Splunk Search

Why is stats avg() not putting in zeros by _time?

kdimaria
Communicator

I am trying to see the average users by day but when there are no events or users for a certain day the _time field doesn't show up or put a zero so the calculation is wrong. I am looking back the previous week so I should see Monday through Friday but I only see Monday Tuesday and Wednesday. I tried fillnull but that did not work. I want to see Thursday and Friday as 0 to calculate the avg correctly.

index=* | where isnotnull(user) | where date_wday!="saturday" AND date_wday!="sunday"| bin _time span=24h | stats dc(user) as Users  by _time| fillnull Users value=0 | stats avg(Users) as Users 
0 Karma
1 Solution

pradeepkumarg
Influencer

Use timechart instead

index=* | where isnotnull(user) | where date_wday!="saturday" AND date_wday!="sunday"| timechart span=24h dc(user) as Users

View solution in original post

0 Karma

pradeepkumarg
Influencer

Use timechart instead

index=* | where isnotnull(user) | where date_wday!="saturday" AND date_wday!="sunday"| timechart span=24h dc(user) as Users

0 Karma

kdimaria
Communicator

thank you 🙂

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...