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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...