Splunk Enterprise

Pass alert count as argument to python script

subramanianp789
New Member

Hi,


I have a requirement to get the alert count from "Searches, Reports, and Alerts" under the Alerts column for the specific saved search.

This Alert count needs to pass as an argument to a python script which will have a counter variable to check the alert value and if crosses certain conditions then send mail has to trigger. How to achieve this.

Thanks

Labels (1)
0 Karma

harsmarvania57
SplunkTrust
SplunkTrust
0 Karma

subramanianp789
New Member

Thanks for your reply.
But how to get the alert count value from "Searches, Reports, and Alerts" under Alerts column for the specific saved search.

Any config file the alert counts will be saved.

0 Karma

harsmarvania57
SplunkTrust
SplunkTrust

I don't have your usecase so not sure whether this will help or not, when you run schedule search you can add custom search command in your query or you can add custom alert action in that schedule search.

if you create custom search command then you can use schedule search query output in python script and do math in your script to count number of alerts and then pass that count to another function which have counter variable to check the alert value and send email from that python script.
If you create custom alert actions then you can use results.csv.gz in your python script, results.csv.gz contain search query output so based on that data you can do math in your python script to count number of alerts and then pass that count to another function which have counter variable to check the alert value and send email from that python script.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...