Splunk Search

File Latest and Oldest

akankshayadav
Path Finder

I have a file which I uploaded once (say 1 year ago), i uploaded it again (say 6 months ago) with some changes, and then I uploaded the same file again recently with some changes . But I want to display only the latest file and the latest-1 version of the file. i.e... if I upload a file for n- time, i only want to compare the nth and (n-1)th files, and grab the event(s) which if different in them. Can any one help? 

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @akankshayadav ,

if each upload was done in the same day, you could run something like this:

index=your_index [ | metasearch 
     index=your_index earliest=0
     | bin span=1d _time
     | dedup _time
     | sort -_time
     | head 2
     | stats earliest(_time) AS earliest latest(_time) AS latest
     | eval latest=latest+86400
     | fields earliest latest
     ]
| ...

In this way you'll have only events of the last two uploads.

Ciao.

Giuseppe

0 Karma

akankshayadav
Path Finder

each upload was on different day, say for example.. 1st upload 2020, 2nd upload 1 month ago and 3rd today.Any help?

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @akankshayadav,

in this case, my solution should run, please try it.

Ciao.

Giuseppe

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...