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
SplunkTrust
SplunkTrust

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!

Streamline Data Ingestion With Deployment Server Essentials

REGISTER NOW!Every day the list of sources Admins are responsible for gets bigger and bigger, often making the ...

Remediate Threats Faster and Simplify Investigations With Splunk Enterprise Security ...

REGISTER NOW!Join us for a Tech Talk around our latest release of Splunk Enterprise Security 7.2! We’ll walk ...

Introduction to Splunk AI

WATCH NOWHow are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. ...