Splunk Search

Create alert based on success rate per a group

MaratD
Explorer

Hi all,

I need to create an alert based on a success rate less than a specific value. My data is as follows:

store = "store1" result= "success"
store = "store1" result= "success"
store = "store1" result= "success-with-warnings"
store = "store1" result= "failed"

store = "store2" result= "success-with-warnings"
store = "store2" result= "failed"

store = "store3" result= "success-with-warnings"
store = "store3" result= "success"

I need to calculate the success rate based on each store. Result = "success" or "success-with-warnings" are considered a success, all other result values are considered failed. For example, using the above data, the search result should be something like this:

store1 %75 success
store2 %50 success
store3 %100 success

Then I need to use those values to create an alert, that will be triggered daily to check stores with a success rate is less than 70%. So in this case, I will get an alert for store2.

 

 

 

 

 

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Use something like this for your alert search

your search
| eventstats count as total by store
| eval success=if(result="success" OR result="success-with-warnings",1,0)
| stats sum(success) as successes values(total) as total by store
| eval success_rate=100*successes/total
| where success_rate < 70

Then set your alert to trigger if any rows are returned

View solution in original post

0 Karma

yuanliu
SplunkTrust
SplunkTrust

This filter

 

| eval result = if(match(result, "^success"), "succeeded", "failure")
| stats count by store result
| eventstats sum(count) as subtotal by store
| eval percent = round(count / subtotal * 100) . "%"
| where result == "succeeded"
| table store percent result

 

gives something like

storepercentresult
store175%succeeded
store267%succeeded
store389%succeeded

 

Here, I used "succeeded" to illustrate that it is a combined count.  You can use any word.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Use something like this for your alert search

your search
| eventstats count as total by store
| eval success=if(result="success" OR result="success-with-warnings",1,0)
| stats sum(success) as successes values(total) as total by store
| eval success_rate=100*successes/total
| where success_rate < 70

Then set your alert to trigger if any rows are returned

0 Karma

MaratD
Explorer

exactly what  I neee! thanks!

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

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...