Splunk Search

Can we pull system time in 'If' Condition

amithhegde
New Member

I have an alert created where I need to display current system time. There is an If condition in alert which looks something like below.

eval checkstatus=if(isnull(status), "Program has not started at @Current System Time@", "OK")

@Current System Time@ is where i want to have my system time displayed.

Is there a way this can be achieved?

Tags (1)
0 Karma

Ayn
Legend

now() should be what you're looking for I think?

eval checkstatus=if(isnull(status), "Program has not started at " . now(), "OK")

This gives you the epoch value which might not be what you want, for something more humanly readable you could do

eval checkstatus=if(isnull(status), "Program has not started at " . strftime(now(),"%+"), "OK")
0 Karma

martin_mueller
SplunkTrust
SplunkTrust

You can do this:

eval checkstatus=if(isnull(status), "Program has not started at ".strftime(now(), "%F %T"), "OK")
0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...