Skip to content
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

Content-type error since using Prometheus 3 #5

Closed
soso-bc opened this issue Dec 10, 2024 · 7 comments
Closed

Content-type error since using Prometheus 3 #5

soso-bc opened this issue Dec 10, 2024 · 7 comments

Comments

@soso-bc
Copy link

soso-bc commented Dec 10, 2024

Hello,

Upgrading to Prometheus 3, I encountered a content-type issue.
Prometheus expects 'text/plain' while the plugin returns 'text/html'

I fixed it locally but I think I would not be the only one.
That's why I give the correction:

$ grep -n 'register[;.]' Docker/plugins/zwavejs-prom/index.js
5:const register = promCli.register;
81: res.set('Content-Type', register.contentType);

@TheAceMan
Copy link

I ran into this as well. Could you explain your work around?

@soso-bc
Copy link
Author

soso-bc commented Dec 26, 2024

@TheAceMan
Modify the zwavejs-prom/index.js file to add the 2 lines (At line 5 and 81) returned by the grep command I specified.

@TheAceMan
Copy link

Ahh, thanks. Didn't realize the grep was ran after the change to show the modifications. Got it working. But this work around will be cleared on pod restart in the kubernetes cluster. Will have to look into a init container or some persistence if this is not going to be fixed.

@soso-bc
Copy link
Author

soso-bc commented Dec 28, 2024

You just need to create your own docker image by overloading the initial one.
ex:

FROM zwavejs/zwave-js-ui:latest

COPY plugins/zwavejs-prom/index.js /usr/src/app/node_modules/@kvaster/zwavejs-prom/index.js

@TheAceMan
Copy link

A bit hackish but the init container is working. Creating a image would require a container registry and pushing new images as zwave-js-ui base updates. Got it all working and hopefully it's a short term.

@disconn3ct disconn3ct mentioned this issue Dec 30, 2024
kvaster added a commit that referenced this issue Dec 31, 2024
@kvaster
Copy link
Owner

kvaster commented Jan 1, 2025

Fixed by #6

@joneshf
Copy link

joneshf commented Jan 14, 2025

Ran into this as well. The migration guide for Prometheus actually calls this failure out: https://prometheus.io/docs/prometheus/latest/migration/#scrape-protocols.

If you cannot update to a version of @kvaster/zwavejs-prom that fixes this (like me) there's another option in that guide: set the fallback_scrape_protocol explicitly.

E.g. If you're running this in k8s (which, surprisingly someone else in this thread seems to be doing!) and using the Prometheus Operator (or at least their CRDs), you can set fallbackScrapeProtocol on your *Monitor:

 apiVersion: monitoring.coreos.com/v1
 kind: ServiceMonitor
 metadata:
   name: z-wave-js
   namespace: z-wave-js
 spec:
   endpoints:
     - path: /metrics
       port: ui
+  fallbackScrapeProtocol: PrometheusText1.0.0
   selector:
     matchLabels:
       app.kubernetes.io/component: z-wave-js
       app.kubernetes.io/name: z-wave-js

Or whatever.

You should be able to do similar with the fallback_scrape_protocol in plain old Prometheus files if you're doing it that way as well.


And for the sake of SEO for the next person that runs into this, the error I was receiving looked something like this:

Error scraping target: received unsupported Content-Type "text/html; charset=utf-8" and no fallback_scrape_protocol specified for target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants