Admin Manual

 


How Splunk Works

Set up Alerts

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

Set up Alerts

Alerts in Splunk are equivalent to cron or batch jobs. An alert is comprised of: saved search terms, a schedule to run it, rules to trigger it and actions to perform. Alerts can be sent via email or RSS, or used to trigger a shell script. Any saved search can be turned into an alert.


via SplunkWeb

You can set up alerts either through the Saved Search tab of the Admin link. By clicking on any saved search, you can set up an alert:


30 admin7 setupalerts-alertprops.jpg


Or you can configure an alert through the saved search link in the drop down menu next to the search box. Click on the Schedule & Alerts tab:


30 admin7 setupalerts-ssearch.jpg


Alert Options

Schedule


Alert Rules


Alert Actions


Alert History


Specify which fields to show

When you receive alerts, any fields included in your search will also be displayed. You can edit the saved search to change which fields are displayed in your alert.


To eliminate a field, pipe your search to fields - $FIELDNAME. To add a field, pipe your search to fields + $FIELDNAME. You can add or subtract any number of fields -- just separate them with a comma: fields - $FIELD1, $FIELD2 + $FIELD3, $FIELD4.


For example:


GenericJDBCException starthoursago::01 | fields - sourcetype

This search will keep the sourcetype field from appearing in your alerts.


via configuration files

You can configure the above aspects through savedsearches.conf. Copy savedsearches.conf from $SPLUNK_HOME/etc/bundles/default/ into $SPLUNK_HOME/etc/bundles/local/. Open $SPLUNK_HOME/etc/bundles/local/savedsearches.conf file. You can edit all of the fields below:


[<Splunk name>]
        * Name of the saved Splunk (header)
query = <string>
        * Actual query terms of this saved Splunk (eg. index::sampledata http NOT 500)
isglobal = <integer>
        * If isglobal is set to 1, everyone can see/use this Splunk
        Possible values: 1/0.
counttype = <string>
    * Which count to compare the quantity against relation
    Possible values: "number of events", "number of hosts",
        "number of sources", "number of sourcetypes"
relation = <string>
    * How to compare against count
    Possible values: "greater than", "less than", "equal to",
        "drops by", "rises by"
quantity = <integer>
    * Number to compare against the number returned for the given counttype
schedule = <string>
    * Cron style schedule (i.e. */12 * * * *)
action_script = <string>
    * Name of shell script to run
action_rss = <integer>
    * Whether or not to create an rss link
    Possible values: 1/0
action_email = <string>
    * Comma delimited list of email addresses to send to
sendresults = <integer>
    * Whether or not to send the results along with the email/shell script
    Possible values: 1/0

For example:


[sudoalert]
action_rss = 1
counttype = number of events
disabled = false
enableSched = 1
isGlobal = 0
quantity = 0
query = sudo
relation = greater than
schedule = */12 * * * *
sendresults = 0
userid = 1

Script options

Your alert can trigger a shell script.


Specify the name of the script file to run when a saved search triggers an alert. You don't need to provide the path to the script if the script is located under $SPLUNK_HOME/bin/scripts/.


Command line arguments passed to the script are:


$1 - number of events returned when search run
$2 - searched terms saved at the time saved search was created
$3 - fully qualified query string, the way query is run internally
$4 - saved search name
$5 - trigger reason for the alert
$6 - encoded http link to the saved search results
$7 - tags that have been saved against this saved search, if there are any.

For examples on how scripts can be configured to work with alerts, please see send SNMP traps and send syslog events.

This documentation applies to the following versions of Splunk: 3.0 , 3.0.1 , 3.0.2 , 3.1 , 3.1.1 , 3.1.2 , 3.1.3 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!