Registry / web-framework / flask-prometheus-metrics

flask-prometheus-metrics

JSON →
library1.0.0pypypiunverified

A Flask extension that provides Prometheus metrics for Flask web applications with minimal configuration. Version 1.0.0 supports Python >=3.6 and offers a straightforward API to expose metrics like request count, request duration, and custom metrics via a /metrics endpoint.

pip install flask-prometheus-metrics
INSTALL
IMPORT
SIG · FLASK-PROMETHEUS-M
F
flask-prometheus-metrics
web-frameworkpythonv1.0.0
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PrometheusMetrics
from flask_prometheus_metrics import PrometheusMetrics
from flask_prometheus_metrics import PrometheusMetrics

Initialize PrometheusMetrics with the Flask app. By default, metrics are exposed at /metrics.

from flask import Flask from flask_prometheus_metrics import PrometheusMetrics app = Flask(__name__) metrics = PrometheusMetrics(app) @app.route('/') def hello(): return 'Hello, World!' if __name__ == '__main__': app.run()
Debug
Known issues
gotchaThe default /metrics endpoint is not protected; anyone can access it. In production, ensure it's secured or exported via a separate sidecar.
fix
Use a reverse proxy or add authentication via Flask decorators before the /metrics route.
affects: all
gotchaIf you use register_metrics() separately, it expects a Flask app or blueprint; otherwise metrics won't update. Common mistake: calling after app creation without passing the app.
fix
Pass the Flask app instance to register_metrics(), e.g., register_metrics(app).
affects: 1.0.0
deprecatedThe old import path flask_prometheus_metrics.metrics is deprecated. All metrics are accessible from the top-level package now.
fix
Use from flask_prometheus_metrics import PrometheusMetrics instead.
affects: >=1.0.0
Upgrade
Version history
1.0.0latest on PyPI · released Jun 6, 2019
Audit
Dependencies
flaskrequiredRuntime dependency
prometheus-clientrequiredCore metrics implementation
Agent activity
25 hits · last 30 days
node
20
OpenAI (training)
2
Amazon
1
Resources
flask-prometheus-metrics — pip install flask-prometheus-metrics · libregistry