Splunk Search

Filter search result to only include events that has top N largest values

Findekano
Engager

Hi -

I am building a query as below:

sourcetype=my-data | eventstats count(request-id) as requestCountByService by remoteServiceName | where requestCountByService > 5000 | timechart count by remoteServiceName

The intent was only services that has more than 5000 requests in the given search time window. There are 2 problems that I want to fix:

  1. The hard coded number 5000 is not flexible. I would like to use something like top 5 to show the top 5 services that made the most requests.
  2. The query above will exclude the request made by other services that doesn't meet the where clause. I want to show them as 'OTHER` group.

How should I update the search query? Thanks in advance!

Tags (1)
0 Karma
1 Solution

Findekano
Engager

Figured it out. Just use timechart directly:

sourcetype=my-data | eventstats count(request-id) as requestCountByService by remoteServiceName | timechart count by remoteServiceName limit=3

View solution in original post

0 Karma

Findekano
Engager

Figured it out. Just use timechart directly:

sourcetype=my-data | eventstats count(request-id) as requestCountByService by remoteServiceName | timechart count by remoteServiceName limit=3

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...