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!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...