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_job_failed` should have `reason` label #2382

Closed keisku closed 1 month ago

keisku commented 2 months ago

What would you like to be added:

Add reason label here other than condition.

https://github.com/kubernetes/kube-state-metrics/blob/9e6e70d328c5d750a0df84cc044c38124b271538/internal/store/job.go#L292-L316

Why is this needed:

Enable to monitor why a job fails.

Describe the solution you'd like

--                  metric.LabelKeys = []string{"condition"}
++                  metric.LabelKeys = []string{"condition", "reason"}

Additional context

I would like to know why the current implementation doesn't allow adding reason label. Any concerns?

ricardoapl commented 1 month ago

I would like to know why the current implementation doesn't allow adding reason label. Any concerns?

I don't know, but wouldn't using kube_job_status_failed instead of kube_job_failed solve your issue?

logicalhan commented 1 month ago

/triage accepted /assign @CatherineF-dev

CatherineF-dev commented 1 month ago

Yes, kube_job_status_failed has reason. https://github.com/kubernetes/kube-state-metrics/blob/9e6e70d328c5d750a0df84cc044c38124b271538/internal/store/job_test.go#L207

CatherineF-dev commented 1 month ago

/close

k8s-ci-robot commented 1 month ago

@CatherineF-dev: Closing this issue.

In response to [this](https://github.com/kubernetes/kube-state-metrics/issues/2382#issuecomment-2091056243): >/close 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/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.