prometheus_flask_exporter icon indicating copy to clipboard operation
prometheus_flask_exporter copied to clipboard

Is working outside of request context possible

Open gautierrog opened this issue 1 year ago • 1 comments

Hello,

I try to use the lib within a celery worker. I used a multiprocess metric and called metrics.start_http_server but the metrics I setup are never updated.

How does this lib work outside of flask http requests?

gautierrog avatar Feb 20 '24 12:02 gautierrog

Hey,

This library is intended to use with Flask as it provides convenient wrappers for its HTTP handler functions. Underneath, it uses https://github.com/prometheus/client_python and all metrics exposed through that to the same registry will also show up on the metrics endpoint. Depending on your use-case, perhaps you'd just need the underlying library only and use its exposition options to expose them to your scraper? If not, perhaps a minimal example would help figuring out what options you have.

How does this lib work outside of flask http requests?

To answer this more directly, using metrics (counters, summary, etc.) from the underlying Prometheus library will all show up together with the Flask specific metrics, as long as they all use the same Prometheus registry. (there's a default one unless overridden)

Hope this helps?

rycus86 avatar Feb 20 '24 23:02 rycus86