tg44 / OctoPrint-Prometheus-Exporter

An octoprint plugin for prometheus compatible metrics endpoint
MIT License
47 stars 21 forks source link

Having trouble getting the permssions to work properly on a simple curl #31

Closed jgrossmac closed 9 months ago

jgrossmac commented 2 years ago
/ # curl 192.168.10.100/plugin/prometheus_exporter/metrics
{"error":{"dangerous":false,"default_groups":["users"],"description":"Allow access to Prometheus metrics. Includes the Status permission.","key":"PLUGIN_PROMETHEUS_EXPORTER_METRICS","name":"Prometheus Exporter Plugin: Metrics access","needs":{"role":["plugin_prometheus_exporter_metrics","status"]},"plugin":"prometheus_exporter"}}

image image

loelkes commented 2 years ago

@jgrossmac I can confirm that. I will look into it (I wrote that piece) and for some magical reasons that I cannot explain right now this did work in my tests.

loelkes commented 1 year ago

It seems this issue is related to OctoPrint. I opened an issue octoprint/octoprint#4670

loelkes commented 1 year ago

So the solution with curl would be

  1. curl -X POST -b /tmp/octoprint-cookie.txt -c /tmp/octoprint-cookie.txt localhost:5000/api/login?passive=true
  2. curl -b /tmp/octoprint-cookie.txt -c /tmp/octoprint-cookie.txt localhost:5000/plugin/prometheus_exporter/metrics

But AFAIK this does not work with prometheus. In this context it's a won't fix and and API key is always required. Setting individual permissions per user (access/no access) for metrics works fine.

tg44 commented 1 year ago

This is really interesting. I don't see a reason why we need a cookie for unauthenticated/public requests...

loelkes commented 1 year ago

This is a confirmed bug in OctoPrint and will be fixed in 1.9.0.

loelkes commented 9 months ago

@jgrossmac This was fixed, I can't reproduce it with OctoPrint 1.9.1.

Please close the issue or comment if this problem persists.

tg44 commented 9 months ago

Thanks for the heads up, I'm closing this!