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!

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...