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!

New in Observability - Improvements to Custom Metrics SLOs, Log Observer Connect & ...

The latest enhancements to the Splunk observability portfolio deliver improved SLO management accuracy, better ...

Improve Data Pipelines Using Splunk Data Management

  Register Now   This Tech Talk will explore the pipeline management offerings Edge Processor and Ingest ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

Register Join this Tech Talk to learn how unique features like Service Centric Views, Tag Spotlight, and ...