Splunk Search

Dividing Results To Get Average

henryt1
Path Finder

So the query I'm running is retiring results of how many people created a project (year to date) and I would like to find the average weekly amount. The query looks like:

host="web01.inno-360.com" AND source="/var/log/apache2/pg_ssl_access.log" AND /projects/create | stats count by source | eventstats avg(count) as Average by week

However when I add the 'by week' to the end of it, it doesn't generate any results but at least when I take it off it will give me the average of each of the results that are listed, but like I said I need the average per week. Any ideas?

Tags (3)
0 Karma
1 Solution

Stephen_Sorkin
Splunk Employee
Splunk Employee

You wouldn't calculate average per week, you'd calculate exact number per week (we use the advanced search language to first snap to the beginning of the year then the beginning of the week at the beginning of the year):

host="web01.inno-360.com" AND source="/var/log/apache2/pg_ssl_access.log" AND /projects/create earliest=@y@w | timechart span=1w count as "Projects Created"

If you want the average over all weeks, you can do:

host="web01.inno-360.com" AND source="/var/log/apache2/pg_ssl_access.log" AND /projects/create earliest=@y@w | timechart span=1w count as "Projects Created" | eventstats avg("Projects Created") as "Average Projects per Week"

View solution in original post

Stephen_Sorkin
Splunk Employee
Splunk Employee

You wouldn't calculate average per week, you'd calculate exact number per week (we use the advanced search language to first snap to the beginning of the year then the beginning of the week at the beginning of the year):

host="web01.inno-360.com" AND source="/var/log/apache2/pg_ssl_access.log" AND /projects/create earliest=@y@w | timechart span=1w count as "Projects Created"

If you want the average over all weeks, you can do:

host="web01.inno-360.com" AND source="/var/log/apache2/pg_ssl_access.log" AND /projects/create earliest=@y@w | timechart span=1w count as "Projects Created" | eventstats avg("Projects Created") as "Average Projects per Week"

henryt1
Path Finder

That's exactly what I needed! Thank you so much!

0 Karma

henryt1
Path Finder

I didn't know, that was just an idea I had. What value would work to give me the average per week?

0 Karma

Ayn
Legend

Where do you get the "week" value from? There is no such value by default at least.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...