The following SPL can be used to calculate the mean deviation of all value
s.
| eventstats mean(value) as mean | eval distance=abs(mean-value) | stats avg(distance) as mean_deviation
For example, this will generate 10 random values and then calculate the mean deviation.
| makeresults count=10 | eval value=random()%10 | eventstats mean(value) as mean | eval distance=abs(mean-value) | stats avg(distance) as mean_deviation
eventstats
is used to calculate the mean all the values, and add this new field to each event. Then, eval disatnace
is used to calculate the absolute distance away each value is from the mean. The final stats
is just used to determine the average of this value.
Look here for documentation around eventstats
https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/Eventstats , and a good blog post around the differences between stats
, eventstats
and streamstats
can be found at https://www.splunk.com/en_us/blog/tips-and-tricks/search-command-stats-eventstats-and-streamstats-2.html