Splunk Search

get max figure for latest time in data

mcaulsc
Path Finder

Hi,

I have data as below sample:

Date Time val1 val2 val3 ......
21/08/31 01:00:00 2 1 2 2 2 2 2 1 1 2 69 1 0 2 0 0 3 3
21/08/31 02:00:00 1 1 0 1 1 1 0 0 0 0 0 0 0 1 0 1 1 0
21/08/31 03:00:00 2 1 1 2 2 2 0 1 0 2 1 0 0 2 0 1 2 2
21/08/31 04:00:00 1 1 1 1 1 1 67 0 1 150 205 0 169 312 0 0 2 2
21/08/31 05:00:00 1 0 1 1 1 1 0 0 0 70 1 2 0 1 1 1 2 58

I can calculate the max value for a specific date and time and show as a single value panel on a dashboard. What I'd like to do it find the max value for the latest time reported in the data for a date.

index=my_index sourcetype=my:sourcetype Date="21/08/31" Time="03:00:00"| eval max_val = max(val1, val2, val3, val4 ....) |stats max(max_val) as mymax

So in the sample where latest Time is "05:00:00" is there a way I can code that rather than hard specify the value?

thanks in advance for any thoughts

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| eval _time=strptime(Date." ".Time, "%d/%m/%y %H:%M:%S")
| sort - _time
| head 1

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| eval _time=strptime(Date." ".Time, "%d/%m/%y %H:%M:%S")
| sort - _time
| head 1

mcaulsc
Path Finder

Thanks, that did it, updated query below for completeness.

eval _time=strptime(Date." ".Time, "%d/%m/%y %H:%M:%S")
| sort - _time
| head 1 |fieldsummary |sort - max | head 1 |rename field as engine| fields max engine

So for the latest time on a given date, normally today and last record loaded, it will report the max value. Thanks for the assistance.

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!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...