Splunk Search

Percentages display

shreyad
Explorer

If I want to display percentages as well as a count for a table and I want the percentages out of the total count of the table, how do I display that?

|multisearch [search index = blah sourcetype="blah" host=blah | tstats count WHERE index = blah sourcetype="blah" host=blah earliest=@mon
| eval earliest=if(cou...
OR ("NAME"="blah") | eval Coast ="EastCoast"]

[search index = blah sourcetype="blah " host=blah
| tstats count WHERE index = blah sourcetype="blah " host=blah earliest=@mon
| eval earliest=if(cou...
OR ("NAME"="blah *") | eval Coast ="WestCoast"]| dedup HOST.IP |stats count(blah) as NumberOfIPs by Coast

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try like this

|multisearch [search index = blah sourcetype="blah" host=blah [| tstats count WHERE index = blah sourcetype="blah" host=blah  earliest=@mon 
| eval earliest=if(count=0,"-1mon@mon","@mon") | table earliest ] 
 ("NAME"="blah_*") OR ("NAME"="blah") | eval Coast ="EastCoast"] 
[search index = blah sourcetype="blah " host=blah
[| tstats count WHERE index = blah sourcetype="blah " host=blah earliest=@mon 
| eval earliest=if(count=0,"-1mon@mon","@mon") 
| table earliest ] 
("NAME"="blah _*") OR ("NAME"="blah *") | eval Coast ="WestCoast"]| dedup HOST.IP |stats count(blah) as NumberOfIPs by Coast
| eventstats sum(NumberOfIPs) as Total
| eval Percentage=round(NumberOfIPs*100/Total,2) 
| fields - Total

shreyad
Explorer

Thank you!

0 Karma

CarsonZa
Contributor

you could use |top otherwise you'll have to do some math.

|stats count(_raw) as total
|stats count(x) by x as foo
|eval perc = ((foo / total)*100) + "%"

http://docs.splunk.com/Documentation/Splunk/7.1.2/SearchReference/Top

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud | Unified Identity - Now Available for Existing Splunk ...

Raise your hand if you’ve already forgotten your username or password when logging into an account. (We can’t ...

Index This | How many sides does a circle have?

February 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...