Splunk Search

Help with making stats table in decreasing order

jialiu907
Path Finder

I am looking for the table to be in decreasing order and with the Total row on top. 

This is my current search. 

index=jia source="/hptc_cluster/splunk/Reports/PBS/splunkresults.csv" host="gridmetrics" sourcetype="JiaGridMetrics"
| stats count as Slots by JobName
| rename Slots as CPU
| addcoltotals label=Total labelfield=JobName
| sort count desc

This is the output.

jialiu907_0-1685026069032.png

 

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

You're asking the sort command to sort on a field that doesn't exist (count).  Choose either CPU or JobName for the sort.

index=jia source="/hptc_cluster/splunk/Reports/PBS/splunkresults.csv" host="gridmetrics" sourcetype="JiaGridMetrics"
| stats count as CPU by JobName
| addcoltotals label=Total labelfield=JobName
| sort - CPU

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

You're asking the sort command to sort on a field that doesn't exist (count).  Choose either CPU or JobName for the sort.

index=jia source="/hptc_cluster/splunk/Reports/PBS/splunkresults.csv" host="gridmetrics" sourcetype="JiaGridMetrics"
| stats count as CPU by JobName
| addcoltotals label=Total labelfield=JobName
| sort - CPU

 

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Wrapping Up Cybersecurity Awareness Month

October might be wrapping up, but for Splunk Education, cybersecurity awareness never goes out of season. ...

🌟 From Audit Chaos to Clarity: Welcoming Audit Trail v2

🗣 You Spoke, We Listened  Audit Trail v2 wasn’t written in isolation—it was shaped by your voices.  In ...

What's New in Splunk Observability - October 2025

What’s New?    We’re excited to announce the latest enhancements to Splunk Observability Cloud and share ...