Splunk Search

Using Eval function to calculate percentage

ldlopez38
Observer

I'm hoping someone can help me out here. I'm looking to create a simple table that displays a column for "count" and another for "Percentage of total". For some reason splunk is not recognizing the total field within the denominator of my eval command. Any suggestions on how to append this? 

 

index=ABC sourcetype="ABC" "EVNT=SWIendcall" |stats count by OUTCOME | addtotals row=f col=t labelfield=OUTCOME |eval Percentage=ROUND((count/Total)*100,1)

ldlopez38_0-1656022941493.png

 

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Splunk generally works on a pipeline of events so the total has to be a field in each event. Try something like this.

index=ABC sourcetype="ABC" "EVNT=SWIendcall" |stats count by OUTCOME 
| eventstats sum(count) as Total
| eval Percentage=ROUND((count/Total)*100,1)
| addtotals row=f col=t labelfield=OUTCOME 
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...