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!

Developer Spotlight with Brett Adams

In our third Spotlight feature, we're excited to shine a light on Brett—a Splunk consultant, innovative ...

Index This | What can you do to make 55,555 equal 500?

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

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...