Splunk Search

Search with a dynamic time window to find the most recent set of specific events.

JWBailey
Communicator

I have splunk monitoring a location that receives uploaded files. The file is uploaded once a day, at unknown times.

Is it possible to write a search such that it will use only the most recent uploaded set of data? I could write it to use “yesterday” as the time window, but if today’s data has already been uploaded I would like to use it. I also need to be aware that it is possible to upload a file at 11:55PM and again at 12:05 AM, I need to make sure my search doesn’t include both of these data sets.

Thanks for the assistance.

0 Karma

woodcock
Esteemed Legend

Try this (search with a timepicker value that is long enough to always include the oldest possible set of data that might also be the newest):

... | stats (first)source AS newest | where source=newest

0 Karma

JWBailey
Communicator

I don't see how this works. Once I use the stats command, don't I lose all the other fields that contain the data I am using to generate my results?

0 Karma

woodcock
Esteemed Legend

Yes, I meant this:

... | stats (first)source AS newest | map search="source=$newest$"

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – November 2025

  Welcome to the inaugural edition of Data Management Digest! As your trusted partner in data innovation, the ...

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...