Splunk Search

How to create a single alert for multiple error codes

shady6
Loves-to-Learn

Following is my query:

index=backup | stats count by errors

I have thousands of error codes in logs and I need to trigger a unique alert for each error code. Is it possible to create a single alert? I have saved the above query with "for each result" option but still get only one trigger with all the error codes. 

Labels (3)
0 Karma

Tom_Lundie
Contributor

I can't recreate your issue.

Using this run anywhere example:

| makeresults count=100
| eval e = substr(tostring(random()), -1)
| eval errors = case(e <= 2, "Error1", e <= 5, "Error2", e <= 8, "Erro3" , 1=1, "Error4")
| stats count by errors

I set up an alert with a send email action and set the alert to be "For each result". I subsequently received four emails.

Make sure you're not throttling the alert, and make sure "For each result" is definitely set.

If you still have no luck then I suspect you could be hitting a bug? Can you share your Splunk version and a screenshot of the alert and I'll see if I can recreate it.

 

 

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...