Splunk Search

How to find standard deviation of the aliase

aayushshah
Engager

I calculate the mean of the four weeks using the aliases, but how do I calculate the standard deviation of the four points as well. 

 

 

source="..." earliest=-0d@d latest=now 
| stats count as Today 
| appendcols
 [ search source="events.log"  earliest=-7d@d latest=-6d@d 
 | stats count as SameDayOneWeekAgo] 
| appendcols
 [ search source="events.log"  earliest=-14d@d latest=-13d@d 
 | stats count as SameDayTwoWeeksAgo] 
| appendcols
 [ search source="events.log" earliest=-21d@d latest=-20d@d 
 | stats count as SameDayThreeWeeksAgo] 
| appendcols
 [ search source="events.log" earliest=-28d@d latest=-27d@d 
 | stats count as SameDayFourWeeksAgo] 
| eval mean= ((SameDayOneWeekAgo + SameDayTwoWeeksAgo + SameDayThreeWeeksAgo + SameDayFourWeeksAgo)/4)

 

 

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
source="..." earliest=-0d@d latest=now 
| stats count as Today 
| append
 [ search source="events.log" earliest=-7d@d latest=-6d@d 
 | stats count] 
| append
 [ search source="events.log" earliest=-14d@d latest=-13d@d 
 | stats count] 
| append
 [ search source="events.log" earliest=-21d@d latest=-20d@d 
 | stats count] 
| append
 [ search source="events.log" earliest=-28d@d latest=-27d@d 
 | stats count] 
| stats values(Today) as Today avg(count) as average stdev(count) as standarddev

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
source="..." earliest=-0d@d latest=now 
| stats count as Today 
| append
 [ search source="events.log" earliest=-7d@d latest=-6d@d 
 | stats count] 
| append
 [ search source="events.log" earliest=-14d@d latest=-13d@d 
 | stats count] 
| append
 [ search source="events.log" earliest=-21d@d latest=-20d@d 
 | stats count] 
| append
 [ search source="events.log" earliest=-28d@d latest=-27d@d 
 | stats count] 
| stats values(Today) as Today avg(count) as average stdev(count) as standarddev
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Each append adds an event with the count for that day, whereas the count for today is renamed Today. The stats outputs the value of Today's count, and the average and standard deviation of the count fields.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You may need to wait for the events to all be read before the standard deviation is calculated

0 Karma

aayushshah
Engager

Could you explain why that works? Also I didn't want to include today's value. 

0 Karma
Get Updates on the Splunk Community!

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

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...