Content-type problem #7476
-
Checklist
Describe the issueHello, This question is dedicated to the kvaster/zwavejs-prom plugins with which I have encountered an encoding problem since I upgraded my prometheus server. This new version of prometheus tells me that the content-type of the metrics returned by the plugin is not in the right format: text/html while prometheus expects text/plain (https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format). Is it possible to overload the format in the context of the plugin? Thanks Software versionsZ-Wave Controller (Stick/Dongle/...)No response Device informationNo response Checklist
Upload LogfileNo response |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
👋 Hey @soso-bc! Thanks for opening an issue! It doesn't look like you provided a logfile though. While not strictly necessary for every issue, having a driver log on loglevel debug is required to diagnose most issues. Please consider uploading a logfile that captures your problem. As a reminder, here's how to create one: |
Beta Was this translation helpful? Give feedback.
-
I think this belongs in the zwave-js-ui repository. I can move the issue tomorrow, or you close it and open a new one in the correct repo. |
Beta Was this translation helpful? Give feedback.
-
The prom-exporter plugin is an external project by a different maintainer: https://github.com/kvaster/zwavejs-prom The plugin code is responsible for setting up the async sendMetrics(req, res) {
this.registry.metrics().then((m) => res.send(m))
} Compare to the example code from the upstream prom-client project, which shows that the request handler needs to set the content type:
And where the default content type is set to static get PROMETHEUS_CONTENT_TYPE() {
return 'text/plain; version=0.0.4; charset=utf-8';
} Since the plugin code is missing the content type setting, if I had to guess |
Beta Was this translation helpful? Give feedback.
-
Just another note, the Prometheus 3 migration guide provides guidance for handling applications that don't set the right Content-Type as this was a breaking change introduced by Prometheus: https://prometheus.io/docs/prometheus/latest/migration/#scrape-protocols
Setting this for your scrape config should restore the previous behavior without having to change the plugin (though still preferred): fallback_scrape_protocol: PrometheusText0.0.4 |
Beta Was this translation helpful? Give feedback.
-
Hello @AlCalzone @kpine, Thank you for your feedback and sorry for the late response but I am in a Paris time zone... Thank you both! |
Beta Was this translation helpful? Give feedback.
-
@kpine Thanks!
|
Beta Was this translation helpful? Give feedback.
The prom-exporter plugin is an external project by a different maintainer: https://github.com/kvaster/zwavejs-prom
The plugin code is responsible for setting up the
/metrics
endpoint request handler and sending the response including setting the content type. Here's the existing code from the plugin:https://github.com/kvaster/zwavejs-prom/blob/ece34753358848b24ab478e3c689e28c942797c8/index.js#L79-L81
Compare to the example code from the upstream prom-client project, which shows that the request handler needs to set the content type:
https://github.com/siimon/prom-client/blob/c1d76c5d497ef803f…