prometheus-fastapi-instrumentator (or starlette-exporter) adds middleware that emits http_request_duration_seconds (histogram) per route, plus http_requests_in_progress (gauge). You exclude /metrics, /health, /docs from the histogram so probe traffic doesn’t dominate.
Instrumentator().instrument(app).expose(app, endpoint=“/metrics”, include_in_schema=False).
exclude_handlers=[“/metrics”, “/health”, “/docs”, “/openapi.json”].
Histogram buckets default to ~ms; tune for your SLO.
request -> middleware -> {route, status, duration} -> /metrics
Prometheus scrapes /metrics -> Grafana queries
Default buckets past; tune them for your latency SLO, or the dashboard lies.