Splunk Search

How to count pass of fail rate from all if conditions

jenniferhao
Explorer

I have the following , I want to know how to calculate rate on rule1, rule 2, rule3.... pass and fail rates(only for condition matched data).

index=ABC sourcetype=ABC_1 
|eval exception=""
|eval num=0
| eval exception=if(exception="" AND con1 = "1" AND element1 = "v1" AND value != "3", "AAA",exception)   #rule1
| eval exception=if(exception="" AND con2 = "5" AND element3 = "v2" AND value != "true", "BBB",exception)  #rule2
| eval exception=if(exception="" AND con3 = "1" AND element6 = "v3" AND value != "true", "CCC",exception)   #rule3

....

| where exception!="" 
| ....
0 Karma

kmorris_splunk
Splunk Employee
Splunk Employee

You could use the following syntax to count each (AAA, BBB, or CCC) then do any math you want using those counts.

YOUR BASE SEARCH
| stats count(eval(exception="AAA")) as aaacount count(eval(exception="BBB")) as bbbcount count(eval(exception="CCC")) as ccccount 
0 Karma

Sukisen1981
Champion

pretty much the way you described it, except in splunk syntax. You first eval your rules using case or if ..if none of your conditions are met, assign eval to "" or some other placeholder end with a | where like you have done.
If you want us to help build the SPL, please share a bit more sample events and rules and expected output

0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...