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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...