kubernetes / kube-state-metrics

Add-on agent to generate and expose cluster-level metrics.
https://kubernetes.io/docs/concepts/cluster-administration/kube-state-metrics/
Apache License 2.0
5.2k stars 1.92k forks source link

kube_cronjob_status_active doesn't tell if a cronjob is running #2429

Open koote opened 1 week ago

koote commented 1 week ago

What happened: I am using kube_cronjob_status_active to monitor my cronjob, it runs every 5 minutes. In the given time window, kube_cronjob_status_active{cronjob=my-job} shows that there is no active cronjob running:

3Kdf3orl

However if I check kube_job_status_start_time{job_name=my-job*} (my-job is a cronjob, every job instance has name like my-job-12345678) within same time window, it shows that there are jobs scheduled to run approximately every 5 minutes:

pz1gP0xf

What you expected to happen: I would like to see that the kube_cronjob_status_active matches kube_job_status_start_time.

How to reproduce it (as minimally and precisely as possible): It is running in our internal k8s cluster so I don't know how to let others repo it, but I am happy to provide as much information as needed.

# An example: https://github.com/kubernetes/kube-state-metrics/issues/2223#issuecomment-1792850276
minikube start
...
go run main.go --custom-resource-state-only --custom-resource-state-config-file ksm-2223/custom-resource-config-file.yaml --kubeconfig ~/.kube/config

Anything else we need to know?:

Environment: AWS EKS

dgrisonnet commented 1 day ago

/assign @rexagod /triage accepted