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
Revered Legend

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
Legend

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
Legend

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
Revered Legend

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
Revered Legend

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!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...