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

An alert is comprised of


You can specify that an alert be sent via email or RSS, or used to trigger a shell script. You can turn any saved search into an alert.


via SplunkWeb

You can set up an alert at the time you create a saved search, or you can enable an alert on any existing saved search you have permission to edit.


Set up an alert at the time you save a search:

  1. Enter your search terms into the search bar and choose Save search... from the drop-down menu to the left of the search bar. The Save Search popup is displayed.
  1. Fill in the fields to save your search and then click the Schedule & Alerts link at the top of the Save Search popup.

Follow the instructions in the Alert Options section below to continue.


Set up an alert on an existing saved search:

  1. From the drop-down menu to the left of the search bar, choose Saved searches > Manage saves searches. This will launch the saved searches window.
  1. In the table, locate the saved search that you want to turn into an alert.
  1. Click enable in the Running column.

To set up an alert, click the box next to Run this search on a schedule under Schedule & Alerts.


Follow the instructions in the Alert Options section below to continue.


View alert history

The alert history page shows what alerts have been triggered on the server since it was last initialized. To access, click the Admin link in the upper right hand corner and select the Saved Searches tab. Your alerts will show up in the Alert History column.


Alert Options

Schedule


Fill in the blanks to run the alert at regular intervals.


Alert rules


Alert actions


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.1.4 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!