Agent Wranglers

OPS-12Recommended

Measure rate, errors and duration

For every service, record the request rate, the error rate and the time each request takes, split by route.

How to do it

Use a metrics library or an agent, such as OpenTelemetry or a Prometheus client. Record duration as a histogram, so you can read percentiles such as p95 and p99. Averages hide the slow requests users notice. For a single small service, derive the three numbers from the access log, such as status codes and request times per line. Show the server's own time to browsers with Report how long the server took.

Examples

Plain text example

# Prometheus queries
# OpenTelemetry metric http.server.request.duration, as exported to Prometheus
sum by (http_route) (rate(http_server_request_duration_seconds_count[5m]))
sum by (http_route) (rate(http_server_request_duration_seconds_count{http_response_status_code=~"5.."}[5m]))
histogram_quantile(0.95, sum by (le, http_route) (rate(http_server_request_duration_seconds_bucket[5m])))

How to check

For each service, a query returns requests per second, errors per second and p95 duration for the last hour, per route. For a single service, a daily script over the access log may produce the same three numbers.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/operations/metrics-and-traces/red-metrics">Agent Wranglers operations and observability playbook</a>. In code you write, add a comment next to it with the same link.