Splunk Search

How to get the top 3 counts for each index?

lys1030
Explorer

Let me make an example to clarify:

Now I have the search result like this:
alt text

How can I get the top 3 counts of each index?
In the end, I want to get search result like this:
alt text

Hope this is clear. Thanks in advance!

Tags (3)
0 Karma
1 Solution

woodcock
Esteemed Legend

You need the top command, like this:

... | top limit=3 count BY index

Or, to keep the country field, this:

... | sort 0 - count | streamstats current=t count AS rank by index | where rank<4 | sort 0 index count

View solution in original post

woodcock
Esteemed Legend

You need the top command, like this:

... | top limit=3 count BY index

Or, to keep the country field, this:

... | sort 0 - count | streamstats current=t count AS rank by index | where rank<4 | sort 0 index count

lys1030
Explorer

Thanks, the second one works!

0 Karma

woodcock
Esteemed Legend

Which one?

0 Karma

lys1030
Explorer

Thanks! the second one works perfectly!

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

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 ...