Prometheus Metrics for Flask Web App
Likely abandoned. No release or commit for years (last release over 7 years ago).
pip install flask-prometheus-metricsFlask Prometheus Metrics
Prometheus metrics exporter for Flask web applications.
flask_prometheus_metrics uses official Prometheus Python Client
providing basic metrics about process resource usage, app's requests metrics and information.
Installation
pip install -U flask_prometheus_metrics
You will need Flask to run examples below:
pip install -U 'flask_prometheus_metrics[flask]'
Usage
Run the following minimal example in Python shell:
from flask import Flask
from prometheus_client import make_wsgi_app
from werkzeug.middleware.dispatcher import DispatcherMiddleware
from werkzeug.serving import run_simple
from flask_prometheus_metrics import register_metrics
app = Flask(__name__)
@app.route("/")
def index():
return "Test"
# provide app's version and deploy environment/config name to set a gauge metric
register_metrics(app, app_version="v0.1.2", app_config="staging")
# Plug metrics WSGI app to your main app with dispatcher
dispatcher = DispatcherMiddleware(app.wsgi_app, {"/metrics": make_wsgi_app()})
run_simple(hostname="localhost", port=5000, application=dispatcher)
Then go over http://localhost:5000/, refresh page a few times and check your
app's metrics at http://localhost:5000/metrics.
See also example.py for more elaborate example of library usage in real Flask applications.
Metrics
flask_prometheus_metrics exposes the following application metrics:
