<p>There are several metrics collected for cron jobs, unfortunately I‘m not sure how to use them properly.</p>
<p>I wanted to use the <code>kube_job_status_failed == 1</code> metrics. I can use a regex for <code>job=~“+.myjobname.+“</code> to aggregate all failed attempts for a cron job.</p>
<p>This is where i got stuck. Is there a way to count the amount of distinct labels(=number of failed attempts) in a given time period?</p>
<p>Or can I use the metrics the other way around meaning checking whether there was <code>kube_job_status_succeeded{job=~“+.myjobname+.“}==1</code> in a given time period?</p>
<p>I feel like I’m so close to solving this but I just can’t wrap my head around it.</p>
<p>EDIT: Added Picture<a href="https://i.stack.imgur.com/TiwSw.png" rel="nofollow noreferrer">This shows that there clearly are several succeded jobs over time, I just have no clue on how to count them</a></p>

Paul7979
<p>This should give you the number of failed jobs matching the job name in 1h period:</p>
<pre><code>count_over_time(kube_job_status_failed{job=~“+.myjobname+.“}==1 [1h])
</code></pre>
