← All features
engineering

Prometheus metrics

Scrape it. Alert on it.

/metrics exposes request counts + duration histograms per route, per method, per status. IP-gated to the docker bridge so Prometheus can scrape without exposing internal metrics to the internet.

  • carrental_http_requests_total{method,path,status}
  • carrental_http_request_duration_seconds histogram (9 buckets 10ms → 5s)
  • Path templates (/api/cars/{car_id}) — no cardinality explosion
  • Metrics endpoint is not proxied by nginx

How it works

prometheus-client registry + a starlette BaseHTTPMiddleware that instruments every request. IP allowlist in code; default 127.0.0.1 + docker 172.16.0.0/12.

Add your Prometheus server IP to METRICS_ALLOW_CIDR.

More engineering features