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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...