Splunk Search

avg of number of events by day

pinzer
Path Finder

Hi all, i need to search the average number from the count by day of an event.

for example if i have 3 5 and 4 events in three different days i need the average that is 4.

the eventtype is

eventtype="searchAccountLocked"

i need also to use rangemap in my search...to control if the number of events of today is higher than the average. I'm using this search queri that doesn't work


eventtype="searchAccountLocked" | stats count as count2 | timechart span=1d count | stats avg(count) |rangemap field=count2 green=1-count2 red=count2-50000 default=gray

please help me! 🙂

Tags (2)
1 Solution

ziegfried
Influencer
eventtype="searchAccountLocked" | timechart span=1d count | stats avg(count)

or

eventtype="searchAccountLocked" | bucket span=1d _time | stats count by _time | stats avg(count)

View solution in original post

ziegfried
Influencer

You won't be able to use the rangemap command for this purpose. But you can use the eval command to do so:

eventtype="searchAccountLocked" | timechart span=1d count | stats last(count) as today_count avg(count) as avg_count | eval range=if(today_count>avg_count, "red", "green")

Documentation on the eval command: http://www.splunk.com/base/Documentation/latest/SearchReference/Eval

pinzer
Path Finder

Perfect! thanks a lot! Really good work!

0 Karma

ziegfried
Influencer
eventtype="searchAccountLocked" | timechart span=1d count | stats avg(count)

or

eventtype="searchAccountLocked" | bucket span=1d _time | stats count by _time | stats avg(count)

ziegfried
Influencer

I've added a separate answer for the solution.

0 Karma

pinzer
Path Finder

i need also to use rangemap in my search...to control if the number of events of today is higher than the average. I'm using this search queri that doesn't work

eventtype="searchAccountLocked" | stats count as count2 | timechart span=1d count | stats avg(count) |rangemap field=count2 green=1-count2 red=count2-50000 default=gray

please help me! 🙂

0 Karma

pinzer
Path Finder

thanks a lot! Good work!

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...