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

Resource relation metrics #2424

Open tiithansen opened 1 week ago

tiithansen commented 1 week ago

What would you like to be added:

It would be great if KSM had an optional set of metrics which would describe relations between resources.

For example:

Why is this needed:

This would give a possibility to query relation changes over time. Also it would allow to create smarter and more detailed alerts about changes to configuration.

Describe the solution you'd like

If the label combinations are not frequently changing it should not have a big impact on memory usage for Prometheus or any other tool that is going to scrape and persist those metrics.

kube_ingress_relation{ingress="name-of-the-ingress", service="name-of-the-service", namespace="name-of-the-namespace"} 1 kube_service_relation{service="name-of-the-service", pod="name-of-the-pod", namespace="name-of-the-namespace"} 1 kube_hpa_relation{hpa="name-of-the-hpa", deployment="name-of-the-deployment", namespace="name-of-the-namespace"} 1 Possibly using resource uids might give better insight while being less fragile.

Additional context

This idea came from trying to develop Grafana Scenes App for Kubernetes to display cluster state based on collected metrics. If we would have metrics describing relations we could easily query state & alerts for related sources and build a full picture about the current state at any given time.

dgrisonnet commented 1 day ago

/assign @rexagod /triage accepted