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
Revered Legend

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
Revered Legend

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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...