Splunk Search

How to display average in month based count?

btcs2
Engager

| chart count over date_month by seriesName  , I have a search that display counts over month by seriesname . but instead of this count i need to display average of the count over month by series name .. 

 

date_month seriesName 1 seriesName 2 seriesName 3

 
1 march % % %
2 feb % % %
Labels (6)
Tags (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

OK so you don't want the average, you want the percentage of the total for the month that each series has?

| bucket span=1mon _time 
| stats count by _time seriesName
| eval date_month=strftime(_time,"%b")
| eventstats sum(count) as total by date_month
| eval percentage=round(100*count/total,2)."%"
| xyseries date_month seriesName percentage

View solution in original post

0 Karma

somesoni2
Revered Legend

If you want to display daily average during that month, try something like this

Your base search
| bucket span=1d _time 
| stats count by _time seriesName
| eval date_month=strftime(_time,"%b")
| chart avg(count) over date_month by seriesName
0 Karma

btcs2
Engager

Not working as expected . its just give count ,not giving average

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The example given by @somesoni2 does seem to do what you seem to have asked for.

If it is not working for you, please can you share the search you are actually using, so we can try to see why?

0 Karma

btcs2
Engager

Yes that query works but that's not what i was looking for .. may be my requirement is not clear 

The average should be in such a way that  (row wise) like in the month of match 15 percentage of event is series 1 and 35 percentage is series 2 and 50 percentage is series 3 . series is nothing but events like offer created or something.  i can show example ..

Find average to the total events in that month to each event(occurrence percentage of each events compare to total events for each month)

 

date_monthseries1series2series3
March15%35%50%
February16%36%48%

 

base query | chart count over date_month by seriesName  this is the query  that we use now . it gives count in expected way ..

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

OK so you don't want the average, you want the percentage of the total for the month that each series has?

| bucket span=1mon _time 
| stats count by _time seriesName
| eval date_month=strftime(_time,"%b")
| eventstats sum(count) as total by date_month
| eval percentage=round(100*count/total,2)."%"
| xyseries date_month seriesName percentage
0 Karma

btcs2
Engager

Thank you so much .. !!  its working  as expected . need to learn all these 🙂 

0 Karma
Get Updates on the Splunk Community!

Exporting Splunk Apps

Join us on Monday, October 21 at 11 am PT | 2 pm ET!With the app export functionality, app developers and ...

[Coming Soon] Splunk Observability Cloud - Enhanced navigation with a modern look and ...

We are excited to introduce our enhanced UI that brings together AppDynamics and Splunk Observability. This is ...

Splunk Smartness with Patrick Tatro | Episode 4

Welcome to another episode of "Splunk Smartness," where we explore how Splunk Education can revolutionize your ...