Splunk Search

Stats Average after timechart incorrect

aohls
Contributor

I want to get a per second average over a period of time. I am running into an issue getting an average of these values. For example one item only occurs 4 or so times and when I calculate the average I get 1; it is not considering the seconds where there are no results. I am doing the following now:

 

| bin _time span=1s |stats count as Vol by foo | stats avg(vol) by foo

 

I would expect to get a very low decimal due to all of the 0 values but, I get 1. I have attempted multiple ways of doing this but it seems that it is only doing an average of the existing values, not the times where I do not have results.

Labels (3)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

@aohls 

Your search doesn't make sense. When you bin by time, the stats command should also split by time, otherwise you are only getting a single count of events by foo in your example, so maybe this is what you need?

| timechart span=1s count by foo
| stats avg(*) as *

the timechart will give you zero values for the missing entries per second, so then the final stats will give you the average. Note you have to use the wildcard as the field names will be the values of foo after the split.

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...