skillfed

starlette-prometheus

Prometheus integration for Starlette

starlette-prometheus v0.10.0 432.5K downloads/30d#6,708 on PyPI378
Copyleft license GPL-3.0+ DORMANT released

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

uv

uv add starlette-prometheus

poetry

poetry add starlette-prometheus

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTP :: HTTP ServersTopic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Application Frameworks

Tags

prometheus metrics starlettestarlette monitoring instrumentationhttp metrics collectionprometheus middlewarestarlette observabilityrequest metrics exposureprometheus http integration
observabilityprometheusmiddleware

More Software Development packages

typing-extensions

Provides backported and experimental type hints…

permissive · top 100 on PyPI

numpy

NumPy provides an N-dimensional array object…

permissive · top 100 on PyPI

fastapi

FastAPI is a Python web framework for building…

permissive · top 100 on PyPI

annotated-doc

Provides a way to document function parameters,…

permissive · top 100 on PyPI

typer

Typer builds command-line applications from…

permissive · top 1,000 on PyPI

distlib

Distlib provides low-level packaging utilities…

permissive · top 1,000 on PyPI

starlette-exporter

Collects and exports Prometheus metrics for…

permissive · top 5,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

prometheus-client

Instruments Python applications to expose…

permissive · top 1,000 on PyPI

oslo.metrics

Collects and exposes metrics data from Oslo…

permissive · top 15,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

prometheus-async

Adds async/await support to Prometheus metrics…

permissive · top 15,000 on PyPI

starlette-context

Middleware for Starlette that stores and…

permissive · top 5,000 on PyPI

starlette-testclient

Provides a drop-in replacement for Starlette's…

permissive · top 5,000 on PyPI