Splunk Search

How do I calculate the average over time when the count keeps changes every month?

k_harini
Communicator

I have to calculate average tickets over time for developer.

Since time is not _time and different time column, I did not use time chart

basesearch|eval Due_Time = strptime('Due By',"%d.%m.%Y") |bin Due_Time span=1mon |chart count over Due_Time by "Developer" usenull="f" useother="f"|eval Due_Time = strftime(Due_Time,"%b.%Y")|addtotals

Till here it's fine. But i want to calculate average over time. How do i capture count so that i can do total/count and arrive at average? The count keeps changing every month, I should not consider if the count is 0. eventstats avg(total) is not working here either.

can someone please help?

0 Karma
1 Solution

sundareshr
Legend

Try this

basesearch
|eval Due_Time = strptime('Due By',"%d.%m.%Y") 
| bin Due_Time span=1mon 
| chart count over Due_Time by "Developer" usenull="f" limit=0
| untable Due_Time Developer Counts
| eventstats avg(Counts) as Average by Due_Time
| eval Due_Time=Due_Time."#".Average
| chart values(Counts) as counts over Due_Time by Developer
| rex field="Due_Time" "(?<Due_Time>[^#]+)#(?<Average>.*)" 
| eval Due_Time = strftime(Due_Time,"%b.%Y")

View solution in original post

0 Karma

woodcock
Esteemed Legend

Just override _time, like this:

basesearch
| eval _time = strptime('Due By',"%d.%m.%Y")
| timechart span=1mon count by "Developer" usenull="f" useother="f"

k_harini
Communicator

Thanks a lot. I dint know this can be overridden.. This will help me with my other cases as well.

0 Karma

sundareshr
Legend

Try this

basesearch
|eval Due_Time = strptime('Due By',"%d.%m.%Y") 
| bin Due_Time span=1mon 
| chart count over Due_Time by "Developer" usenull="f" limit=0
| untable Due_Time Developer Counts
| eventstats avg(Counts) as Average by Due_Time
| eval Due_Time=Due_Time."#".Average
| chart values(Counts) as counts over Due_Time by Developer
| rex field="Due_Time" "(?<Due_Time>[^#]+)#(?<Average>.*)" 
| eval Due_Time = strftime(Due_Time,"%b.%Y")
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!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...