Splunk Search

Display the "others" or the rest after showing top results

christopheryu
Communicator

I have this search to show top 5 values:

search... | fields ALARM | stats count by ALARM | sort limit=5 -count

Result for above is shown in a dashboard as a pie chart. How do I search for the rest of ALARM to show in a separate pie chart? Values for ALARM vary depending on time range.

Sorry if duplicate, did not find a similar question.

Tags (1)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try like this

search... | fields ALARM | top limit=5 useother=t showperc=f ALARM

Updated

Try this. This will exclude top 5 and give the rest (streamstats will assign rank/serial no to sorted list and then we filter top 5)

search...| fields ALARM | stats count by ALARM | sort 0 -count | streamstats count as rank | where rank>5 | fields - rank

View solution in original post

DalJeanis
SplunkTrust
SplunkTrust

search...
| fields ALARM
| stats count by ALARM
| search NOT [search... | fields ALARM | stats count by ALARM | sort limit=5 -count | table ALARM]

0 Karma

christopheryu
Communicator

this works if my time range is set to past 3 days where there are less than 1M events, however, when I tried past 30 days with 10M events, it pulled up all ALARM values

0 Karma

christopheryu
Communicator

sorry, this actually works, forgot to add the table ALARM at the end. however, this takes twice the time as compared to somesoni2's - thank you!

0 Karma

DalJeanis
SplunkTrust
SplunkTrust

That makes sense - it's doing twice the work!

Wouldn't have posted it at all if somesoni2's second answer had been posted yet.

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try like this

search... | fields ALARM | top limit=5 useother=t showperc=f ALARM

Updated

Try this. This will exclude top 5 and give the rest (streamstats will assign rank/serial no to sorted list and then we filter top 5)

search...| fields ALARM | stats count by ALARM | sort 0 -count | streamstats count as rank | where rank>5 | fields - rank

christopheryu
Communicator

this pulled up the top 5 and "other" values for ALARM

0 Karma

somesoni2
SplunkTrust
SplunkTrust

I didn't fully read I guess. Try the updated answer.

0 Karma

christopheryu
Communicator

thank you, this works.

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...