Splunk Search

How do I edit my search using tstats to get top hosts by percentage?

mcbradford
Contributor

I run the following every morning, but I know it could be accomplished more efficiently using tstats, but I cannot get the top host by percentage of all host.

index=* | top  20 host

The following gives me the top host, but I also want to know the percentage of all the hosts.

| tstats count by host | sort -count
Tags (3)
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

Try this:

| tstats count by host | eventstats sum(count) as total | eval percentage = count/total*100 | fields - total | sort - count | head 20

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

Try this:

| tstats count by host | eventstats sum(count) as total | eval percentage = count/total*100 | fields - total | sort - count | head 20

martin_mueller
SplunkTrust
SplunkTrust

All you need to do is read the sort docs: | sort 0 - count will work for larger sets.

http://docs.splunk.com/Documentation/Splunk/6.5.1/SearchReference/sort

w531t4
Path Finder

I suppose that works, my mistake. Thanks!

0 Karma

w531t4
Path Finder

I downvoted this post because doesn't work on large event sets over 10000 rows

0 Karma
Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...