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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

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 GA in US-AWS!

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