Alerting

How to pass our command line arguments to script called from Splunk for alert triggered

jayannah
Builder

Hi

I configured an Alert for some search and configured perl script to be called when Alert is triggered. I understand by default Splunk sends some values as command line arguments to script (Ref: http://docs.splunk.com/Documentation/Splunk/5.0/Alert/Configuringscriptedalerts ).

My questions are here:
1. Can I pass my own values (not fixed values) to script as command line argument? The values may be derived from search and hence may change everytime.
2. Is there any limits for passing command line arguments to script from Splunk?

If someone answers with examples helps lot to many splunk users.

Regards
Jay

Tags (3)
0 Karma

Mathieu_Dessus
Splunk Employee
Splunk Employee
0 Karma

gkanapathy
Splunk Employee
Splunk Employee

First of all, if these are not 'fixed' how are they going to be set? Scripted alerts are launched by an instance of a Splunk saved search. Where would the instance of the search get these varying parameters?

Generally, you can have parameters that are fixed (simply by wrapping them in simple script, for example) or that vary by the saved search definition (by either using alert_actions.conf or by performing logic in the wrapper script), or you can have instance-specific actions by having your script use the documented parameters or the results file.

jayannah
Builder

Thanks for the response gkanapathy.

If I configure the alert to call the script, Splunk tool passes complete results as argument. But, I want to pass only few values extracted from result to script.

Here my scenario
1. I will issue the following search in Splunk. The result will have host and source parameters & its values. I want to call python script with parameters host & source values.

Spunk Search:
source="D:\Splunk\sample-log.txt" shutdown | script python myPythonScript <> <>

Can you please explain how to call the values from result to the python script?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...