Splunk Search

Timechart results, max value for time

astatrial
Contributor

Hi all,

I am counting distinct values of destinations with timechart (span=1h).
I am trying to take those values and find the max value per hour, as follows:

Original: 
_time    dest1       dest2           dest3
06:00      3           0               1
07:00      6           2               9 
08:00      0           3               7
 ...

Result: 
_time    max 
06:00     3                 
07:00     9                
08:00     7            

*This is just an example, there are more dests and more hours.

Can anyone please assist me with this ?

Thanks!

0 Karma
1 Solution

renjith_nair
Legend

@astatrial ,

Try adding this to end of your search

|eval max=0
|foreach * [eval max=if(max < <<FIELD>>,<<FIELD>>,max)]

OR below if you do not want destination fields in your output

|untable _time,dest,count
|stats max(count) as c by _time
---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

0 Karma

renjith_nair
Legend

@astatrial ,

Try adding this to end of your search

|eval max=0
|foreach * [eval max=if(max < <<FIELD>>,<<FIELD>>,max)]

OR below if you do not want destination fields in your output

|untable _time,dest,count
|stats max(count) as c by _time
---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

astatrial
Contributor

First option didn't work, but the second option worked.

Thanks.

0 Karma

renjith_nair
Legend

@astatrial ,
First option also should work. Did you get any error message? Please note that , you have to use that search as it is. i.e. <<FIELD>> should be there as it is , dont replace it with your field names

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

astatrial
Contributor

Yes, i know. There was no error, i know it is possible to fix it to get the result but the second option did the job.

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud’s AI Assistant in Action Series: Analyzing and ...

This is the second post in our Splunk Observability Cloud’s AI Assistant in Action series, in which we look at ...

Elevate Your Organization with Splunk’s Next Platform Evolution

 Thursday, July 10, 2025  |  11AM PDT / 2PM EDT Whether you're managing complex deployments or looking to ...

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...