Splunk Search

How to calculate percentage from 2 different searches?

jip31
Motivator

hello

I try to calculate a percentage from 2 searches results
I know how to count results from my first search :

index="x" sourcetype=y source="z" EventCode=6008 

And I know how to count results from my second search

[| inputlookup host.csv ]|

But I dont succeed to calcul a percentage by divising the first search result by the second search result
I would like to do something like this :

eval search 1 = toto
eval search 2 = titi
eval result =( toto/titi)*100

Could you help me please?

0 Karma
1 Solution

niketn
Legend

@jip31 please try out the following and confirm.

index="x" sourcetype=y source="z" EventCode=6008 
| stats count as toto
| appendcols 
   [| inputlookup host.csv 
     | stats count as titi]
| eval Perc=round((toto/titi)*100,2)

Following is a run anywhere example based on Splunk's _internal and _audit indexes on similar lines (provided you have access to query these indexes)

| tstats count as "Internal" where index=_internal sourcetype="splunk*" 
| appendcols 
    [| tstats count as "Audit" where index=_audit
        ]
| eval Perc=round((Audit/Internal)*100,2)
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@jip31 please try out the following and confirm.

index="x" sourcetype=y source="z" EventCode=6008 
| stats count as toto
| appendcols 
   [| inputlookup host.csv 
     | stats count as titi]
| eval Perc=round((toto/titi)*100,2)

Following is a run anywhere example based on Splunk's _internal and _audit indexes on similar lines (provided you have access to query these indexes)

| tstats count as "Internal" where index=_internal sourcetype="splunk*" 
| appendcols 
    [| tstats count as "Audit" where index=_audit
        ]
| eval Perc=round((Audit/Internal)*100,2)
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

jip31
Motivator

thanks you are the best 😉

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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...