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!

Agentic SOC Triage: Investigating Splunk ES Notables with MCP Server and a Local LLM

The Problem: Too Many Alerts, Too Little Context Security operations teams running Splunk Enterprise Security ...

All Work and No Play? Not at .conf26! Unwind at These Evening Events

Between hands-on technical sessions, keynote reveals, and diving into live architectures, .conf26 is packed ...

Join the Hackathon at .conf26 and build a No-Code AI agent

Join us for the AI Agent Buildathon, an in-person, three-hour hands-on Hackathon where you’ll use Splunk Agent ...