Watching a served golem
Three things help you run golem serve (ADR-064): a /metrics page for Prometheus, a trace id in every log line of a request, and a load test that says how much one container takes. All three are in the gateway, the process that listens on GOLEM_LISTEN. No protocol and no database is involved.
Metrics
GET /metrics is off until you turn it on in your config.toml:
[serve]
metrics = trueWith it off, the path answers 404. With it on, the call needs a key of the app, like /v1 does: Authorization: Bearer gk_.... A missing or revoked key answers 401. The page is the Prometheus text format, and it counts what this one gateway process has seen since it started. With more than one replica, scrape each one.
| Metric | Type | Labels | Is |
|---|---|---|---|
golem_http_requests_total | counter | route, method, status | Requests answered |
golem_http_request_duration_seconds | histogram | route | Time to the response headers. A stream counts until it starts, not until it ends |
golem_runs_started_total | counter | workflow | Runs started through this gateway. A replay of an Idempotency-Key is not a new run |
golem_runs_finished_total | counter | workflow, status | Runs started through this gateway that were seen to end, as completed, failed or canceled |
golem_runs_in_flight | gauge | none | Runs started through this gateway and not yet seen to end |
golem_sse_streams_open | gauge | none | Event streams and streamed chats open now |
golem_limit_refusals_total | counter | limit | Calls refused with 429, by the limit that refused them (requests_per_minute, streams_at_once, runs_at_once, runs_at_once_total, user_usd_per_day, key_usd_per_day) |
golem_daemon_up | gauge | none | 1 when the daemon answers and has a model endpoint (what /readyz checks), else 0 |
golem_build_info | gauge | version | Always 1. The label is the golem version |
Things to know:
- No user id, run id or key is ever a label.
routeis the path template, such as/v1/runs/:id, never the real path. A path that matches nothing isunmatched. - A run is seen to end when a call through this gateway shows its final state: a
GETof the run, a cancel, a resume, or its event stream reaching the end. A run nobody looks at stays ingolem_runs_in_flight. A run that a gateway did not start (one from before a restart, or one started by another replica) is not counted by this one. - The counters start at zero when the gateway starts. Use
rate()andincrease(), as for any counter.
Scrape it
# prometheus.yml
scrape_configs:
- job_name: golem
scrape_interval: 15s
metrics_path: /metrics
authorization:
type: Bearer
credentials_file: /etc/prometheus/golem-key # a file that holds the key and nothing else
static_configs:
- targets: ["golem:8080"]Make a key for it with golem serve keys create --name prometheus. Some questions and the queries for them:
| Question | Query |
|---|---|
| Is it up and ready? | golem_daemon_up == 1 |
| Server errors in the last 5 minutes | sum(increase(golem_http_requests_total{status=~"5.."}[5m])) |
| p95 of one route | histogram_quantile(0.95, sum by (le) (rate(golem_http_request_duration_seconds_bucket{route="/v1/workflows/:name/runs"}[5m]))) |
| Is a limit biting? | sum by (limit) (increase(golem_limit_refusals_total[1h])) |
| Runs that fail | sum by (workflow) (increase(golem_runs_finished_total{status="failed"}[1h])) |
Follow one request
Send a W3C traceparent header, such as 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01. When it is valid:
- the gateway puts its trace id (the second part,
0af7651916cd43dd8448eb211c80319c) in thetrace_idfield of every JSON log line of that request, - the response carries the same
traceparentback, - a run or chat that the request starts keeps the header, and the run's trace shows it.
A header that is not valid is ignored: the request goes on, and there is no trace_id. Every request has an X-Request-Id too, and its log lines carry request_id.
{"ts":"2026-12-01T09:00:00.000Z","process":"gateway","level":"info","msg":"request","request_id":"req_1f0c","trace_id":"0af7651916cd43dd8448eb211c80319c","method":"POST","path":"/v1/workflows/score/runs","route":"/v1/workflows/:name/runs","status":202,"ms":41}The daemon's own log lines do not carry the trace id yet. That is a follow-up.
Load test
just serve-load starts a local golem serve with the fake model (a stub that answers a fixed text, so no model is called and nothing costs money), starts runs of the example workflow, -c at once until -n are done, and follows each run on its event stream. It prints the requests per second, the p50, p95 and p99 of start to finish, the errors, and the peak memory of the gateway and of the daemon. Any error is exit code 1.
just dist # a built tree, once
just serve-load # 20 at once, 200 in all
just serve-load "" -c 5 -n 20 # a small runThe limits in the test config are raised, so the test measures the gateway and the daemon, not the limits. It is not part of just check. CI runs it once small, as a smoke test, and once at the defaults.
Numbers
Measured by CI on the Linux job (ubuntu-24.04, a GitHub-hosted runner), 200 runs, 20 at once, of a workflow with no model call:
| What | Result |
|---|---|
| Machine | ubuntu-24.04 GitHub-hosted runner, Linux x86_64, 4 cpus |
| Requests per second | 216 (600 requests in 2.8 s, 72 runs per second) |
| Start to finish, p50 | 228 ms |
| Start to finish, p95 | 408 ms |
| Start to finish, p99 | 409 ms |
| Errors | 0 |
| Peak memory | gateway 110 MiB, daemon 190 MiB |
A run is three requests: the start, the event stream and one read.
These show the cost of the HTTP layer, the event stream and the daemon's run machinery, with the model out of the picture. A real model call takes seconds and sets the pace of a real app, so read the numbers as the room the container has, not as what your app will do.
Next
- What goes in /app, the
[serve]settings. - Serve API, the calls, limits and errors.