Splunk Search

Any use cases on time commands in splunk SPL....?

prakash007
Builder

Can anyone explain the time commands in Splunk with a use case? I see few of these searches in Splunk Answers, but I understood only bits and pieces of them when used in searches...

_time
time()
now()
relative_time()
info_min_time()
info_max_time()
strptime()
strftime()
Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

You've mixed functions and fields.

_time is a field that says when an event happened.
info_min_time and info_max_time are fields added by the addinfo command. These fields are the lower and upper bounds of the search. They can be used to define the time period of a report, for instance.

The now() and time() functions both return the current time of day. time() includes microseconds whereas now() is the time in seconds. Both can be used in calculations to determine how old an event is.
The strptime() function converts a timestamp string ("2016-06-05", for example) into epoch (integer) form. This is the only way to do calculations with times.
The strftime() function is the inverse of strptime(). It converts a timestamp from epoch form into a human-readable string.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

You've mixed functions and fields.

_time is a field that says when an event happened.
info_min_time and info_max_time are fields added by the addinfo command. These fields are the lower and upper bounds of the search. They can be used to define the time period of a report, for instance.

The now() and time() functions both return the current time of day. time() includes microseconds whereas now() is the time in seconds. Both can be used in calculations to determine how old an event is.
The strptime() function converts a timestamp string ("2016-06-05", for example) into epoch (integer) form. This is the only way to do calculations with times.
The strftime() function is the inverse of strptime(). It converts a timestamp from epoch form into a human-readable string.

---
If this reply helps you, Karma would be appreciated.
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 ...