Prometheus provides production visibility by collecting application metrics, indexing them as time series, querying them, and supporting alert evaluation. Applications expose a metrics endpoint, and Prometheus workers pull and store the results. Grafana visualizes the data, while Alertmanager routes triggered alerts to operational channels. section 3.5 section 11.1.4
A practical Prometheus deployment connects these pieces:
- Expose /metrics or a similar endpoint from each monitored application, using language-specific instrumentation packages. section 3.5
- Configure scraping so Prometheus discovers targets and pulls their metrics into its time-series database. section 3.5
- Use the Prometheus UI to verify scraping and query values; use Grafana for durable dashboards and charts. section 3.5
- Define PromQL alert expressions such as up == 0 or absent(up) == 1, add a duration and severity, then route notifications through Alertmanager. section 11.1.4
Instrumenting a FastAPI service
Add PrometheusMiddleware and expose handle_metrics at /metrics. Prometheus can then scrape the service, while request counters can be queried and visualized in Grafana. A query such as sum by (response_code) (increase(starlette_requests_total[10m])) summarizes recent requests by response code.







