Splunk Search

Getting a percentage value to show up in a statistics table

dbcase
Motivator

Hi,

I have this query

earliest=-6w@w1 index=top10 source=/home/oracle/workdir/account_log.csv STATUS="Reason*"|transaction PREMISE maxspan>19d|eventstats count as grandtotal|eventstats count as ptotal by STATUS|chart sparkline(count) as Trend count(STATUS) as Count values(eval(round(ptotal/grandtotal*100,2))) as Percentage by STATUS | sort -Count

And everything works except for the Percentage near the end. I get multiple values in the Percentage column where the Trend and Count columns are just fine

0 Karma
1 Solution

sundareshr
Legend

Try this

earliest=-6w@w1 index=top10 source=/home/oracle/workdir/account_log.csv STATUS="Reason*"
| transaction PREMISE maxspan>19d
| eventstats count as grandtotal
| chart sparkline(count) as Trend count(STATUS) as Count max(grandtotal) as gtotal count as ptotal by STATUS
| eval Percentage=round(ptotal/gtotal*100, 2)
| sort -Count

View solution in original post

0 Karma

sundareshr
Legend

Try this

earliest=-6w@w1 index=top10 source=/home/oracle/workdir/account_log.csv STATUS="Reason*"
| transaction PREMISE maxspan>19d
| eventstats count as grandtotal
| chart sparkline(count) as Trend count(STATUS) as Count max(grandtotal) as gtotal count as ptotal by STATUS
| eval Percentage=round(ptotal/gtotal*100, 2)
| sort -Count
0 Karma

dbcase
Motivator

That worked perfectly!!!! Thanks Sundareshr!!!!

0 Karma

dbcase
Motivator

Looks like this
Trend Count Percentage
(sparkline is here) 2791 0.05
0.15
0.25
0.41
0.82

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 ...