skillfed

starlette-exporter

Prometheus metrics exporter for Starlette applications.

starlette-exporter v0.24.0 1.9M downloads/30d#3,434 on PyPI413
Permissive license Apache License 2.0 Active released

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-exporter

uv

uv add starlette-exporter

poetry

poetry add starlette-exporter

Installing 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

prometheus metrics starletterequest monitoring middlewarehttp metrics exporterprometheus histogram counter gaugeapplication performance metricsstarlette middleware monitoringweb framework instrumentation
prometheusobservabilitymiddleware

More Monitoring packages

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

opentelemetry-semantic-conventions

Provides generated Python code for…

permissive · top 100 on PyPI

opentelemetry-sdk

Provides the reference implementation of the…

permissive · top 100 on PyPI

opentelemetry-api

Provides the abstract API and interfaces for…

permissive · top 100 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI

aioprometheus

A Prometheus client library for asyncio…

permissive · top 15,000 on PyPI

prometheus-fastapi-instrumentator

Adds Prometheus metrics collection and exposure…

permissive · top 5,000 on PyPI

starlette-prometheus

Adds Prometheus metrics collection and exposure…

copyleft · top 15,000 on PyPI

prometheus-flask-exporter

Exports HTTP request metrics from Flask…

permissive · top 5,000 on PyPI

airflow-exporter

Exposes Airflow DAG and task metrics to…

permissive · top 15,000 on PyPI

django-prometheus

Exports Django application metrics (requests,…

permissive · top 5,000 on PyPI

opentelemetry-exporter-prometheus

Exports OpenTelemetry metrics to Prometheus for…

permissive · top 1,000 on PyPI

prometheus-client

Instruments Python applications to expose…

permissive · top 1,000 on PyPI

starlette-compress

Middleware for Starlette and FastAPI that…

permissive · top 5,000 on PyPI

fastapi-healthchecks

Adds configurable health check endpoints to…

permissive · top 15,000 on PyPI