What problem does it solve?
This Skill prevents blind monitoring and guesswork by showing how to add Prometheus custom metrics to a FastAPI service in a way that stays production-safe, especially around label cardinality and observability readiness.
Core Features & Use Cases
- Production-ready /metrics endpoint: Exposes Prometheus scrape data via
prometheus_client.generate_latest() for FastAPI.
- 3-location metric recording: Implements a clear pattern for placing metrics in middleware (request lifecycle), routes (domain/model/token metrics), and services (quota/rejection outcomes).
- Cardinality safety rules: Provides concrete guardrails to avoid Prometheus time-series explosions (path whitelisting, known enums for model/reason, grouping status codes, and banning high-cardinality identifiers).
- Histogram bucket guidance: Recommends latency bucket selection aligned with expected SLO ranges (e.g., LLM gateway latencies in ms).
- Grafana dashboard starter: Supplies a template dashboard driven by the metric schema for fast visualization and alert panel setup.
Quick Start
Use the skill to instrument your FastAPI app by following the provided 3-location pattern and applying the cardinality rules so you can immediately start scraping and building Grafana panels from the exported metrics.