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!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...