This documentation does not apply to the most recent version of Splunk.
This documentation applies to the following versions of Splunk: 3.2 , 3.2.1 , 3.2.2 , 3.2.3 , 3.2.4 , 3.2.5 , 3.2.6
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.
First, configure a saved search. Then, add the following attribute/value pairs to your saved search stanza to create an alert:
counttype = <string>
relation = <string>
quantity = <integer>
schedule = <string>
action_rss = <integer>
action_email = <string>
sendresults = <integer>
execDelay = <integer>
maxresults = <integer>
Note: This is different from specifying maxresults during a search (maxresults:: search modifier in older versions, or -maxresults in the CLI in versions 3.2 and above).
Optionally set the display options for your saved search in savedsearches.conf. Here are the possible attribute/value pairs:
viewstate.resultView = reportView
viewstate.chart.plotMode = column
viewstate.prefs.selectedKeys = source host sourcetype
Your alert can trigger a shell script. Use the following attribute/value pair:
action_script = <string>
Note: If there are no saved tags, $7 becomes the name of the file containing the search results ($8).
All scripts must be shell scripts. If you want to run a script written in a different language (e.g. PERL, Python, VBScript) you must wrap it inside a shell script file which will interpret and pass Splunk's parameters to the script responsible for the heavy lifting. Specify the interpreter you want Splunk to use in the first line of your script, following the #!. For example:
---- myscript.pl ---- #!/path/to/perl ...... ......
---- myscript.py ----- #!/path/to/python ..... .....
For examples on how scripts can be configured to work with alerts, see send SNMP traps and send syslog events.
This example runs a search for events containing the term "sudo" on a schedule, and sends the results via an RSS feed.
[sudoalert] action_rss = 1 counttype = number of events enableSched = 1 quantity = 0 search = sudo relation = greater than schedule = */12 * * * * sendresults = 0 role = Admin