Splunk Search

How to write a look back query with epoch time?

kiersti
Engager

I have the start of a query but I can't get it to limit a look up by time. I need to use the converted field sent_time as the timestamp to base the look back on. Any suggestions as to what I can do to improve this query? I tried to subtract 3 months worth of seconds from the epoch time number, not sure if that logic is appropriate.

sourcetype="log_file" | eval sent_date=strptime(mail_date,"%d %b %Y") |  sent_date>(sent_date-7948797) | dedup mail_date | table name, id, mail_date, sent_date | sort sent_date
Tags (3)
0 Karma

lguinn2
Legend

sourcetype = log_file | eval sent_date = strptime (mail_date, "%d %b %Y" ) |
where sent_date >= relative_time(_time, -30d)

Try this!

Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...