Splunk Search

How to get current time and convert to epoch

jbv
Engager

Hi,

Is there a way to get current time on Splunk and then convert it to epoch? Im trying to create a dashboard to show inactivity from my data sources and plan to use info from | metadata command.

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @jbv ,

you can use the now() funtion, for more infos see at https://docs.splunk.com/Documentation/SCS/current/SearchReference/DateandTimeFunctions

You can try something like this:

| makeresults
| eval current_time=now()
| table current_time

it's in epochtime, then you can convert in the format you like.

Ciao.

Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jbv ,

you can use the now() funtion, for more infos see at https://docs.splunk.com/Documentation/SCS/current/SearchReference/DateandTimeFunctions

You can try something like this:

| makeresults
| eval current_time=now()
| table current_time

it's in epochtime, then you can convert in the format you like.

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jbv ,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma

tej57
Contributor

Hello @jbv,

You can get the current time using the now() function. By default it is returned in epoch  format only. You can use eval to call a field and you'll get what you want.

| eval current_time_epoch=now()

 

Thanks,
Tejas.

 

---

If the above solution helps, an upvote is appreciated.!! 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

There are a couple of functions to returns time, now() which returns the time the search started, and time() which returns the time the function is executed. Both of these functions already return the time in epoch format.

0 Karma
Get Updates on the Splunk Community!

Detecting Brute Force Account Takeover Fraud with Splunk

This article is the second in a three-part series exploring advanced fraud detection techniques using Splunk. ...

Buttercup Games: Further Dashboarding Techniques (Part 9)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Buttercup Games: Further Dashboarding Techniques (Part 8)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...