skillfed

prometheus-fastapi-instrumentator

Instrument your FastAPI app with Prometheus metrics

prometheus-fastapi-instrumentator v8.1.0 16.1M downloads/30d#1,162 on PyPI1,479
Permissive license ISC Active released

What it is and what it does

prometheus-fastapi-instrumentator is a middleware library that automatically collects and exposes Prometheus metrics from FastAPI applications. It wraps your FastAPI app to track HTTP request counts, response sizes, request sizes, and request duration across multiple histogram buckets, with metrics grouped by handler, status code, and HTTP method. The library exposes these metrics on a `/metrics` endpoint ready for Prometheus scraping.

Out of the box it provides five default metrics: a counter for total requests, summaries for request and response sizes, and histograms for request duration at both standard and high-resolution bucket levels. You can customize or extend metrics using pre-built closures from the metrics module or write your own instrumentation functions. Configuration options include regex-based route exclusion, environment variable control, label customization, gzip compression, and in-progress request tracking.

Use it for:

  • Monitor request latency and throughput across FastAPI endpoints for performance analysis
  • Track HTTP response and request sizes to identify bandwidth bottlenecks
  • Expose metrics to Prometheus for alerting on error rates or slow endpoints
  • Build custom metrics to track application-specific events like language preferences or business logic counters
  • Conditionally enable metrics collection in multi-service deployments via environment variables

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Adds Prometheus metrics collection and exposure to FastAPI applications with minimal setup, tracking HTTP request counts, sizes, durations, and custom metrics.

Yes. Low install friction, active maintenance, permissive license, and no known vulnerabilities make this a safe choice. The two-line fast-track setup with sensible defaults covers common monitoring needs, while advanced configuration options support specialized use cases. Suitable for production FastAPI deployments that need Prometheus integration.

Install

prometheus-fastapi-instrumentator on PyPI

pip

pip install prometheus-fastapi-instrumentator

uv

uv add prometheus-fastapi-instrumentator

poetry

poetry add prometheus-fastapi-instrumentator

Installing prometheus-fastapi-instrumentator

Before you install

Low install friction with only two runtime dependencies (prometheus-client and starlette). Actively maintained with recent releases; last commit 2026-08-01 and latest release 2026-07-26. Supports current Python versions (3.10 through 3.14).

License in practice

Licensed under ISC (permissive), allowing use in commercial and private projects with minimal restrictions.

Quickstart

pip install prometheus-fastapi-instrumentator

from prometheus_fastapi_instrumentator import Instrumentator
from fastapi import FastAPI

app = FastAPI()
Instrumentator().instrument(app).expose(app)

Requires Python 3.10 or later.

Verify before relying

  • Performance overhead of middleware instrumentation under high request volumes
  • Cardinality explosion risk with high-dimensionality labels in custom metrics

Package facts

License ISC (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 2 — prometheus-client, starlette
Maintenance actively maintained — 19 days since the last release
Last repo commit
First released
Downloads 16,089,530/month — #1,162 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: prometheus_fastapi_instrumentator-8.1.0-py3-none-any.whl

Keywords: prometheus, instrumentation, fastapi, exporter, metrics

License :: OSI ApprovedProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

prometheus fastapi metricsfastapi instrumentation monitoringhttp request metrics collectionprometheus middleware fastapifastapi prometheus exporterapplication performance monitoring fastapirequest latency trackingmetrics endpoint fastapi
observabilitymetrics-collectionprometheus

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

fan-tools

A collection of internal testing utilities,…

permissive · top 15,000 on PyPI

starlette-exporter

Collects and exports Prometheus metrics for…

permissive · top 5,000 on PyPI

prometheus-api-client

Connects to Prometheus monitoring systems and…

permissive · top 5,000 on PyPI

py-grpc-prometheus

Adds Prometheus metrics collection to gRPC…

unclear · top 5,000 on PyPI

aioprometheus

A Prometheus client library for asyncio…

permissive · top 15,000 on PyPI

starlette-prometheus

Adds Prometheus metrics collection and exposure…

copyleft · top 15,000 on PyPI

prometheus-client

Instruments Python applications to expose…

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

opentelemetry-exporter-prometheus

Exports OpenTelemetry metrics to Prometheus for…

permissive · top 1,000 on PyPI