Open dmitriishaburov opened 1 month ago
This issue is currently awaiting triage.
If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the triage/accepted
label and provide further guidance.
The triage/accepted
label can be added by org members by writing /triage accepted
in a comment.
The main issue is that you don't get a specific metric for each ContainerResources trigger when using multiple (assuming the same resource name and target type). It generates the same metric with the same label values. e.g:
metrics:
- type: ContainerResource
containerResource:
name: cpu
container: main
target:
type: Utilization
averageUtilization: 40
- type: ContainerResource
containerResource:
name: cpu
container: istio-proxy
target:
type: Utilization
averageUtilization: 90
you get all target_metric
specific metrics duplicated, making it impossible to identify which one applies to each. Also when Prometheus scrapes these, only take one of each, losing information.
kube_horizontalpodautoscaler_spec_target_metric{namespace="prod",horizontalpodautoscaler="sample",metric_name="cpu",metric_target_type="utilization"} 40
kube_horizontalpodautoscaler_spec_target_metric{namespace="prod",horizontalpodautoscaler="sample",metric_name="cpu",metric_target_type="utilization"} 90
kube_horizontalpodautoscaler_status_target_metric{namespace="prod",horizontalpodautoscaler="sample",metric_name="cpu",metric_target_type="average"} 1.442
kube_horizontalpodautoscaler_status_target_metric{namespace="prod",horizontalpodautoscaler="sample",metric_name="cpu",metric_target_type="utilization"} 24
kube_horizontalpodautoscaler_status_target_metric{namespace="prod",horizontalpodautoscaler="sample",metric_name="cpu",metric_target_type="average"} 0.836
kube_horizontalpodautoscaler_status_target_metric{namespace="prod",horizontalpodautoscaler="sample",metric_name="cpu",metric_target_type="utilization"} 69
As @dmitriishaburov suggested, one option would be to have a container label. However, we need to consider what value it would have when using type=Resource
. Additionally, with this option, there is a chance that a container name could collide with that specific value. We could also add a type
label to solve this, with values resource
and container_resource
.
Another option would be to have separate metrics for type=Resources
and type=ContainerResources
. The problem I see with this approach is that it splits the information about the same concept into 2 different metrics, also making building charts more complicated because you will have to duplicate the queries to consider both types in every scenario
What happened:
Duplicate
kube_horizontalpodautoscaler_spec_target_metric
causing issues with Prometheus 2.52.0+ Due to new duplicates detection mechanism, I'm seeing following errors in Prometheus:After checking kube-state metrics I've found that metrics for HPA are duplicated:
HPA itself have 3 separate entries for CPU, but there's different on container:
What you expected to happen: kube-state-metrics not producing duplicate metrics, probably by adding container label (?)
How to reproduce it (as minimally and precisely as possible):
Environment:
kubectl version
): v1.28.9-eks-036c24b