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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...