Splunk Search

timechart span value produces different averages for the day

nk-1
Path Finder

Case 1: earliest=-1d@d latest=-0d@d ... | timechart span=1h count as Samples, avg(duration) as avg
vs.
Case 2: earliest=-1d@d latest=-0d@d ... | timechart span=1d count as Samples, avg(duration) as avg

The value for Samples is the same in both cases (if the 24 separate Samples in Case 1 are added), but the value for avg is not (if the 24 separate averages in Case 1 are averaged).
Why is that?

0 Karma
1 Solution

cmerriman
Super Champion

If you are averaging an average (in case 2, you are taking an average of 24 averages), you will get a different value than if you average all of the original numbers together right away (case 1)
http://www.incontext.indiana.edu/2013/mar-apr/article3.asp
this link is just a quick example of some averaging of averages vs actual averages.

View solution in original post

somesoni2
Revered Legend

Count would remain same regardless of the bucketing is done. The average however depends upon the total/number of instances. Daily average will be same if the count is same for every hour for that day. Take this data sample

Hour    duration
Hour1   100
Hour1   10
Hour1   10
Hour2   10
Hour2   10
Hour2   10
Hour2   10

Now the Average for the day (when span=1d) will be (100+10+10+10+10+10+10)=160/7=22.86

Average when span1d
Hour1=100+10+10=120/3=40
Hour 2=10+10+10+10=40/4=10
Average of hourly average= 40+10/2 (number of hours)=25.

cmerriman
Super Champion

If you are averaging an average (in case 2, you are taking an average of 24 averages), you will get a different value than if you average all of the original numbers together right away (case 1)
http://www.incontext.indiana.edu/2013/mar-apr/article3.asp
this link is just a quick example of some averaging of averages vs actual averages.

Get Updates on the Splunk Community!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...