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!

Improve Your Security Posture

Watch NowImprove Your Security PostureCustomers are at the center of everything we do at Splunk and security ...

Maximize the Value from Microsoft Defender with Splunk

 Watch NowJoin Splunk and Sens Consulting for this Security Edition Tech TalkWho should attend:  Security ...

This Week's Community Digest - Splunk Community Happenings [6.27.22]

Get the latest news and updates from the Splunk Community here! News From Splunk Answers ✍️ Splunk Answers is ...