-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
KSM 2.8.0 can't be scraped by Prometheus if Native Histograms is enabled #2022
Comments
This issue is currently awaiting triage. If kube-state-metrics contributors determine this is a relevant issue, they will accept it by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
I could reproduce this issue.
After open localhost:9090, can see
(It's a little weird that I can't find this error from pod logs. And I need to open localhost:9090) |
By default Prometheus doesn't log out scraping errors, if you change the helm command to turn on debug logging
You can see the errors in the container logs
(Updated my original comment to include turning on the debug logging) |
Currently, kube-state-metrics is using contentType="application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=delimited" I agree with
|
fyi: fix is #2024 |
What happened:
Starting from version 2.8.0, if Prometheus is started with
--enable-feature=native-histograms
flag it fails to scrape KSM, instead erroring with the error:What you expected to happen:
KSM should be able to be scraped by Prometheus
How to reproduce it (as minimally and precisely as possible):
I can reproduce this just on minikube with the standard helm prometheus, chart https://github.com/prometheus-community/helm-charts/tree/main/charts/prometheus
This deploys kube-state-metrics version:
registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.8.0
And Prometheus version:
quay.io/prometheus/prometheus:v2.41.0
With the
--enable-feature=native-histograms
set.Anything else we need to know?:
The problem was introduced in this PR #1974
I think the issue, is that when you enable Native Histograms, Prometheus is sending headers with a content type of:
Which we're then mirroring in our headers:
But we're not actually changing our response so we're replying with invalid protobuf hence the error from Prometheus.
I did this as a simple workaround and it fixed the issue:
However I'm not sure this is the right approach, is it intended that kube-state-metrics always responds with content headers that match the request? Or was this just a change for Open Metrics? In which case perhaps the header should only get changed if the
contentType == expfmt.FmtOpenMetric
? e.g reverse the logic, only change the headers if we detect open metrics headers:That way the code would behave the same as it did prior to 2.8.0 if the open metrics headers are not present.
Environment:
kubectl version
): 1.26.1The text was updated successfully, but these errors were encountered: