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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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