Splunk Search

How to get only latest try of a job?

splunkuser320
Path Finder

I need to show only the results of the job. Job try multiple times in case of failure. So if the job passed on 3rd attempt then I do not want to include it in the failed job counter.

Sample logs

{"id":"1", "status": "Failed","retry":"1"}

{"id":"1", "status": "Failed","retry":"2"}

{"id":"1", "status": "Failed","retry":"4"}

{"id":"1", "status": "Failed","retry":"5"}

{"id":"2", "status": "Passed","retry":"1"}

{"id":"3", "status": "Failed","retry":"1"}

{"id":"3", "status": "Passed","retry":"1"}

In the above example counter should show value 0f 1 since only job 1 is failed in last try

Labels (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Use | dedup id to keep only the first event for each job ID.  Since Splunk processes events in reverse time order, the first event seen is the most recent one.

---
If this reply helps you, Karma would be appreciated.
0 Karma

splunkuser320
Path Finder

Thanks for the reply. I only want to show the results of the failed job, so If the last attempt is successful, I want to exclude it. 

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@splunkuser320 - Filter for the failed job before you dedup.

index=<whatever> <any-other-search-filters>
| search status="Failed" | dedup id

 

Hope this helps. Kindly accept the answer and upvote the answer if this helps!!!

0 Karma
Get Updates on the Splunk Community!

Your Guide to Splunk Digital Experience Monitoring

A flawless digital experience isn't just an advantage, it's key to customer loyalty and business success. But ...

Data Management Digest – November 2025

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

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...