{"id":23751,"library":"flask-prometheus-metrics","title":"Flask Prometheus Metrics","description":"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.","status":"active","version":"1.0.0","language":"python","source_language":"en","source_url":"https://github.com/pilosus/flask_prometheus_metrics/","tags":["flask","prometheus","metrics","monitoring"],"install":[{"cmd":"pip install flask-prometheus-metrics","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Runtime dependency","package":"flask","optional":false},{"reason":"Core metrics implementation","package":"prometheus-client","optional":false}],"imports":[{"note":"","wrong":"","symbol":"PrometheusMetrics","correct":"from flask_prometheus_metrics import PrometheusMetrics"},{"note":"Older versions used nested module, now public at package level","wrong":"from flask_prometheus_metrics.metrics import register_metrics","symbol":"register_metrics","correct":"from flask_prometheus_metrics import register_metrics"}],"quickstart":{"code":"from flask import Flask\nfrom flask_prometheus_metrics import PrometheusMetrics\n\napp = Flask(__name__)\nmetrics = PrometheusMetrics(app)\n\n@app.route('/')\ndef hello():\n    return 'Hello, World!'\n\nif __name__ == '__main__':\n    app.run()","lang":"python","description":"Initialize PrometheusMetrics with the Flask app. By default, metrics are exposed at /metrics."},"warnings":[{"fix":"Use a reverse proxy or add authentication via Flask decorators before the /metrics route.","message":"The default /metrics endpoint is not protected; anyone can access it. In production, ensure it's secured or exported via a separate sidecar.","severity":"gotcha","affected_versions":"all"},{"fix":"Pass the Flask app instance to register_metrics(), e.g., register_metrics(app).","message":"If 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.","severity":"gotcha","affected_versions":"1.0.0"},{"fix":"Use from flask_prometheus_metrics import PrometheusMetrics instead.","message":"The old import path flask_prometheus_metrics.metrics is deprecated. All metrics are accessible from the top-level package now.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run: pip install flask-prometheus-metrics (note hyphens in package name, underscores in import).","cause":"Outdated installation or wrong package name; flask_prometheus_metrics is not installed.","error":"ImportError: cannot import name 'PrometheusMetrics' from 'flask_prometheus_metrics'"},{"fix":"Use metrics.register_default() - if available, or check documentation for current API. For 1.0.0, this method is still present.","cause":"Method renamed in newer versions; register_default is deprecated.","error":"AttributeError: 'PrometheusMetrics' object has no attribute 'register_default'"},{"fix":"Ensure you call register_metrics(app) with the app argument, or initialize PrometheusMetrics(app).","cause":"Missing required metric or exporter info; likely due to incomplete configuration.","error":"KeyError: 'flask_exporter_info' in metrics endpoint"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}