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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...