Splunk Search

How to use a date field in my data to filter and only return search results within a certain time range?

danderson_splun
Splunk Employee
Splunk Employee

I have a field of lastConnected that I want to evaluate as containing a date in the last 7 days and then pipe that sub-set of results to a dedup on a different field (guid). How can I do this?

0 Karma

sundareshr
Legend

Try this

.... | eval lastWeek=relative_time(now(), "-7d@d") | where lastConnected>lastWeek | dedup guid

OR, instead of deduping on guid, you could do

.... | eval lastWeek=relative_time(now(), "-7d@d") | where lastConnected>lastWeek | stats <<count and/or other functions>> by guid

Dedup is an expensive operation and should be avoided if possible.

0 Karma
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, ...