Splunk Enterprise

Passing search results to a python script in alert_actions

fabrizioalleva
Path Finder

Hi all,

I'm trying to execute a script in a scheduled Alerts, when results of a search are greater than 0.

I've created my $SPLUNK_HOME/etc/apps/[myapp]/default/alert_actions.conf, following:

https://dev.splunk.com/enterprise/docs/devtools/customalertactions/configappcaa

and I've this:

[MyAction]
is_custom = 1
label = MyAction
description = open ticket
payload_format = json
python.version = python3

alert.execute.cmd = test.py

param.datemod =
param.devname =
param.toner =

I've put 3 params in the same file, and everything I write after = generates this error:

Invalid key in stanza [MyAction] in /splunk/sh/etc/apps/monitor/default/alert_actions.conf, line 9: param.datemod (value: ).
Invalid key in stanza [MyAction] in /splunk/sh/etc/apps/monitor/default/alert_actions.conf, line 10: param.devname (value: ).
Invalid key in stanza [MyAction] in /splunk/sh/etc/apps/monitor/default/alert_actions.conf, line 11: param.toner (value: ).

I understood that it's waiting for something after the =, I've tried  ( datemod, devname, toner that are the output of the search ) but nothing.

I configured the web gui alert with MyAction as Trigger Action ( the action is now running every 2 minutes )

The script is executed, because I write a static line into a file, and I see that the file is always update.

But how can I pass the search results to the script ?

Reading the guide it's no so clear for me.

Thanks in advance for any help!

Fabrizio

 

Labels (1)
Tags (2)
0 Karma
1 Solution

fabrizioalleva
Path Finder

thank for your help!

I've found that I've to configure alert_actions.conf.spec file in README dir of my own application.

After some attempts all is wortking fine

View solution in original post

0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @fabrizioalleva 

I dont think those errors should cause it not to work, they are reporting as errors because there is no corresponding spec file update for your custom alert action. Have a look at https://github.com/splunk/itsi-deep-dive-email-alert/blob/master/README/alert_actions.conf.spec - basically you need to create a README/alert_actions.conf.spec in your app with something like this:

[MyAction]
param.datemod = <string>
param.devname = <string>
param.toner = <string>

🌟 Did this answer help you? If so, please consider:

  • Adding karma to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma

fabrizioalleva
Path Finder

thank for your help!

I've found that I've to configure alert_actions.conf.spec file in README dir of my own application.

After some attempts all is wortking fine

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Build the Future of Agentic AI: Join the Splunk Agentic Ops Hackathon

AI is changing how teams investigate incidents, detect threats, automate workflows, and build intelligent ...

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...