Splunk Search

How to extract the earliest and latest dates for a certain time range to filter the values of a lookup containing a list of dates?

gcusello
SplunkTrust
SplunkTrust

I need to extract the first and the last dates of a period to use to filter the values of a lookup table containing a list of dates.

I have to do this because, in addition to the Timestamp, I also have to search events by indextime and put these dates in a drop-down list, but I cannot load the list at search-time because there are too many events, so I loaded the list in a lookup (updated every night). However, in my forms, I have to correlate this list to the Time period.

I cannot use head and tail commands because I have too many events (head command is fast, but tail is very slow!)

Is it possible to extract dates from the earliest and latest values?

Thank you.

Giuseppe

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

I solved the problem in a different way: insted to use a lookup I used an index in which every event countains only a date and the timestamp is the same.
In this way I can find the values I need.

View solution in original post

gcusello
SplunkTrust
SplunkTrust

I solved the problem in a different way: insted to use a lookup I used an index in which every event countains only a date and the timestamp is the same.
In this way I can find the values I need.

sundareshr
Legend

Have you tried ..| stats max(_time) as l and min(_time) as e

0 Karma

gcusello
SplunkTrust
SplunkTrust

it doesn't work,
but the problem is that calculating max and min is everyway very slow.
The problem is that Splunk read all the events from the latest event to the earliest, so the "head 1" command is very fast, but istead the "tail 1" command is very very slow because the search starts from the latest event.
If I could start the search from the earliest event, it will be very fast.
Thank you.
Bye.
Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

maybe a way to proceed is to associate a timestamp to the lookup items, like:

| inputlookup lookuptable.csv | eval _time=strftime(strptime(Data1,"%Y/%m/%d"),"%Y-%m-%d 00.00.00")

but it doesn't work!

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...