devops / monitoring
Monitoring and Observability: RED, USE, Percentiles and Prometheus
What to measure on a service and on a server, why the average response time misleads, and how Prometheus turns histogram buckets into a p95. The percentile arithmetic was computed for this page and the tool facts were checked on their own sites.
Monitoring answers a question you wrote down in advance: is the error rate above 1 percent, is the disk full. Observability is the ability to answer questions you did not predict, by exploring metrics, logs and traces after something strange happens. In practice you need both, and you need to know which numbers deserve a graph in the first place. Two short checklists, RED for services and USE for resources, cover most of the answer. A third idea, percentiles, explains why a dashboard that says "average latency 220 ms" can sit on top of an application that is timing out for one user in fifty.
01 · THE AVERAGE PROBLEM
Why the mean hides your slowest users
Take 1,000 requests: 900 finish in 100 ms, 80 take 400 ms, and 20 take 5,000 ms. That is a plausible shape for a service with a slow dependency or a cold cache. Computing the summary numbers directly from that list gives:
| Statistic | Value | What it tells you |
|---|---|---|
| Mean | 222 ms | Looks fine, and matches nobody's real experience |
| p50 (median) | 100 ms | The typical request |
| p90 | 100 ms | Nine in ten requests are fast |
| p95 | 400 ms | The slow tail begins |
| p99 | 5,000 ms | One request in a hundred waits five seconds |
The percentile pN is the value that N percent of observations are at or below, which Prometheus's documentation phrases as the φ-quantile. Here the nearest-rank p99 is the 990th-fastest of 1,000 requests. The mean of 222 ms is dragged up by the 20 outliers and hides them, while p99 states the problem outright. Alert and set targets on percentiles, and graph p50, p95 and p99 together so you can see whether the whole distribution moved or only the tail.
02 · WHAT TO GRAPH
RED for services, USE for resources, and the four golden signals
The RED method comes from Tom Wilkie, who described it for microservices: for every service, track the rate of requests, the number of errors, and the duration of requests. The USE method comes from Brendan Gregg: for every resource, such as a CPU, a disk or a network interface, check utilization, saturation and errors. Gregg defines saturation as the degree to which a resource has extra work it cannot service, often a queue. Google's SRE book offers a related list, the four golden signals: latency, traffic, errors and saturation.
| Method | Apply it to | Concrete example |
|---|---|---|
| RED | Each request-driven service | Checkout API: requests per second, share of responses that are 5xx, p95 latency |
| USE | Each machine resource | Database host disk: percent busy, queue length, I/O error count |
| Four golden signals | A user-facing system, when you can only pick four | Latency, traffic, errors, and saturation of the tightest resource |
03 · FROM BUCKETS TO A P95
How Prometheus estimates percentiles, and where it goes wrong
A Prometheus histogram does not store every request time. It stores counters of how many observations fell at or below each bucket boundary. Prometheus calculates the quantile on the server with histogram_quantile(), interpolating inside the bucket where the target rank falls. The documentation states that quantiles are estimates, with error limited by the width of the bucket the quantile lands in.
Feed it the same 1,000 requests with buckets at 0.1 s, 0.5 s and 5 s, which hold 900, 980 and 1,000 cumulative observations:
| Quantile | Target rank | Bucket it lands in | Estimate | True value |
|---|---|---|---|---|
| p95 | 950 | 0.1 to 0.5 s (80 observations) | 0.1 + 0.4 × (50 / 80) = 0.35 s | 0.4 s |
| p99 | 990 | 0.5 to 5 s (20 observations) | 0.5 + 4.5 × (10 / 20) = 2.75 s | 5 s |
The p99 estimate is off by almost a factor of two because one bucket spans 0.5 s to 5 s. Prometheus assumes the observations are spread evenly across the bucket, and these are all stacked at the top. The fix is not a cleverer query; it is choosing bucket boundaries around the latencies you care about, such as your SLO threshold. The same docs compare summaries, which calculate quantiles inside the application but cannot be aggregated across instances. When many instances serve one API, histograms are the usual choice for that reason.
# Rate: requests per second across all instances sum(rate(http_requests_total[5m])) # Errors: share of responses that are 5xx sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) # Duration: p95 latency, aggregated across instances histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))
The last query follows the pattern in the Prometheus function reference: wrap rate() in sum, and keep the le label in the by clause because histogram_quantile() needs it. The metric names are the common convention; yours depend on your client library. These queries are patterns to adapt, and were not run against a live server for this page.
04 · THE FREE STACK
Prometheus, Grafana and OpenTelemetry: versions and licenses
| Tool | Role | Version / license / free tier |
|---|---|---|
| Prometheus | Scrapes metrics and stores them as time series; evaluates alert rules | 3.15.1 listed as latest and 3.13.5 as the LTS release on the download page; Apache License 2.0 |
| Grafana | Dashboards and alerting over many data sources | GNU AGPL v3 for the open source project; Grafana Cloud has an always-free plan with usage limits and 14 days of retention |
| OpenTelemetry | Vendor-neutral instrumentation for traces, metrics and logs | Open specification and SDKs; you pick the backend |
The AGPL is a copyleft license, which means a different set of obligations from Apache 2.0, so read it before you modify and redistribute Grafana. For learning, the licenses make no practical difference. The usual first project is Prometheus scraping one application and Grafana drawing the three RED panels from the queries above.
05 · READ NEXT
Primary sources, in the order worth reading them
- The USE Method, by Brendan Gregg ↗The original write-up, with per-resource checklists for servers.brendangregg.com
- The RED Method: How to Instrument Your Services ↗Grafana's summary of Tom Wilkie's talk, including how RED relates to USE.grafana.com
- Monitoring Distributed Systems (Google SRE book) ↗Chapter 6, the source of the four golden signals and the symptoms-over-causes advice.sre.google
- Histograms and summaries (Prometheus) ↗How quantiles are estimated, with the error analysis behind the example above.prometheus.io
- Query functions: histogram_quantile and rate ↗The reference for the functions used in the queries above.prometheus.io
- Alerting on SLOs (Google SRE workbook) ↗Turning a service level objective into alert rules that page only when the budget is actually at risk.sre.google
- Get started with Grafana Open Source ↗Installing Grafana and building a first dashboard.grafana.com
- OpenTelemetry signals ↗The project's definition of traces, metrics and logs and how they relate.opentelemetry.io
06 · PRACTICE
Reproduce the p99 error yourself
histogram_quantile returns.07 · FAQ
Frequently asked questions
What is the difference between monitoring and observability?
Monitoring checks known conditions, such as error rate or disk space, against thresholds you defined in advance. Observability is how well you can explain unexpected behavior from the metrics, logs and traces a system emits. Monitoring tells you something is wrong; observability helps you find out why.
What is the RED method?
RED stands for rate, errors and duration. For every service you track how many requests it receives per second, how many of those fail, and how long they take. It was described by Tom Wilkie as a way to monitor microservices consistently.
What is the difference between the RED and USE methods?
RED describes services from the point of view of requests: rate, errors and duration. USE, from Brendan Gregg, describes resources such as CPUs and disks: utilization, saturation and errors. Use RED for what your users call and USE for the machines underneath.
Why use p95 and p99 instead of the average latency?
The average is pulled around by a few extreme requests and describes almost no real request. Percentiles show the experience of the slowest users directly. In a set where 2 percent of requests take five seconds, the mean can still look healthy while p99 shows the problem.
Is Grafana free?
Yes. Grafana is open source under the AGPL v3 license and you can run it yourself at no cost. Grafana Cloud also offers an always-free plan with usage limits and 14 days of retention for metrics, logs and traces.