Splunk Enterprise

Help with a query to calculate percentage

sunny_871
New Member

Hello, I am working on a query where I need to set an alert based on failure percentages. Calculating the failure percentage is the tricky part. Here is my sample query - 

index=myindex  (status=success OR status=inprogress) 
| bin _time 
| stats count(eval(like(status, "success"))) as success count(eval(like(status, "inprogress"))) as inprogress by id _time 

 

The conditions for access and failure are as below -

Success - 

| where success = 1 AND inprogress >=1

Failure -

| where success = 0 AND inprogress >=1

Now I want to create an alert based on failure percentage of 10%. How do i calculate the failure and success percentage here? The id you are seeing in the BY clause is nothing but customer ID so I'd like to get alerted based on 10% failure,

Best Regards

Labels (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Your search looks a little odd for what you are trying to do although it does depend on your data.

Since you have _time in your by clause, it is likely that your success count is likely to be either 1 or zero, same with the inprogress count.

If you remove the _time from your by clause, you will get the counts across the whole of the time period of the search (which might be what you actually want)

You can then do an eval based on your criteria for success or failure and count those again over the time period of your search using another stats command.

Finally, you can do an eval to determine the percentage success of all the events within the time period

0 Karma

sunny_871
New Member

Hi @ITWhisperer Thanks for the response. I have removed the _time.

Sorry how would i create or generate an eval with the below success and failure conditions? Could you give me a guidance.,

Best Regards,
Shashank

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval status=case(success = 1 AND inprogress >=1, "success", success = 0 AND inprogress >=1, "failure")
0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...