intermediate
RED metrics
Track request rate, errors, and duration for request-driven services and APIs.
RED (Rate, Errors, Duration) fits request-driven services: APIs, gateways, and serverless handlers. It answers how much traffic you serve, how often it fails, and how slow it feels to callers.
| Letter | Metric idea | |--------|-------------| | Rate | Requests per second (or events/minute) | | Errors | Failed requests / total (by status or outcome) | | Duration | Latency distribution (p50, p95, p99) |
// conceptual counters/histograms
http_requests_total.inc({ method, route, status });
http_request_duration_ms.observe({ route }, elapsed);
Slice by route, method, and dependency only where cardinality stays bounded. Pair RED with SLOs on availability and latency percentiles users actually feel.
On interviews: choosing histogram buckets, error definition (5xx only vs business failures), and RED vs USE for a database node.
Common pitfalls: high-cardinality route labels (raw IDs); averaging latency instead of percentiles; counting 4xx client errors as service errors without context.
The trade-off is dashboard usefulness versus label cardinality and storage cost.
Checklist:
- Measure rate, errors, and latency per key surface.
- Use histograms or summaries for duration.
- Align error definition with SLO intent.
- Cap label cardinality.