Day 99: Prometheus fundamentals: exporters, PromQL
Prometheus: pull-based metrics collection
Unlike systems where apps push metrics out, Prometheus pulls — it periodically scrapes an HTTP endpoint (/metrics) that each service exposes, storing everything as time series. An exporter is a small process that exposes metrics for something that doesn't natively speak Prometheus's format (a database, a queue, an OS).
http_requests_total{method="GET",path="/api/users",status="200"} 15234
http_request_duration_seconds_bucket{le="0.1"} 9821
http_request_duration_seconds_bucket{le="0.5"} 15100Why pull instead of push
Pull-based collection means Prometheus itself controls scrape timing and can immediately tell if a target stops responding (a scrape failure is itself a signal) — and services don't need to know anything about where metrics are sent, they just expose an endpoint. This is a real, deliberate design trade-off, not an arbitrary choice.
PromQL
rate(http_requests_total[5m]) -- requests/sec over the last 5 min
sum(rate(http_requests_total{status=~"5.."}[5m])) -- total error rate across all instances
histogram_quantile(0.99, rate(http_request_duration_seconds_bucket[5m])) -- p99 latencyKey terms
- Exporter
- A process exposing metrics in Prometheus's format for something that doesn't natively support it.
- PromQL
- Prometheus's query language for time series data.
Why does Prometheus's pull model make it easy to detect that a service has gone completely down?