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!

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...

SPL2 Deep Dives, AppDynamics Integrations, SAML Made Simple and Much More on Splunk ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...