Splunk Search

How to eval time from timepicker and use it in search?

kimberlytrayson
Path Finder

I need to eval time in hours between now and earliest time from timepicker to use it in search.
e.g. if timepicker set to “last 24 hours” - evaluated time should be 24h, for “last 2 days” - 48h, etc. Thank you!

Tags (1)
0 Karma

woodcock
Esteemed Legend

Like this:

... | addinfo | eval hours_between_now_and_earliest = round(((now() - info_min_time) / 60 / 60), 2) | fields - info_*
0 Karma

kimberlytrayson
Path Finder

Thanks! Can you explain what this part is doing "| fields - info_*"?

0 Karma

woodcock
Esteemed Legend

There was a typo; I was using earliest when I should have been using info_min_time. I edited my answer and fixed it.

0 Karma

woodcock
Esteemed Legend

It is getting rid of the info_* fields that were added by the call to addinfo.

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@kimberlytrayson

You can try addinfo command.

info_min_time = The earliest time boundary for the search.
info_max_time = The latest time boundary for the search.

http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/addinfo

0 Karma

kimberlytrayson
Path Finder

Sorry, it will be epoch time, right?

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...