Splunk Search

How can I use the "where" function to find where the output will be only the last 24hrs of the results?

GHOST27
Engager

Ex: | where first_seen<"24h" or where first_seen="-1d" this is what I used but obviously it's wrong.

Tags (1)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

You would need to make use of relative_time function in there.

If first_seen is in epoch format, then try like this

..| where first_seen>=relative_time(now(),"-24h")

If it's not in epoch, need to convert it to epoch to compare

..| where strptime(first_seen,"<<TimeFormatHere>>") >=relative_time(now(),"-24h")

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

You would need to make use of relative_time function in there.

If first_seen is in epoch format, then try like this

..| where first_seen>=relative_time(now(),"-24h")

If it's not in epoch, need to convert it to epoch to compare

..| where strptime(first_seen,"<<TimeFormatHere>>") >=relative_time(now(),"-24h")

GHOST27
Engager

Your are the man with the juice!!!

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...