Splunk Search

Finding all instances of a field greater than the avg of that field during a 15 minute span

kultar
Engager

Hi All,

I have a field "TotalResponse" which is the total response time for a web request. I'm attempting to determine the following:
1. What the average "TotalResponse" is over a 15 minute span
2. Return any result where "TotalResponse" is greater than the average
3. Total % of responses that were greater than the average

I'm having a bit of a tough time figuring out part 2, hopefully someone can help?

Cheers
K

Tags (3)
0 Karma
1 Solution

sideview
SplunkTrust
SplunkTrust

Give this a shot:

<your search here> | eventstats count as globalCount avg(TotalResponse) as globalAvg | where TotalResponse > globalAvg | stats count as greaterThanAverageCount last(globalAvg) as globalAvg last(globalCount) as globalCount | eval percent = 100 * greaterThanAverageCount / globalCount | table globalAvg percent

The Eventstats command allows you to do anything you can do in stats, but paint the aggregate statistical results about the whole set back onto each of the original incoming rows. Basically whenever you have a problem that feels like you need to make "two passes" through the data, you should look at eventstats, or its streaming cousin, streamstats.

View solution in original post

sideview
SplunkTrust
SplunkTrust

Give this a shot:

<your search here> | eventstats count as globalCount avg(TotalResponse) as globalAvg | where TotalResponse > globalAvg | stats count as greaterThanAverageCount last(globalAvg) as globalAvg last(globalCount) as globalCount | eval percent = 100 * greaterThanAverageCount / globalCount | table globalAvg percent

The Eventstats command allows you to do anything you can do in stats, but paint the aggregate statistical results about the whole set back onto each of the original incoming rows. Basically whenever you have a problem that feels like you need to make "two passes" through the data, you should look at eventstats, or its streaming cousin, streamstats.

kultar
Engager

Thanks very much! That was super helpful! Plus, I learned something new!

0 Karma

sideview
SplunkTrust
SplunkTrust

Nature abhors any search language question left unanswered for more than 5 minutes!

0 Karma

sdaniels
Splunk Employee
Splunk Employee

I'm just not quick enough, thanks sideview

Get Updates on the Splunk Community!

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

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...