Splunk Search

Finding the latest source file per day

Nadhiyaa
Path Finder

My script runs every 2 hrs per day .But i need the latest file per day for a timerange to do some calculation.

Tags (1)
0 Karma

FrankVl
Ultra Champion

Are you looking for the event(s) related to that latest file, or for the file(name) itself? It would help if you could elaborate a bit on what your data looks like, what the output is that you're after (and perhaps what you have tried so far).

In general, to get the latest something per day, you could do something along the lines of:

index=foo
| eval day = _time
| bin day span=1d 
| stats latest(source) by day
| convert ctime(day)

Which gets you the latest value of the source field per day, for the given index.

0 Karma

Nadhiyaa
Path Finder

it works !! Thanks

0 Karma

FrankVl
Ultra Champion

Cool 🙂

I've changed my comment to an answer, so you can mark it as accepted.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...