Splunk Search

How can I get top x results and then do stats on top x

ashabc
Contributor

I have web page logs that have several fields. The important ones for this are CDN locations x_edge_location and the response time time_taken

How can I first find out top 5 x_edge_location and then do a stats on those top 5 locations for average time_taken?

Tried the following, does not work

...| top 5 x_edge_location | fields x_edge_location, time_taken | stats avg(time_taken) by x_edge_location

I guess its not working, because top does not return any additional fields other than the field on which top operation is carried out and the count.

0 Karma
1 Solution

immortalraghava
Path Finder

| stats count as total avg(time_taken) as Avg by x_edge_location | sort 5 -total

Please try this and let me know if this works !

View solution in original post

immortalraghava
Path Finder

| stats count as total avg(time_taken) as Avg by x_edge_location | sort 5 -total

Please try this and let me know if this works !

ashabc
Contributor

Wow! Why I did not think that way. That is what exactly I was looking for. Thank you.

0 Karma

ashabc
Contributor

It will be nice to have a feature like this.

| stats avg(time_taken) by top 5 x_edge_location

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...