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!

What's New in Splunk Cloud Platform 9.2.2403?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2403! Analysts can ...

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

Dive into our sizzling summer lineup for July and August Community Office Hours and Tech Talks. Scroll down to ...

Edge Processor Scaling, Energy & Manufacturing Use Cases, and More New Articles on ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...