Splunk Search

Getting daily count and overall average

Sam2
Explorer

Hello all,

I'm trying to get the stats of the count of events per day, but also the average.

...| stats count by date_mday is fine for getting the count per day

and

...| stats count by date_mday | stats avg(count) gets the overall daily average

However, I'd like to combine those two into a single table, with one column being the daily total, and the second column being the overall average (which will of course be the same value every day).

I think I'm just struggling with the syntax...can anyone help please?????

Tags (2)
1 Solution

tom_frotscher
Builder

I think you can use eventstats for this:

| stats count by date_mday | eventstats avg(count)

View solution in original post

tom_frotscher
Builder

I think you can use eventstats for this:

| stats count by date_mday | eventstats avg(count)

prakash007
Builder

index=main host=wrs* domain=zzz* | stats count as daycount by date_mday | eventstats avg(daycount)

when i use run the above command for past 7days...i see different values for daycount which is expected, but i'm getting same values for avg(daycount) for all 7 days....can you explain me how it works...??

0 Karma

jwalzerpitt
Influencer

If want to see a moving average try using | streamstats avg(daycount)

Breakdown of eventstats vs. streamstats that may help clear up what each one does
http://blogs.splunk.com/2014/04/01/search-command-stats-eventstats-and-streamstats-2/

0 Karma

Taruchit
Contributor

Hello Sir,

I am trying to fetch count of errors in application logs on daily basis and average count of errors in past 7 days.

I tried using the following: -

index=** <Search condition> |stats count by error |streamstats avg(count)

I get three columns: error, count, avg(count). I am able to follow the results obtained in first two columns, but unable to understand how the values are getting calculated and displayed for avg(count). Thus, need your help to comprehend the same.

Thank you

0 Karma

khubyarb
Path Finder

Thanks for the streamstats tip

0 Karma

kenvanderheyden
Path Finder

Exactly what i was looking for. Thanks

0 Karma

Sam2
Explorer

Yes, easy when you know the command!

Thanks.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...

Network to App: Observability Unlocked [May & June Series]

In today’s digital landscape, your environment is no longer confined to the data center. It spans complex ...