--- id: prometheus-fastapi-instrumentator version: "8.1.0" license: ISC license_treatment: permissive maintenance: active --- # prometheus-fastapi-instrumentator — Instrument your FastAPI app with Prometheus metrics License: permissive · Maintenance: active · Downloads: 16.1M/mo ## 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 above — 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 pip install prometheus-fastapi-instrumentator uv add prometheus-fastapi-instrumentator 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_current - Install friction: low - Maintenance: active - Downloads: 16.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags prometheus fastapi metrics, fastapi instrumentation monitoring, http request metrics collection, prometheus middleware fastapi, fastapi prometheus exporter, application performance monitoring fastapi, request latency tracking, metrics endpoint fastapi, observability, metrics-collection, prometheus [View on SkillFed](https://skillfed.io/packages/prometheus-fastapi-instrumentator) · [View on PyPI](https://pypi.org/project/prometheus-fastapi-instrumentator/)