Hi,
Refer the section "Configure scripted alerts" in Splunk Alert guide.
Splunk currently enables you to pass arguments to scripts both as command line
arguments and as environment variables. This is because command line
arguments don't always work with certain interfaces, such as Windows.
The values available in the environment are as follows:
· SPLUNK_ARG_0 Script name
· SPLUNK_ARG_1 Number of events returned
· SPLUNK_ARG_2 Search terms
· SPLUNK_ARG_3 Fully qualified query string
· SPLUNK_ARG_4 Name of saved search
SPLUNK_ARG_5 Trigger reason (for example, "The number of events was
greater than 1")
·
· SPLUNK_ARG_6 Browser URL to view the saved search
SPLUNK_ARG_8 File in which the results for this search are stored (contains
raw results)
·
SPLUNK_ARG_7 is not used for historical reasons.
These can be referenced in UNIX shell as $SPLUNK_ARG_0 and so on, or in
Microsoft batch files via %SPLUNK_ARG_0% and so on. In other languages (perl,
python, and so on), use the language native methods to access the environment.
These values are also available as positional arguments passed on the
command line of the script. You can use these as well if they are more
convenient. Relatively old versions of Splunk do not provide the environment
variables. However, due to platform reasons, they are not entirely reliable in
Microsoft Windows.
The command line arguments that Splunk passes to the script are:
· 0 = Script name
· 1 = Number of events returned
· 2 = Search terms
· 3 = Fully qualified query string
· 4 = Name of saved search
· 5 = Trigger reason (i.e. "The number of events was greater than 1")
· 6 = Browser URL to view the saved search
· 7 = This option has been deprecated and is no longer used
· 8 = File where the results for this search are stored (contains raw results)
Note: Splunk encourages Windows users to use the $SPLUNK_ARG_
environment variables when passing arguments to scripts.
You can then use the values supplied as an argument in the script to populate the data which will be used by the probe.
Let me know if that helps.
Regards,
Amit Saxena
... View more