Splunk Search

compute the ratio of some specific fields in total event

hjwang
Contributor

Hello,i would like to compute the ratio of some specific fields in total event, for example, in IPS attack event log, i wanna get known with the ratio of scr_ip coming from the specific country in total attack event, it seems straightforward, but i don't know how to use search command.(that is to say the number of events by using src=xxx or src=xxx..., divided by the number of events non-using such condiction), Thanks!!

Tags (1)
0 Karma
1 Solution

gkanapathy
Splunk Employee
Splunk Employee
... | stats count(src=="xxx") as xxx_count, count as total_count | eval ratio = xxx_count/total_count

View solution in original post

suminty
New Member

You would need to add eval with stats some thing like

| stats count(eval(rslt=="found")) as cache_hit, count as total_count | eval ratio=cache_hit/total_count
,we will need add eval in stats something like:


| stats count(eval(rslt=="found")) as cache_hit, count as total_count | eval ratio=cache_hit/total_count

0 Karma

gkanapathy
Splunk Employee
Splunk Employee
... | stats count(src=="xxx") as xxx_count, count as total_count | eval ratio = xxx_count/total_count

hjwang
Contributor

thanks, i try it, but the syntax stats should be count(eval(src="xxx")) as xxx_count

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...