Splunk Search

Calculate percentage of total and display as pie chart

balash1979
Path Finder

I have total of 7M users. My splunk query shows the count of completed users. I want to draw a pie chart showing completed users vs Total users. 

So far I have gotten this far 

    << my query>> | eval TotalMax=7000000 | stats count(Path) as completed | eval perc=(completed/TotalMax)/100 | table completed,perc

count(Path) which is same as completed comes out as 200000
But perc is not getting calculated.  Am I missing anything ?

--Sunray

Labels (1)
0 Karma
1 Solution

scelikok
SplunkTrust
SplunkTrust

Hi @balash1979,

After stats command only fields  that stats outputs are exist. On your case you are loosing TotalMax field, so perc cannot be calculated. Below should work;

    << my query>> 
| stats count(Path) as completed 
| eval TotalMax=7000000
| eval perc=(completed/TotalMax)/100 
| table completed,perc

OR

    << my query>> 
| eval TotalMax=7000000 
| stats count(Path) as completed values(TotalMax) as TotalMax
| eval perc=(completed/TotalMax)/100 
| table completed,perc

 

If this reply helps you an upvote is appreciated.

If this reply helps you an upvote and "Accept as Solution" is appreciated.

View solution in original post

Tags (1)

balash1979
Path Finder

Thanks. If i add "table completed, perc" , i can get the correct data. 

How can i display this as a pie chart ? in the pie chart, i would like to see % completed out of the total. Thanks

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @balash1979,

After stats command only fields  that stats outputs are exist. On your case you are loosing TotalMax field, so perc cannot be calculated. Below should work;

    << my query>> 
| stats count(Path) as completed 
| eval TotalMax=7000000
| eval perc=(completed/TotalMax)/100 
| table completed,perc

OR

    << my query>> 
| eval TotalMax=7000000 
| stats count(Path) as completed values(TotalMax) as TotalMax
| eval perc=(completed/TotalMax)/100 
| table completed,perc

 

If this reply helps you an upvote is appreciated.

If this reply helps you an upvote and "Accept as Solution" is appreciated.
Tags (1)
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!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...