Splunk Search

Can earliest/latest function be used over my own timestamp field?

codewarrior
Loves-to-Learn Everything

Hi folks, my dataset looks like this:

timestampiduserMailreason
t1id1a@example.comtest
t2id1a@example.comtest
t3id1a@example.com test
t2id2b@example.comtesttest
t4id2b@example.comttt

 

I want to group by id and userMail, then find the last (latest) record in each group. From the help document on latest/earliest function, it uses metadata field _time to find the latest row, how can I let latest function to use timestamp field in my case? 
I know I can use something like eval _time = timestamp to overwrite the _time field, but want to know if there are better ways to achieve.

My second question is how to write the query, can i do in this way:

| eval _time=timestamp/pow(10,3)
| chart latest(*) by id, userEmail

Thanks!

Labels (1)
Tags (2)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

@codewarrior wrote:

My second question is how to write the query, can i do in this way:

| eval _time=timestamp/pow(10,3)
| chart latest(*) by id, userEmail


Also yes.  As soon as you redefine _time, it behaves as the original _time. (In some use cases, you want to first rename the original in order to save its value.  But for the stats that you are using it with, that is not necessary.)

0 Karma

isoutamo
SplunkTrust
SplunkTrust
If needed you could add new field (or convert timestamp) for epoch time (time in seconds). Then just look min/max from this values and then add values(timestamp) as timestamp your query or convert that min/max value back to displayable format.
r. Ismo
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Yes, you can.  If you want to use search command, rename your timestamp _time; else you will need to do calculations in where command.

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Synthetic Monitoring - Resolved Incident on Detector Alerts

We’ve discovered a bug that affected the auto-clear of Synthetic Detectors in the Splunk Synthetic Monitoring ...

Video | Tom’s Smartness Journey Continues

Remember Splunk Community member Tom Kopchak? If you caught the first episode of our Smartness interview ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud? Learn how unique features like ...