Skip to main content

fastapi-prometheus-exporter

codecov
FastAPI Prometheus Exporter is a simple Prometheus exporter for FastAPI applications. It provides a set of metrics by default and allows you to add your own metrics as well.

Installation

pip install fastapi-prometheus-exporter

or

poetry add fastapi-prometheus-exporter

Usage

from fastapi import FastAPI
from fastapi_prometheus_exporter import PrometheusExporterMiddleware
app = FastAPI()

PrometheusExporterMiddleware.setup(
    app=app,
    metrics_path="/metrics",
    # ignore_paths=["/healthz", "/metrics"],
)

Parameters

  • app: FastAPI application instance
  • ignore_paths: List of paths to ignore. Default: []
  • metrics_path: Path to expose metrics. Default: /metrics
  • metrics_registry: Prometheus registry to use. Default: prometheus_client.CollectorRegistry
  • request_latency_name: Name of the request latency metric. Default: http_request_duration_seconds
  • request_latency_doc: Description of the request latency metric. Default: HTTP Request Latency
  • request_latency_buckets: Buckets for the request latency metric. Default: prometheus_client.Histogram.DEFAULT_BUCKETS
  • request_latency_labels: Labels for the request latency metric. Default: ["method", "endpoint", "http_status"]
  • request_count_name: Name of the request count metric. Default: http_requests_total
  • request_count_doc: Description of the request count metric. Default: Total HTTP Requests
  • request_count_labels: Labels for the request count metric. Default: ["method", "endpoint", "http_status"]

Metrics

Default Metrics

  • http_request_duration_seconds: HTTP request latency in seconds
  • http_requests_total: Total HTTP requests

Metadata

Release files for fastapi-prometheus-exporter 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-prometheus-exporter 0.2.2
File Size Uploaded Provenance Actions
fastapi_prometheus_exporter-0.2.2.tar.gz 3.4 kB Without provenance Details for fastapi_prometheus_exporter-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-prometheus-exporter 0.2.2
File Interpreter ABI Platform Actions
fastapi_prometheus_exporter-0.2.2-py3-none-any.whl Python 3 none any Details for fastapi_prometheus_exporter-0.2.2-py3-none-any.whl

Total release size: 7.8 kB

Release files / fastapi_prometheus_exporter-0.2.2.tar.gz

Download URL fastapi_prometheus_exporter-0.2.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1eb6d88b638e1e234e071879d413b64f466a31fd6f0afc5dfdc869956c1d2b1e
BLAKE2b-256 checksum
How to use checksums
734f3e08d09b8ba29daa10e750022f7038b2d11770ff4d7b9be02615ed4de17e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1016-azure

Release files / fastapi_prometheus_exporter-0.2.2-py3-none-any.whl

Download URL fastapi_prometheus_exporter-0.2.2-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e14ee4350131768d3ec0588d62b12b8b6d2cf870467b4d0761d5925cf2a65960
BLAKE2b-256 checksum
How to use checksums
7943b3a6b35b3d832280119b96b7c2775ca4cf776a09cb96c32a2f6aeeb46336
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.12 Linux/6.2.0-1016-azure

Security for fastapi-prometheus-exporter 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page