starlette-prometheus
Prometheus integration for Starlette
What it is and what it does
Starlette Prometheus is a middleware package that integrates Prometheus metrics collection into Starlette web applications. It automatically instruments HTTP requests and responses, collecting metrics like request counts, latencies, and response codes, then exposes them via a `/metrics/` endpoint that Prometheus can scrape. The package wraps Starlette's middleware system to intercept requests transparently.
The package depends on starlette and prometheus_client to function. It's straightforward to set up—add the middleware and route the metrics endpoint—but requires careful configuration when handling dynamic or unmatched routes, as unfiltered path tracking can consume unbounded memory. The package supports Python 3.8 through 3.12 and is marked Production/Stable, though development has been dormant since its last release.
Use it for:
- Expose HTTP request metrics to Prometheus for monitoring Starlette application performance and availability.
- Track request latency, error rates, and throughput to feed into alerting and dashboarding systems.
- Debug and profile application behavior by analyzing request patterns and response times over time.
- Integrate observability into microservices built with Starlette without writing custom instrumentation code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds Prometheus metrics collection and exposure to Starlette web applications, allowing you to instrument HTTP request/response behavior and expose metrics via a `/metrics/` endpoint.
Yes, if you need Prometheus metrics for a Starlette application and accept the GPL-3.0+ copyleft license. Install friction is low and the package is stable. However, dormant maintenance means you should verify compatibility with your Starlette version and be prepared to fork or patch if issues arise. Not suitable if your project cannot comply with GPL-3.0+ licensing.
Install
starlette-prometheus on PyPI
pip
pip install starlette-prometheusuv
uv add starlette-prometheuspoetry
poetry add starlette-prometheusInstalling starlette-prometheus
Before you install
Low install friction with only two runtime dependencies (starlette and prometheus_client). Maintenance is dormant—last release was over 710 days ago, though the repository remains active and the package is marked Production/Stable.
License in practice
Licensed under GPL-3.0+, a copyleft license. Any application using this package must comply with GPLv3+ terms, including potential source code disclosure obligations if you distribute the application.
Quickstart
pip install starlette-prometheus
from starlette.applications import Starlette
from starlette_prometheus import metrics, PrometheusMiddleware
app = Starlette()
app.add_middleware(PrometheusMiddleware)
app.add_route("/metrics/", metrics)
Requires Python 3.8+ and Starlette 0.12+. Unfiltered unhandled paths can lead to unbounded memory use; use filter_unhandled_paths=True if needed.
Verify before relying
- Whether the package is actively maintained or seeking new maintainers despite dormant status.
- Performance impact of metrics collection on high-throughput applications.
- Compatibility with recent Starlette versions beyond what the classifiers declare.
Package facts
| License | GPL-3.0+ (copyleft) |
| Python support | supports the current Python release (<4.0,>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — starlette, prometheus_client |
| Maintenance | dormant — 710 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 432,478/month — #6,708 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: starlette_prometheus-0.10.0-py3-none-any.whl
Keywords: starlette, prometheus, metrics
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
starlette-exporterCollects and exports Prometheus metrics for…
permissive · top 5,000 on PyPI
aioprometheusA Prometheus client library for asyncio…
permissive · top 15,000 on PyPI
prometheus-fastapi-instrumentatorAdds Prometheus metrics collection and exposure…
permissive · top 5,000 on PyPI
prometheus-clientInstruments Python applications to expose…
permissive · top 1,000 on PyPI
oslo.metricsCollects and exposes metrics data from Oslo…
permissive · top 15,000 on PyPI
airflow-exporterExposes Airflow DAG and task metrics to…
permissive · top 15,000 on PyPI
django-prometheusExports Django application metrics (requests,…
permissive · top 5,000 on PyPI
prometheus-asyncAdds async/await support to Prometheus metrics…
permissive · top 15,000 on PyPI
starlette-contextMiddleware for Starlette that stores and…
permissive · top 5,000 on PyPI
starlette-testclientProvides a drop-in replacement for Starlette's…
permissive · top 5,000 on PyPI