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!

Combine Multiline Logs into a Single Event with SOCK - a Guide for Advanced Users

This article is the continuation of the “Combine multiline logs into a single event with SOCK - a step-by-step ...

Everything Community at .conf24!

You may have seen mention of the .conf Community Zone 'round these parts and found yourself wondering what ...

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...