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

Gather `ownerReferences` for all object types #1993

Open bartebor opened 1 year ago

bartebor commented 1 year ago

What would you like to be added: As far as I see a metrics like kube_pod_owner is created for very few object types: pods, replicasets and jobs. There are more object types being owned by some other objects or controllers. We are also using a custom CRDs which own deployments and HPAs.

Why is this needed: Having owner references of all kubernetes objects would allow connecting objects together in grafana dashboards. As for now this is limited to selected objects only.

Describe the solution you'd like I would like to have owner references for all object types, including custom CRDs. This could be opt-in feature - some command line flag, maybe something similar to --resources for default object types and some field in custom resource configuration for CRDs. This way it would not break backward compatibility nor introduce new metrics for those space concerned.

logicalhan commented 1 year ago

/triage accepted /assign @dgrisonnet @rexagod

gabeduke commented 1 year ago

This would help us a great deal 👍

gabeduke commented 1 year ago

I drafted a possible solution and would like feedback before moving forward with it. I've deployed and tested with this image. @dgrisonnet @rexagod is this already being worked on? Happy to continue working on this with your guidance.

» curl -s localhost:8080/metrics | grep kube_pod_container_status_restarts_total | grep kube-state
kube_pod_container_status_restarts_total{created_by_kind="ReplicaSet",created_by_name="prom-stack-kube-state-metrics-6f9949d79f",namespace="monitoring",pod="prom-stack-kube-state-metrics-6f9949d79f-2dcm8",uid="6f7a498f-a125-4695-8670-d57ff553fa9e",container="kube-state-metrics"} 0
k8s-triage-robot commented 3 months ago

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

k8s-triage-robot commented 2 weeks ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale