TExcelTAD

RED & USE: What to Query

Knowing PromQL doesn't tell you what to put on a dashboard. Two short checklists do, and System Design: Observability introduced both: RED for anything that serves requests, USE for anything that is a resource. Google's SRE book adds the four golden signals, which are RED plus saturation.

Method For Signals
RED (Tom Wilkie) services, endpoints, dependencies Rate (requests/s), Errors (failed requests/s or ratio), Duration (latency distribution)
USE (Brendan Gregg) CPUs, memory, disks, network, pools, queues Utilisation (% busy), Saturation (queued work), Errors (device errors)
Golden signals user-facing systems latency, traffic, errors, saturation

RED for linkly in PromQL

promql
# Rate: requests per second, per route
sum by (route) (rate(http_requests_total{job="linkly"}[5m]))

# Errors: fraction of requests answered with 5xx
sum(rate(http_requests_total{job="linkly", code=~"5.."}[5m]))
  / sum(rate(http_requests_total{job="linkly"}[5m]))

# Duration: p50 / p99 per route
histogram_quantile(0.99,
  sum by (route, le) (rate(http_request_duration_seconds_bucket{job="linkly"}[5m])))

Decide what counts as an error. 5xx: yes. 4xx: usually not (the client's fault), except codes that mean you failed (429 Too Many Requests when you rate-limit too hard). For linkly, a 404 on GET /{code} is a normal "unknown link"; a sudden jump in 404s, though, may mean a cache bug, so graph it separately.

Apply RED per dependency too, from the client side: linkly's PostgreSQL queries and Redis calls, each with their own rate, error and duration metrics. When the service's latency rises, the dependency panels say which one did it.

USE for the machines underneath

Resource Utilisation Saturation Errors
CPU 1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) load per core: node_load1 / count by (instance) (node_cpu_seconds_total{mode="idle"}), or PSI rate(node_pressure_cpu_waiting_seconds_total[5m]) –
Memory 1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes swapping rate(node_vmstat_pswpin[5m]), OOM kills increase(node_vmstat_oom_kill[1h]), PSI memory –
Disk rate(node_disk_io_time_seconds_total[5m]) rate(node_disk_io_time_weighted_seconds_total[5m]) (queue) node_disk_*_errors via smartctl exporter
Network bytes vs link speed drops rate(node_network_receive_drop_total[5m]) rate(node_network_receive_errs_total[5m])
Container CPU vs limit: rate(container_cpu_usage_seconds_total[5m]) / on(...) kube_pod_container_resource_limits{resource="cpu"} throttling rate(container_cpu_cfs_throttled_periods_total[5m]) / rate(container_cpu_cfs_periods_total[5m]) restarts increase(kube_pod_container_status_restarts_total[1h])
Connection pool in use / max waiters, wait time timeouts acquiring

Saturation is the one people forget, and it's the early warning: a CPU at 70% utilisation with a long run queue is already slowing requests down. In containers, CPU throttling is the classic hidden saturation: average CPU looks fine while the container hits its CFS quota every 100 ms window (Linux Server Administration: cgroups).

RED and USE from raw events

This model computes RED for one minute of linkly requests and USE for a connection pool from samples, the same arithmetic PromQL does:

python · try it yourself
requests = [  # (second, route, status, duration_seconds)
    (1, "/{code}", 302, 0.004), (2, "/{code}", 302, 0.006), (5, "/links", 201, 0.031),
    (9, "/{code}", 404, 0.003), (14, "/{code}", 302, 0.005), (20, "/{code}", 500, 2.001),
    (27, "/{code}", 302, 0.007), (33, "/links", 201, 0.028), (41, "/{code}", 302, 0.004),
    (44, "/{code}", 500, 2.003), (52, "/{code}", 302, 0.009), (58, "/links", 500, 1.998),
]
window = 60
by_route = {}
for _, route, status, dur in requests:
    r = by_route.setdefault(route, {"n": 0, "err": 0, "durs": []})
    r["n"] += 1
    r["err"] += status >= 500
    r["durs"].append(dur)

print("route     rate/s  errors  p50      max")
for route, r in sorted(by_route.items()):
    d = sorted(r["durs"])
    print(f"{route:9} {r['n'] / window:6.3f}  {r['err'] / r['n']:6.1%}  {d[len(d) // 2] * 1000:5.0f} ms {d[-1] * 1000:5.0f} ms")

# USE for a pool of 10 PostgreSQL connections, sampled every 10 s
in_use = [6, 7, 10, 10, 10, 8]
waiting = [0, 0, 3, 7, 4, 0]
timeouts = 2
print(f"pool utilisation {sum(in_use) / (10 * len(in_use)):.0%}, "
      f"saturation: max {max(waiting)} waiting, errors: {timeouts} acquire timeouts")
route     rate/s  errors  p50      max
/links     0.050   33.3%     31 ms  1998 ms
/{code}    0.150   22.2%      6 ms  2003 ms
pool utilisation 85%, saturation: max 7 waiting, errors: 2 acquire timeouts

The story reads straight off the numbers: every failure took about 2 seconds (a timeout), and in the same minute the pool was full with requests queuing for a connection. RED says what users feel; USE says why. A dashboard with RED on top and USE for each dependency below is the layout the Mini Project builds.

Test yourself

Which three signals make up RED?

  1. Rate, Errors, Duration
  2. Requests, Exceptions, Disk
  3. Reads, Errors, Delay
  4. Rate, Events, Data

A container's average CPU usage is 40% of its limit, yet latency rises at peak. Which saturation signal should you check?

  1. Disk errors
  2. CPU throttling: cfs_throttled_periods / cfs_periods
  3. Memory utilisation
  4. up

Should linkly count 404 responses to GET /{code} as errors in its error-rate SLI?

  1. Yes, all 4xx are errors
  2. Usually not: an unknown short code is a correct answer; graph 404s separately to catch anomalies
  3. Only on weekends
  4. Only if they are slow