prometheus_flask_exporter
prometheus_flask_exporter copied to clipboard
Exposing metrics on a different HTTP server causes metrics to be available on every endpoint
Hi There,
Maybe I am doing something wrong in my configuration, but when I use Gunicorn to expose the metrics on another http server/port taken from the example config: GunicornPrometheusMetrics.start_http_server_when_ready(5005)
Although I can see the metrics on the "/metrics" endpoint, I can also see the metrics on ANY endpoint. /metrics, /metricsTEST, on /, etc. Is this intended behavior? Do I perhaps have something configured wrong?
Thanks!
Hello,
Yeah, I think I didn't really get to the bottom of this yet. :( See the last paragraph in the README at https://github.com/rycus86/prometheus_flask_exporter#multiprocess-applications
A final caveat is that the metrics HTTP server will listen on any paths on the given HTTP port, not only on /metrics, and it is not implemented at the moment to be able to change this.
Thanks for the quick response. I admit I completely missed that in the documentation. Is this because the start_http_server
is just calling the underlying prometheus library under the hood? I take it that isn't tied to any sort of flask app?
Yeah, that function just calls into https://github.com/prometheus/client_python/blob/3be4faff2223c509b83cb5f2854a9e6d324aa3a7/prometheus_client/exposition.py#L75 which starts a new wsgi server on a new thread. Can't remember the exact reason now why it was hard to do it with Flask, but there might be ways to improve this.