Splunk Search

How to i match the latest date value in lookup file?

hvdtol
Path Finder

Hi,

I am a newbie to SPL and would like some help.
I want to find the latest date field in my lookup file file.

My test.csv file look like this

name,size,datum
AA,11,12-09-2020
AA,18,14-09-2020
AB,33,15-04-2020
AB,34,16-04-2020
AB,35,15-06-2020
AC,23,14-05-2020
AC,14,08-07-2020

If i want to find the maximum value of column "size"  i succeed
 
|inputlookup test.csv
| eval foo=[ |inputlookup test.csv |stats max(size) as dtx | return $dtx ]
| table foo

Result:
35
35
..

But when i try this with the date value i get this

|inputlookup tabs.csv
| eval foo=[ |inputlookup tabs.csv |stats max(datum) as dtx | return $dtx ]
| table foo

i get

-2008
-2008
..

How to i match the latest date value ?

Thank you in advance.

Reagrds,

Harry

Labels (2)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @hvdtol,

you have to convert the date in epochtime and then sort, something like this:

| inputlookup test.csv
| eval epoch_datum=strptime(datum,"%d-%m-Y")
| sort -epoch_datum
| head 1
| table name size datum

Ciao.

Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @hvdtol,

you have to convert the date in epochtime and then sort, something like this:

| inputlookup test.csv
| eval epoch_datum=strptime(datum,"%d-%m-Y")
| sort -epoch_datum
| head 1
| table name size datum

Ciao.

Giuseppe

0 Karma

hvdtol
Path Finder

Oh yes of course.
This was helpfull.

Thank you,Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @hvdtol,

good for you.

Ciao and happy splunking.

Giuseppe

P.S.: Karma Points are appreciated 😉

hvdtol
Path Finder

thanks

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...