How to Instrument the Golden Signals
Instrument latency, traffic, errors and saturation for every service using consistent metrics, so health is visible before customers report it.
On this page
Introduction
When a service is unhealthy, there are only four questions worth asking first: how slow is it, how much load is it taking, how often does it fail, and how close is it to a resource limit. These are the golden signals: latency, traffic, errors and saturation. Instrumenting them consistently across every service gives a uniform health view, so an operator moving between services, or a dashboard aggregating the whole fleet, sees the same four numbers everywhere and can tell healthy from unhealthy at a glance.
The Four Signals Defined
Latency is how long requests take, reported as a distribution rather than an average, because an average hides the tail that users feel. Traffic is demand: requests per second, messages consumed, jobs executed. Errors is the rate of failed requests, split by cause such as client errors versus server errors. Saturation is how full a constrained resource is: CPU, memory, connection pool, queue depth.
The four are related. Rising latency with flat traffic suggests saturation or a downstream slowdown; rising errors with rising traffic may be overload; falling traffic with falling latency can mean requests are failing so fast they never do work. Reporting them together is what makes the picture interpretable.
import { Counter, Histogram } from 'prom-client';
export const httpRequests = new Counter({
name: 'http_requests_total',
help: 'Total HTTP requests',
labelNames: ['method', 'route', 'status'], // traffic + errors
});
export const httpDuration = new Histogram({
name: 'http_request_duration_seconds',
help: 'HTTP request latency',
labelNames: ['method', 'route'],
buckets: [0.05, 0.1, 0.25, 0.5, 1, 2, 5], // latency distribution
});
export const inFlight = new Counter({
name: 'http_in_flight_requests',
help: 'In-flight requests (saturation proxy)',
});
Latency as a Distribution
Never alert on average latency, because a mean of fifty milliseconds can hide a tail of ten seconds that affects a meaningful fraction of users. Use a histogram with buckets chosen around your SLO thresholds, and compute quantiles from the bucket counts. Buckets should concentrate near the boundary you care about, for example half a second, so the quantile is precise where the decision is made.
Distinguish successful from failed request latency. A request that errors in two milliseconds should not be counted as fast success, or a wave of failures will look like an improvement in latency. Track latency for successful requests, and use the error counter for failures.
# Latency quantiles from a histogram (PromQL)
# p95 of successful requests over 5m
histogram_quantile(
0.95,
sum by (le) (rate(http_request_duration_seconds_bucket{status!~"5.."}[5m]))
)
# bucket choice: 0.05..2s near the 99.9% SLO boundary
Traffic and Errors Together
Traffic is the denominator that makes the other signals interpretable. Track requests per second per route, and split errors into client errors and server errors. Server errors are availability failures; client errors may be garbage input from a caller. Labeling the status code lets you compute an error ratio, which is what SLOs use.
Watch the ratio, not just the count. A hundred errors per second is alarming on a service handling two hundred requests per second and unremarkable on one handling a million. The error rate is what detects a spreading failure before absolute numbers look large.
# Error ratio (the SLO's raw input)
sum(rate(http_requests_total{status=~"5.."}[5m]))
/
sum(rate(http_requests_total[5m]))
# Traffic by route
sum by (route) (rate(http_requests_total[5m]))
Saturation and Resource Limits
Saturation is the signal that predicts trouble: a resource that is getting full will eventually cause latency and errors. Track the utilisation of every constrained resource: CPU, memory, thread pool, database connection pool and queue depth. The most useful form is queue depth and utilisation against the limit, because that tells you how much headroom remains.
The classic saturation indicator for most services is the connection pool. If every connection is busy and requests are waiting, latency rises no matter how fast the code is. Export pool in-use versus pool size, and queue wait time, so you can see the wall coming instead of hitting it.
Distinguish utilisation from saturation. Utilisation is how much of a resource is in use right now; saturation is the degree to which there is more work to do than capacity to do it, visible as queuing. A pool at ninety percent utilisation but with zero wait time is fine; a pool at seventy percent with a growing wait queue is not. That is why queue depth and wait time, not just utilisation, belong on the dashboard.
# Saturation proxies worth exporting
cpu_usage_ratio = used_cores / limit_cores
memory_usage_ratio = rss_bytes / limit_bytes
db_pool_in_use / db_pool_max = connection pool utilisation
queue_depth = pending items awaiting a worker
worker_busy_ratio = busy workers / total workers
Consistent Naming Across Services
The golden signals pay off only when every service reports them under the same names with the same labels. Adopt one metric naming scheme, one set of route labels, one definition of error. The OpenTelemetry semantic conventions give you most of this; follow them rather than inventing per-service names.
Consistency lets you build a single fleet-wide dashboard that aggregates the four signals across all services, and lets an operator who has never seen a service read its health immediately. It also lets alerts be shared: the same burn-rate rule works for every service because the SLI is defined identically everywhere.
# Same four signals, same names, every service:
{service="orders"} latency p95, rps, 5xx ratio, pool utilisation
{service="search"} latency p95, rps, 5xx ratio, pool utilisation
{service="auth"} latency p95, rps, 5xx ratio, pool utilisation
# a single dashboard groups by service => uniform health view
Common Pitfalls and Conclusion
Do not alert on averages. Do not put high-cardinality labels such as user id on the signals. Do not forget the denominator: an error count without a rate is not actionable. Do not instrument only CPU and call it saturation; connection pools and queues saturate first for most services. And do not let each team name its metrics differently.
Latency, traffic, errors and saturation cover the questions that matter when something is wrong. Instrument all four per service, under consistent names, with latency as a distribution and saturation against real limits. A dashboard built from them tells you whether a service is healthy before a customer tells you it is not.
Sources: Google SRE Book: Monitoring distributed systems, Prometheus: Histograms and summaries, OpenTelemetry metrics conventions.
FAQ
- Why not just alert on CPU and memory?
- Because resource usage without traffic and latency is uninterpretable: high CPU on a busy service is healthy, and low CPU on a wedged service is not. The golden signals need to be read together, and for most services the connection pool or queue saturates before CPU.
- How do I pick histogram buckets?
- Concentrate them around the latency boundary that matters for your SLO, for example near half a second, so the quantile is precise where the alert decision is made. Include a small number of coarse upper buckets to catch outliers.
Report a problem with this articleOpens a pre-filled issue on GitHub.