Splunk Search

Last vs Max in Timestamp

lucas4394
Path Finder

I wonder what the difference between last and max in timestamp if I want to return the most recent time from a lookup. Both of them return the same result as showed below. Any comments?

| makeresults 
| eval last_seen=strptime("05/06/2019 5:43:32","%m/%d/%Y %H:%M:%S") 
| append 
    [| makeresults 
    | eval last_seen=strptime("05/06/2019 16:12:00","%m/%d/%Y %H:%M:%S")] 
| stats max(last_seen) as max_last_seen last(last_seen) as first_last_seen 
| eval max_last_seen=strftime(max_last_seen, "%m/%d/%Y %H:%M:%S"), first_last_seen=strftime(first_last_seen, "%m/%d/%Y %H:%M:%S")
Tags (1)
0 Karma
1 Solution

woodcock
Esteemed Legend

Using max(_time) is far more efficient than using latest(_time) because it does less work. One should ALWAYS use max(_time) over latest(_time).

View solution in original post

woodcock
Esteemed Legend

Using max(_time) is far more efficient than using latest(_time) because it does less work. One should ALWAYS use max(_time) over latest(_time).

woodcock
Esteemed Legend

Furthermore, if you are POSITIVE that you results will ALWAYS be sorted (keep in mind that in low-RAM situations, sometimes events are not returned fully sorted), you can use first(_time) which is the fastest and most-efficient of them all.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...