At the end of part 4, the only way to see what steer was doing was to read its log, one line at a time. So phase 5 adds Prometheus metrics.
The first thing I did with them was rerun part 4’s slow-backend test and ask Prometheus for the p99. It said 492.5 ms. Steer’s own logs said 302 ms. Nothing was broken. The p99 Prometheus shows you is an estimate, and with the default settings it was 63% too high.
That matters because many SLOs, latency alerts and Grafana panels are built on this estimate. An alert on “p99 over 400 ms” would have paged me, even though no request in those runs took longer than 306 ms.
what steer exports now Link to heading
Six metrics, on their own port (:2112/metrics), since every path on steer’s main port goes to a backend:
steer_requests_totalandsteer_request_duration_seconds: what clients saw, once per request.steer_backend_requests_totalandsteer_backend_request_duration_seconds: what each backend did. A retried request counts once per backend it tried.steer_backend_in_flightandsteer_backend_up: phase 4’s in-flight count and phase 3’s health flag, read fresh each time Prometheus asks.
The log moved to Go’s log/slog, which can write one JSON object per line:
{"time":"2026-11-28T19:55:57.384199-06:00","level":"INFO","msg":"request","method":"GET","path":"/r15","status":200,"backend":"http://localhost:8083","attempts":1,"duration_ms":301.514}
That duration_ms is the exact duration of every request, which is what I checked Prometheus against.
the experiment Link to heading
The same setup as part 4: three backends on my laptop, 8083 sleeping 300 ms before every response, and 600 requests through steer, 10 at a time, with round robin. A real Prometheus (v3.5, in Docker) scraped steer every second. After each run I asked it for the percentiles:
histogram_quantile(0.99, sum by (le) (steer_request_duration_seconds_bucket))
Then I worked out the real percentiles from the 600 duration_ms values in the log. Three runs:
| Prometheus said | exact, from the logs | |
|---|---|---|
| p50 | 3.75–3.77 ms | 0.24–0.27 ms |
| p90 | 425 ms | 301.3 ms |
| p99 | 492.5 ms | 302.0–302.5 ms |
| average | 100.53–100.56 ms | 100.53–100.56 ms |
The p99 was 492.5 ms in all three runs, the same to the decimal. A real measurement wobbles a little from run to run. This one didn’t move at all.
why: a histogram only counts Link to heading
A Prometheus histogram doesn’t store durations. It stores counters, one per bucket: how many requests took up to 5 ms, up to 10 ms, and so on. Here’s what steer exported after run 1:
steer_request_duration_seconds_bucket{le="0.005"} 398
steer_request_duration_seconds_bucket{le="0.01"} 400
...
steer_request_duration_seconds_bucket{le="0.25"} 400
steer_request_duration_seconds_bucket{le="0.5"} 600
(le means “less than or equal to”, in seconds. These are Prometheus’s default buckets, which go from 5 ms to 10 s.)
That’s all Prometheus knows about the slow requests: 200 of them took somewhere between 250 and 500 ms. To get a p99 out of that, histogram_quantile finds the 594th request out of 600. That’s the 194th of the 200 in that bucket. It can’t see inside the bucket, so it assumes the requests are spread evenly across it. 194 out of 200 is 97% of the way from 250 to 500 ms: 492.5 ms.
The real requests were all bunched up at the bottom of the bucket:

The p50 is wrong for the same reason. 398 fast requests were somewhere between 0 and 5 ms, so Prometheus put the median 75% of the way up that range, at 3.77 ms. It was actually a quarter of a millisecond.
The average is exact, though. Next to the buckets, a histogram also keeps _sum and _count, and those are real totals, so _sum / _count is the true average. In my histograms post the average was the number that lied. Here it was the only one that didn’t.
the fix: put the boundaries where your latencies are Link to heading
So I added a -latency-buckets flag to steer and reran it with boundaries close to where my requests actually landed: fine steps under a millisecond for the fast ones, and 25 ms steps around 300 ms for the slow ones.
-latency-buckets 500us,1ms,2.5ms,5ms,10ms,25ms,50ms,100ms,250ms,275ms,300ms,325ms,350ms,400ms,500ms,1s,2.5s
Three more runs:
| Prometheus said | exact, from the logs | |
|---|---|---|
| p50 | 0.39–0.41 ms | 0.24–0.28 ms |
| p90 | 317.5–317.6 ms | 301.3–301.4 ms |
| p99 | 324.2–324.4 ms | 301.7–305.1 ms |
Much closer, but still not right: the slow requests now sit in a 25 ms bucket instead of a 250 ms one, and the estimate still lands near the top of it. Better buckets shrink the error. They can’t remove it.
The buckets aren’t free. Every bucket is its own time series, for every backend. My 17 buckets cost more than the default 11, and that multiplies with every label you add.
the question a histogram answers exactly Link to heading
There’s one question a histogram can answer with no guessing: how many requests were faster than one of its boundaries? I asked:
sum(steer_request_duration_seconds_bucket{le="0.25"}) / sum(steer_request_duration_seconds_count)
It said 0.667 in all six runs, with either set of buckets. That’s exactly 400 out of 600, which matches the logs.
That changes how I’d write a latency SLO. “p99 under 300 ms” is checked with an estimate. “99% of requests under 300 ms”, with a bucket boundary at exactly 300 ms, is checked with a count. If the threshold you care about is a bucket boundary, you don’t need histogram_quantile at all. It’s the same bad-requests-over-total-requests ratio that Ithildin uses for availability, with “slower than 300 ms” counting as bad instead of “returned a 5xx”. (More on SLOs themselves in my SLO primer.)
things that surprised me Link to heading
- The per-backend p99 was wrong too, but it still pointed at the right backend. It said 497.5 ms for 8083 and about 5 ms for the others. Even a bad estimate tells you which backend to look at.
- Under least connections, the real p99 jumped between 3 ms and 301 ms from run to run. 6 or 8 of the 600 requests went to the slow backend: exactly 1%, or a little over. When about 1% of requests are slow, p99 is a coin toss, whatever tool calculates it.
- Round robin left nearly every request in flight on the slow backend. During each run, the in-flight gauge showed 7 to 10 of the 10 requests sitting on 8083 at every scrape, and 0 on the others. Each backend got the same number of requests, but not the same load. That’s its own post.
things I’m still not sure about Link to heading
- Would native histograms make this go away? Prometheus has a newer kind of histogram, called a native histogram, that picks lots of small buckets automatically. I’d like to rerun this with one and see how close it gets, and what it costs.
- How do teams pick buckets in practice? Mine fit this test because I knew the answer in advance. If 8083 got slower, it would drift out of my fine buckets and the estimate would get worse again.
Next is phase 6, timeouts, for a backend that takes a request and never answers.
The code is at github.com/balakrishnan-vasudevan/steer. The data, the experiment script and the chart script are in static/charts/steer-metrics/.