-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
repeated adding and deleting CustomResourceDefinitions causes duplicate metric entries #2223
Comments
/triage accepted |
I came here to open the same issue just to find it's already here. This issue simply kills the ability to use Here you can find some example manifests and steps to reproduce the issue: https://gist.github.com/bergerx/adad24dcd7cc360e1f36fbb98407b27b
And here is the output:
Prometheus compatible parsers will throw an error like this on line 8:
In the example above it's a single resource definition in the custom-resource-state-config file, but the same issue also happens if the same metric name is somehow used for different GVKs, which I believe is also a valid scenario. e.g. we used to have this item under the - groupVersionKind:
group: our.internal.group # we have a copy of this whole thing for each internal group
kind: "*"
version: "*"
labelsFromPath:
name: [metadata, name]
namespace: [metadata, namespace]
metricNamePrefix: "cr"
metrics:
- name: status
each:
type: Gauge
gauge:
path: [status, conditions]
labelsFromPath:
type: [type]
valueFrom: [status] |
#1810 seems to be a related issue. |
I can reproduce this issue (metric values are not put together for one same metric) using #2223 (comment).
QQ: I think the issue is that KSM doesn't put same metric value together. Is it correct? cc @bergerx @k15r |
I think the issue is here https://github.com/kubernetes/kube-state-metrics/blob/main/internal/store/builder.go#L210
|
@CatherineF-dev Thanks for taking care of this issue.
In my opinion there are multiple issues shown in your output:
it must look like this as "Only one TYPE line may exist for a given metric name"
Here it displays 392 AND 391 for the same metric with exactly the same values. It is not clear which one to use. For clients trying to parse this TEF there is no way to identify the correct value. |
guys, could you please update with ETA (if any) for this bug? |
Hi @k15r, could you provide detailed steps to reproduce this issue? The first issue I want to fix is this:
|
Could you try #2257 to see whether |
I was just trying this feature on With a config such as:
Each of my
I would have expected those to be aggregated into a single gauge metric for each state? |
Hi, i have this problem configuring
I use a grep with a PortForward to kube-state-metric to find what is the duplicated metric, after some time researching, identify the problem are when apply upgrades to CRD related to CustomResourceDefinitions that produce kube-state-metric refreshing and just add new CustomResourceDefinitions at the bottom of I see too in logs on ... ... 1 custom_resource_metrics.go:79] "Custom resource state added metrics" familyNames=...
... ... 1 custom_resource_metrics.go:79] "Custom resource state added metrics" familyNames=...
... ... 1 custom_resource_metrics.go:79] "Custom resource state added metrics" familyNames=...
... ... 1 custom_resource_metrics.go:79] "Custom resource state added metrics" familyNames=...
... ... 1 custom_resource_metrics.go:79] "Custom resource state added metrics" familyNames=... after that i just manually restart the deployment of |
What happened:
This is part of our kubestate customresource configuration:
after adding and deleting the corresponding CRD and on CR its kind this is a part of the
/metrics
response of kubestatemetrics:as you can see, there are multiple entries for the same metric (#HELP, and #TYPE is mentioned 3 times. Within a single metric block lines are duplicated .
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
For an advanced version of this bug create the following configuration in the cluster:
This configuration puts the metrics of two different CRs into the same metric (
kube_customresource_module_status
)Now if you create both CRDs and a matching CR and repeatedly create and remove one of the CRDs you will get output similar to this (here the sample-CRD was deleted):
Environment:
kubectl version
): v1.26.7The text was updated successfully, but these errors were encountered: