Splunk Search

Eval count in two searches

macadminrohit
Contributor

Hi,

I have a search that lists top 50 events based on the following search :

index=servers sourcetype=json appName="" AND appName!="*Server" AND appName!="Service") locId=* level=Warning OR level=Error OR level=Critical) bdy.msg="Scanner*"
top 50 appName level msg bdy.ex.Msg | addcoltotals | fields - percent

This give me top 50 events with their count. I have another search with slight change :

index=servers sourcetype=json appName="" AND appName!="*Server" AND appName!="Service") locId=* level=Information bdy.msg="Scanner*"
top 50 appName level msg bdy.ex.Msg | addcoltotals | fields - percent

only thing changing is Level . Now i have to calculate the ratio of both the counts from two searches. how can i do that. any help is highly appreciated.

Thanks
Rohit

Tags (1)
0 Karma

somesoni2
Revered Legend

Give this a try

index=servers sourcetype=json (appName="*"  AND appName!="*Server*" AND appName!="*Service*") locId=* (level=Warning OR level=Error OR level=Critical OR level=Information)   bdy.msg="Scanner*"
| eval level=if(level="Information",level,"NonInformation")
|  top 50 appName msg bdy.ex.Msg by level showperc=f 
| eval Info=if(level="Information",count,null())
| eval NonInfo=if(level!="Information",count,null())
| stats values(Info) as Info values(NonInfo) as NonInfo by appName msg bdy.ex.Msg
| addcoltotals 
| eval Ratio=Info/NonInfo
0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...