Splunk Search

Using "earliest" and other time modifiers in ad hoc queries

mv10
Path Finder

Is it possible to put time modifiers like "earliest" into a search and essentially disregard the time range drop-down in the Splunk UI? I have data that is logged once every 24 hours, so I'd like to embed "WHERE earliest=-24h" into a rather large, complicated query so I can cut-and-paste from my notes without having to mess around with the drop-down (or more importantly, so I don't need to make additional notes to remind myself to set the drop-down).

I tried something like this:

index=iis sourcetype=xxxx host=xxxx | WHERE earliest=-24h | eval... | table...

 But the UI shows "Error in 'where' command: the operator at 'h' is invalid.

0 Karma
1 Solution

mv10
Path Finder

Bah... the "WHERE" clause is unnecessary (got that from somewhere in the docs) ... just specifying "earliest" as one of the criteria is adequate.

View solution in original post

0 Karma

mv10
Path Finder

Bah... the "WHERE" clause is unnecessary (got that from somewhere in the docs) ... just specifying "earliest" as one of the criteria is adequate.

0 Karma

isoutamo
SplunkTrust
SplunkTrust

You can use earliest, latest etc. in your base search, don't use | and where. Just 

index=iis sourcetype=xxxx host=xxxx earliest=-24h | eval... | table...

This is even more efficient way to do queries that add where or search on the right side of first pipe (|).

r. Ismo 

0 Karma

mv10
Path Finder

Thanks!

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

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...

Customer success is front and center at .conf25

Hi Splunkers, If you are not able to be at .conf25 in person, you can still learn about all the latest news ...