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.36k stars 2k forks source link

Introduce new job metric `kube_job_status_suspend` #2511

Open ThusharaSampath opened 1 week ago

ThusharaSampath commented 1 week ago

What would you like to be added:

As of now kube job metrics have kube_job_status_failed, kube_job_status_succeeded, kube_job_status_active to track status of a job. With https://kubernetes.io/docs/concepts/workloads/controllers/job/#suspending-a-job jobs can be suspended. So having a status metric to track suspended jobs would be valuable.

Following are status parts of a suspended job

status:
  conditions:
  - lastProbeTime: "2024-09-26T11:25:42Z"
    lastTransitionTime: "2024-09-26T11:25:42Z"
    message: Job suspended
    reason: JobSuspended
    status: "True"
    type: Suspended

Why is this needed:

As of now there is no way to monitor suspended jobs via kube-state-metrics (via prometheus)

Describe the solution you'd like

Implement new metric similar other jobs status metrics for suspended status

Additional context

https://kubernetes.io/blog/2021/04/12/introducing-suspended-jobs/

https://github.com/kubernetes/kube-state-metrics/blob/7995d5fd23bcff7ae24ab6849f7c393d262fb025/docs/metrics/workload/job-metrics.md

dgrisonnet commented 12 hours ago

/triage accepted /help

k8s-ci-robot commented 12 hours ago

@dgrisonnet: This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed by commenting with the /remove-help command.

In response to [this](https://github.com/kubernetes/kube-state-metrics/issues/2511): >/triage accepted >/help Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.