starlette-exporter
Prometheus metrics exporter for Starlette applications.
What it is and what it does
starlette_exporter is a middleware that automatically instruments Starlette applications to collect HTTP metrics compatible with Prometheus. It tracks three core metrics: total request count (starlette_requests_total), request duration distribution (starlette_request_duration_seconds), and concurrent requests in progress (starlette_requests_in_progress). Each metric is labeled by HTTP method, request path, and response status code, allowing fine-grained monitoring and alerting.
The middleware integrates as a standard Starlette middleware and exposes metrics via a /metrics endpoint that Prometheus can scrape. It supports customization through options like custom labels (static or request-derived), histogram bucket configuration, path grouping for cardinality control, and filtering or grouping of unhandled paths. It also provides helper functions to extract label values from request or response headers with cardinality constraints.
Use it for:
- Monitor request latency distribution and identify performance regressions in Starlette services.
- Track concurrent request volume to detect capacity issues and inform auto-scaling decisions.
- Add custom labels from headers to correlate metrics with deployment environment or tenant information.
- Exclude health-check or probe endpoints from metrics collection to reduce noise and cardinality.
- Integrate trace IDs as exemplars in Prometheus histograms to link metrics to distributed traces.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Collects and exports Prometheus metrics for Starlette and FastAPI applications, tracking request counts, response times, and concurrent request volumes with configurable labels and histogram buckets.
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a standard need for Prometheus monitoring of web applications. The permissive Apache 2.0 license poses no restrictions. Install it if you run Starlette and need Prometheus metrics without writing custom instrumentation.
Install
starlette-exporter on PyPI
pip
pip install starlette-exporteruv
uv add starlette-exporterpoetry
poetry add starlette-exporterInstalling starlette-exporter
Before you install
Low friction: pure Python wheel with only two runtime dependencies (prometheus_client and starlette). Actively maintained with recent releases; last commit 2026-07-29.
License in practice
Apache License 2.0 (permissive): you can use, modify, and distribute this package freely in commercial and open-source projects, provided you include a copy of the license and state significant changes.
Quickstart
pip install starlette_exporter
from starlette.applications import Starlette
from starlette_exporter import PrometheusMiddleware, handle_metrics
app = Starlette()
app.add_middleware(PrometheusMiddleware)
app.add_route("/metrics", handle_metrics)
Verify before relying
- Whether the package works with all current versions of prometheus_client and starlette, or if specific version ranges are required.
- Performance overhead of metric collection in high-throughput scenarios.
- Compatibility with frameworks beyond Starlette (e.g., FastAPI) given only starlette is listed as a runtime dependency.
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — prometheus_client, starlette |
| Maintenance | actively maintained — 16 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,916,953/month — #3,434 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: starlette_exporter-0.24.0-py3-none-any.whl
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,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
starlette-prometheusAdds Prometheus metrics collection and exposure…
copyleft · top 15,000 on PyPI
prometheus-flask-exporterExports HTTP request metrics from Flask…
permissive · top 5,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
opentelemetry-exporter-prometheusExports OpenTelemetry metrics to Prometheus for…
permissive · top 1,000 on PyPI
prometheus-clientInstruments Python applications to expose…
permissive · top 1,000 on PyPI
starlette-compressMiddleware for Starlette and FastAPI that…
permissive · top 5,000 on PyPI
fastapi-healthchecksAdds configurable health check endpoints to…
permissive · top 15,000 on PyPI