Admin Manual

 


Configure scripted alerts

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

Configure scripted alerts

Configure scripted 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.

Script options

Your alert can trigger a shell script, which must be located in $SPLUNK_HOME/bin/scripts. Use the following attribute/value pairs:

action_script = <string>

If you want to run a script written in a different language (e.g. Perl, Python, VBScript) you must specify the interpreter you want Splunk to use in the first line of your script, following the #!. For example:

to run a Perl script:

---- myscript.pl ----
#!/path/to/perl
......
......

to use Python to interpret the script file:

---- myscript.py -----
#!/path/to/python
.....
.....

For an example on how scripts can be configured to work with alerts, see send SNMP traps.


Example

You can configure Splunk to send alerts to syslog. This is useful if you already have syslog set up to send alerts to other applications, and you want Splunk's alerts to be included.

Check the Splunk Wiki for information about the best practices for using UDP when configuring Syslog input.

Write a script that calls logger (or any other program that writes to syslog). Your script can call any number of the variables your alert returns.

Create the following script and make it executable:

logger $5

Put your script in $SPLUNK_HOME/bin/scripts.

Now write an alert that calls your script. See Set Up Alerts for information on alert configuration. Configure the alert to call your script by specifying the path in the Trigger shell script field of the alert.

Edit your saved search to call the script. If your script is in $SPLUNK_HOME/bin/scripts you don't have to specify the full path.

30 admin7 syslog-logit.jpg

This logs the trigger reason to syslog:

Aug 15 15:01:40 localhost logger: Saved Search [j_myadmin]: The number of events(65) was greater than 10

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.