Splunk Search

How to find top 10 hosts after a sort?

I-Man
Communicator

The following search will give the count of events by host and sort the hosts by count, highest to lowest.

index=summary source="SI Count By Host Every 10m" | stats count by orig_host | sort count

Now I just want to show the top 10 hosts based on their high count. Using the head command will show the first 10 hosts that are found and not the top 10 based on the count that i am trying to display. This seems easy enough but i cannot figure it out...

Feeling very noob right now, help is always appreciated.

Thanks, Iman

Tags (1)
1 Solution

Genti
Splunk Employee
Splunk Employee

I think that's what you're looking for can be achieved by.

index=summary source="SI Count By Host Every 10m" | top limit=10 orig_host

However, if you would like to use your search you could also achieve the same by:

index=summary source="SI Count By Host Every 10m" | stats count by orig_host | sort limit=10 -count 

.gz

View solution in original post

renjujacob88
Path Finder

index=summary source="SI Count By Host Every 10m" | stats count by orig_host | sort 10 - count

0 Karma

rameshyedurla
Explorer

try this
index=_internal source=*license_usage.log type="Usage" | stats sum(b) AS volume by h | eval GB=round(volume/1024/1024/1024,5) | table h GB | sort 10 - GB | rename h AS Host

I-Man
Communicator

index=summary source="SI Count By Host Every 10m" | stats count by orig_host | sort -count | head 10

The above search finally worked for me. There was some kind of bug going on that when I clicked on the top of a column to sort via ascending/descending order, the sort -count OR sort +count would make no difference as the column properties take seemed to take precedence. Not sure why but this only happened when the head function was not present. Weird. Thank you anyways for the quick response Genti.

Genti
Splunk Employee
Splunk Employee

I think that's what you're looking for can be achieved by.

index=summary source="SI Count By Host Every 10m" | top limit=10 orig_host

However, if you would like to use your search you could also achieve the same by:

index=summary source="SI Count By Host Every 10m" | stats count by orig_host | sort limit=10 -count 

.gz

Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...