http_requests_total{code="500"}FOUR GOLDEN SIGNALS119rate –1import prometheus_client as prom2reqs = prom.Counter('http_requests',3 'Requests served', ['code'])4prom.start_http_server(8000)5reqs.labels(code='500').inc()0 s–15 s–30 s–45 s–60 s–LATENCYTRAFFICERRORSSATURATION
Back row: the app, /metrics, Prometheus, the alert rule, Alertmanager, the on-call phoneFront: the Python counter, the stored time series, the four golden signalsMovers: the scrape, each new sample, the alertMonitoring with Prometheus: a shop web app counts its failed requests in its own code and lists the count on a /metrics page. Prometheus pulls that page every 15 seconds and stores each reading as a sample in a time series; a query turns the counter's climb into errors per second. When a bad release pushes the rate from 0.2 to 3 errors per second, an alerting rule goes pending, then fires, and Alertmanager pages the on-call engineer. In front, the Python that makes the counter, the stored samples, and Google's four golden signals. The sample values are an invented example. Real services usually alert on the share of requests that fail (errors divided by all requests), not on a raw count, so the threshold still makes sense as traffic grows.

The idea

  1. Monitoring means collecting numbers about a running service, called metrics, every few seconds. A tool stores them over time, draws graphs and wakes a person when a number crosses a line. Here Prometheus watches a shop's web app.

Collect: count and scrape

Store and query

Alert a person

What to watch

What happens

;; step 1/10 · watch
service  → counts things in its code (metrics)
monitor  → collects them every few seconds
         → stores them over time
         → graphs them, checks rules
person   ← woken only when a rule trips

The figure divides one 15-second rise by 15 seconds; that is what irate() returns. rate() averages over its whole window, extrapolates to the window edges and handles counter resets, so on real data it gives about the same number, not exactly it. Alerts should use rate(). The sample values are an invented example. Real services usually alert on the share of requests that fail (errors divided by all requests), not on a raw count, so the threshold still makes sense as traffic grows.