Refine your search:

1
2

I'm trying to figure out how to calculate a percent of total such that:

search string | stats count percent by email

Would spit out:

EMAIL               COUNT PERCENT
email@blah.com          5     10%
otheremail@blah.com    10     20%

Thanks! -S.

asked 27 Aug '10, 19:19

sondradotcom's gravatar image

sondradotcom
141117
accept rate: 0%

edited 27 Aug '10, 19:35

Stephen%20Sorkin's gravatar image

Stephen Sorkin ♦
8.9k510


One Answer:

Try the top command:

search string | top email

If you're getting the data from a "stats" or "sistats" in a summary index, it's a bit harder, but certainly possible.

For a summary populated by "stats":

index=summary source=<search_name> | stats sum(count) as count by email | eventstats sum(count) as total | eval percent = round(count/total) . " %" | fields - total

For a summary populated by "sistats":

index=summary source=<search_name> | stats count by email | eventstats sum(count) as total | eval percent = round(count/total) . " %" | fields - total
link

answered 27 Aug '10, 19:36

Stephen%20Sorkin's gravatar image

Stephen Sorkin ♦
8.9k510
accept rate: 52%

edited 27 Aug '10, 19:51

So, I'm searching against a summary index. In an effort to keep the summary index multi-purpose, I created it as a sistats (run hourly), as in:

sourcetype="blah" earliest="-2h@h" latest="-1h@h" | sistats count by email

So if I used "top" for a query on the summary index, and a certain email showed up 100 times each hour, "top" would only count the number of times the email showed up in the summary index (a maximum of one per hour).

So, is it possible to imitate "top" in this circumstance? Am I just making this too hard on myself?

(27 Aug '10, 19:44) sondradotcom

Correct, do not use top in this circumstance. Use stats and eventstats as Stephen as shown above.

(28 Aug '10, 18:20) gkanapathy ♦
Post your answer
toggle preview

Follow this question

Log In to enable email subscriptions

RSS:

Answers

Answers + Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×267

Asked: 27 Aug '10, 19:19

Seen: 1,860 times

Last updated: 27 Aug '10, 19:51

Copyright © 2005-2012 Splunk Inc. All rights reserved.