Splunk® Enterprise

Search Reference

Splunk Enterprise version 7.2 is no longer supported as of April 30, 2021. See the Splunk Software Support Policy for details. For information about upgrading to a supported version, see How to upgrade Splunk Enterprise.
This documentation does not apply to the most recent version of Splunk® Enterprise. For documentation on the most recent version, go to the latest release.

sendalert

Description

Use the sendalert command to invoke a custom alert action. The command gathers the configuration for the alert action from the alert_actions.conf file and the saved search and custom parameters passed using the command arguments. Then the command performs token replacement. The command determines the alert action script and arguments to run, creates the alert action payload and executes the script, handing over the payload by using STDIN to the script process.

When running the custom script, the sendalert command honors the maxtime setting from the alert_actions.conf file and terminates the process if the process runs longer than the configured threshold. By default the threshold is set to 5 minutes.

See Write the script for a custom alert action for Splunk Cloud Platform or Splunk Enterprise in the Developer Guide on the Developer Portal.

Syntax

sendalert <alert_action_name> [results_link=<url>] [results_path=<path>] [param.<name>=<"value">...]

Required arguments

alert_action_name
Syntax: <alert_action_name>
Description: The name of the alert action configured in the alert_actions.conf file

Optional arguments

results_link
Syntax: results_link=<url>
Description: Set the URL link to the search results.
results_path
Syntax: results_path=<path>
Description: Set the location to the file containing the search results.
param.<name>
Syntax: param.<name>=<"value">
Description: The parameter name and value. You can use this name and value pair to specify a variety of things, such as a threshold value, a team name, or the text of a message.

Usage

When you use the sendalert command in an ad hoc search, the command might be called multiple times if there are a large number of search results. This occurs because previewing the search results on the Statistics tab is enabled by default. If you are using an ad hoc search to test the sendalert command, testing turn off preview to avoid the command being called multiple times.

When the sendalert command is included in a saved search, such as a scheduled report or a scheduled search, the command is called only one time.

Search results format

When the sendalert command is used in a search or in an alert action, the search results are stored in an archive file in the dispatch directory using the CSV format. The file name is results.csv.gz. The default format for the search results is SRS, a Splunk-specific binary format for the search results. The CSV format for the archive file is used so that scripts can process the results file. The default SRS format is not designed to be parsed by scripts.

The archived search results format is controlled through the forceCsvResults setting. This setting is in the [default] stanza in the alert_actions.conf file.

Examples

Example 1: Invoke an alert action without any arguments. The alert action script handles checking whether there are necessary parameters that are missing and report the error appropriately.

... | sendalert myaction

Example 2: Trigger the hipchat custom alert action and pass in room and message as custom parameters.

... | sendalert hipchat param.room="SecOps" param.message="There is a security problem!"

Example 3: Trigger the servicenow alert option.

... | sendalert servicenow param.severity="3" param.assigned_to="DevOps" param.short_description="Splunk Alert: this is a potential security issue"

Last modified on 14 March, 2023
selfjoin   sendemail

This documentation applies to the following versions of Splunk® Enterprise: 7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.2.8, 7.2.9, 7.2.10, 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 7.3.5, 7.3.6, 7.3.7, 7.3.8, 7.3.9, 8.0.0, 8.0.1, 8.0.2, 8.0.3, 8.0.4, 8.0.5, 8.0.6, 8.0.7, 8.0.8, 8.0.9, 8.0.10


Was this topic useful?







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

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters