Splunk Search

find max of two averaged fields over a month of daily data

dang
Path Finder

I've got a very basic query which computes an average of some daily attempts to do something like this:

index=monitoring | timechart span=1d sum(done) as Success sum(try) as Attempt | eval Percent=round(Success*100/Attempt,2) | convert ctime(_time) as Date timeformat="%d %B" | fields - _time | fields Date Percent 

I'm unclear how I could find the day with the highest value of "Percent" over a month's worth of daily valules. Would I need to create a summary index to handle this?

Tags (3)
0 Karma
1 Solution

Stephen_Sorkin
Splunk Employee
Splunk Employee

You can find the single highest day by sorting by Percent, descending, and taking the first row:

index=monitoring
| timechart span=1d sum(done) as Success sum(try) as Attempt
| eval Percent=round(Success*100/Attempt,2)
| convert ctime(_time) as Date timeformat="%d %B"
| fields - _time
| fields Date Percent
| sort - Percent
| head 1

Alternately you can tag the highest row using eventstats and eval:

index=monitoring
| timechart span=1d sum(done) as Success sum(try) as Attempt
| eval Percent=round(Success*100/Attempt,2)
| convert ctime(_time) as Date timeformat="%d %B"
| fields - _time
| fields Date Percent
| eventstats max(Percent) as max_Percent
| eval is_highest = if(Percent == max_Percent, "yes", "no")

View solution in original post

0 Karma

Stephen_Sorkin
Splunk Employee
Splunk Employee

You can find the single highest day by sorting by Percent, descending, and taking the first row:

index=monitoring
| timechart span=1d sum(done) as Success sum(try) as Attempt
| eval Percent=round(Success*100/Attempt,2)
| convert ctime(_time) as Date timeformat="%d %B"
| fields - _time
| fields Date Percent
| sort - Percent
| head 1

Alternately you can tag the highest row using eventstats and eval:

index=monitoring
| timechart span=1d sum(done) as Success sum(try) as Attempt
| eval Percent=round(Success*100/Attempt,2)
| convert ctime(_time) as Date timeformat="%d %B"
| fields - _time
| fields Date Percent
| eventstats max(Percent) as max_Percent
| eval is_highest = if(Percent == max_Percent, "yes", "no")
0 Karma

dang
Path Finder

Thanks, Stephen. I'll probably use the first example, but the second one will help me learn new stuff about streamstats.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...