patternkubernetesMinor
Monitoring Kubernetes CronJob & Job in Grafana for today day only
Viewed 0 times
kubernetestodaymonitoringcronjobdayforonlygrafanajob
Problem
I'm trying to create a Dashboard in Grafana that will show the status of Cronjob & Job success & fail.
Currently i'm using
I try to be creative with
How can i get only
Currently i'm using
kube_job_status_succeeded to get a status job, but the issue here PromQL also take a 3 days of job status back, but i only wanted for 1 days job status.I try to be creative with
kube_job_created but no luck.How can i get only
kube_job_status_succeeded for 1 day only ? Thank you.Solution
I had similar problem. I found no straightforward solution, bur eventually I solved it with a workaround.
The problem is that
In other words,
My workaround is based on joining data from kube_job_status_succeeded and kube_job_created. In this way, I take most recent timestamp of successful job. Then I deduct it from current timestamp. In result I get a info how long ago last successful job execution took a place.
In Grafana it looks like this:
Maybe this is not direct answer to your question, but I believe that this might be a good starting point to achieve your goal. In Grafana you can do some data mapping to present time diff calculated in the query as one big "success"/"failed" label, depending on your neads
The problem is that
kube_job_status_succeeded will always present number of rows equal to .spec.successfulJobsHistoryLimit (if some jobs in the past have succeded) with value of 1, and number of rows equal to .spec.failedJobsHistoryLimit (if some jobs in the past have failed) with value of 0. Moreover, kube_job_status_succeeded does not tell you when the job was performed.In other words,
kube_job_status_succeeded just store .spec.successfulJobsHistoryLimit (default: 3) of most recent succesful jobs and .spec.failedJobsHistoryLimit (default: 1) of most recent failed jobsMy workaround is based on joining data from kube_job_status_succeeded and kube_job_created. In this way, I take most recent timestamp of successful job. Then I deduct it from current timestamp. In result I get a info how long ago last successful job execution took a place.
time() - max(kube_job_status_succeeded{namespace="my_namespace",job_name=~"job_name.*"} * on (job_name) kube_job_created{namespace="my_namespace",job_name=~"job_name.*"})In Grafana it looks like this:
Maybe this is not direct answer to your question, but I believe that this might be a good starting point to achieve your goal. In Grafana you can do some data mapping to present time diff calculated in the query as one big "success"/"failed" label, depending on your neads
Code Snippets
time() - max(kube_job_status_succeeded{namespace="my_namespace",job_name=~"job_name.*"} * on (job_name) kube_job_created{namespace="my_namespace",job_name=~"job_name.*"})Context
StackExchange DevOps Q#14737, answer score: 1
Revisions (0)
No revisions yet.