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!

Developer Spotlight with Brett Adams

In our third Spotlight feature, we're excited to shine a light on Brett—a Splunk consultant, innovative ...

Index This | What can you do to make 55,555 equal 500?

April 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...