Services

Resources

Company

Prometheus

Prometheus is an open source monitoring and alerting toolkit that stores metrics as time series. It scrapes numeric samples from HTTP endpoints, keeps them with key-value labels in a local database, and lets you query them with PromQL, its query language. It began at SoundCloud in 2012 and joined the Cloud Native Computing Foundation in 2016.

How it works

An application exposes its metrics at a path such as /metrics. Prometheus pulls from that path on a schedule. The global scrape interval defaults to 1 minute, and many teams set 15 seconds. Samples go into a local time series database that keeps 15 days of data by default.

A query for the share of failing requests over 5 minutes looks like this:

  • sum(rate(http_requests_total{code=~"5.."}[5m])) / sum(rate(http_requests_total[5m]))

Alert rules run on the server. Alertmanager then groups, routes and silences the alerts. Grafana is the usual dashboard layer.

Why it matters in production

Prometheus is the common base for SLI and SLO alerting on Kubernetes. One server does not scale out, so large setups use remote write to long-term storage. Labels with many distinct values, called cardinality, are the usual cause of memory trouble.

See also

On the One2N blog

Further reading

Comic about Prometheus: a shop's app shows its own counts on a web page, 200 requests, 4 failed, slowest 0.8 s, but only for now; Prometheus visits every 15 seconds and writes the numbers down, building history; a PromQL query works out failed over total in the last 5 minutes, 4 / 200 = 2%; a rule alerts when failures stay above 5% for 5 minutes.