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
Ultra Champion
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
Ultra Champion

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!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...