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
Builder

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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...