Admin Manual

 


Set up alerts in savedsearches.conf

This documentation does not apply to the most recent version of Splunk. Click here for the latest version.

Set up alerts in savedsearches.conf

Configure alerts with savedsearches.conf. Use the $SPLUNK_HOME/etc/system/README/savedsearches.conf.example as an example, or create your own savedsearches.conf. Edit this file in $SPLUNK_HOME/etc/system/local/, or your own custom application directory in $SPLUNK_HOME/etc/apps/. For more information on configuration files in general, see how configuration files work.

Follow these steps:

1. Create a saved search.

2. Schedule the search.

3. Define alert conditions.

4. Configure alert actions.

You can set up an alert at the time you create a saved search, or add the alert configurations to your saved search stanza later.

Note: You must have email enabled on your Splunk server for alerts to be sent out. Alternately, your Splunk server must be able to contact your email server. Configure email settings in Manager.

Create a saved search

First, set up a saved search. You can also set up a saved search via savedsearches.conf.

Schedule the search

Next, schedule your search. This means your search runs on the specified schedule. For example, Splunk runs your search every hour or at midnight. If your search meets the alert conditions, then Splunk alerts you.

Add the following attribute/value pairs to your saved search stanza to run the search on a schedule:

userid = <integer>

enableSched = < 0 | 1 >

schedule = <string>

Note Cron lets you use standard cron notation to define your scheduled search interval. In particular, cron can accept this type of notation: 00,20,40 * * * *, which runs the search every hour at hh:00, hh:20, hh:40. Along the same lines, a cron of 03,23,43 * * * * runs the search every hour at hh:03, hh:23, hh:43. Splunk recommends that you schedule your searches so that they're staggered over time. This reduces system load. Running all of them (*/20) every 20 minutes means they would all launch at hh:00 (20, 40) and might slow your system every 20 min.

execDelay = <integer>

Alert conditions

Now define alert conditions. Alert conditions tell Splunk whether or not to send you an alert. Enter a threshold number of events, sources, or hosts in your results. If the alert conditions are met, Splunk notifies you via email or triggers a shell script.

counttype = <string>

relation = <string>

quantity = <integer>

So if you have the following:

counttype = number of events
relation = rises by
quantity = 25

Splunk alerts you if your search results have risen by 25 since the last time the search ran.

You can also define a search condition for your alerts:

alert_condition = <string>

Configure email alert actions

Tell Splunk to send an email once an alert is triggered.

action.email = 0 | 1

Configure the format of the email that is sent. These will override the settings that are defined in alert_actions.conf:

action.email.to = <string>


action.email.from = <email address>


action.email.subject = <string>


action.email.mailserver = <string>

Example

This example runs a search for events containing the term "sudo" on a schedule, and sends the results via email.

[sudoalert]
action.email = 1
action.email.to = me@work.org 
action.email.from = splunk@work.org
action.email.subject = Sudo Alert!
action.email.mailserver = mail.work.org
counttype = number of events
enableSched = 1
quantity = 10
search = sudo
relation = greater than
schedule = */12 * * * *
role = Admin

This documentation applies to the following versions of Splunk: 4.0 , 4.0.1 , 4.0.2 , 4.0.3 , 4.0.4 , 4.0.5 , 4.0.6 , 4.0.7 , 4.0.8 , 4.0.9 , 4.0.10 , 4.0.11 View the Article History for its revisions.


You must be logged into splunk.com in order to post comments. Log in now.

Was this documentation topic helpful?

If you'd like to hear back from us, please provide your email address:

We'd love to hear what you think about this topic or the documentation as a whole. Feedback you enter here will be delivered to the documentation team.

Feedback submitted, thanks!