Skip to content

Prometheus metrics

Holotable exports Prometheus metrics from GET /api/metrics. Everything it exposes is state the server already keeps in memory — how long a poller tick takes, how long a metrics query runs, how many browsers are attached to a dashboard, what the model costs, what the SQL guard rejects — so a scrape does no I/O and needs no timeout of its own.

The endpoint is closed until you configure it. With neither METRICS_TOKEN nor METRICS_ALLOWED_CIDRS set it answers 404.

A scraper holds no session cookie, so /api/metrics sits outside the normal authorization path and has a gate of its own (src/lib/metrics-access.ts).

METRICS_TOKEN METRICS_ALLOWED_CIDRS Requirement
unset unset 404 — the endpoint is disabled
set unset Authorization: Bearer <token>
unset set The request’s source address is in the list
set set Both

Set both and they are ANDed, never ORed. That is deliberate: the address check reads X-Forwarded-For, and a header a client can write must never be able to stand in for the token.

METRICS_ALLOWED_CIDRS is a comma- or space-separated list of IPv4/IPv6 addresses and CIDR ranges — 10.0.0.0/8, 192.168.1.5, fd00::/8, ::1. An IPv4-mapped IPv6 address (::ffff:10.0.0.1, how a dual-stack listener reports an IPv4 peer) is folded to IPv4, so one entry covers both forms. An entry that does not parse stops the server from booting rather than silently narrowing the list.

The address itself is taken from the last X-Forwarded-For hop, falling back to X-Real-IP. A proxy either overwrites that header with the peer it observed or appends that peer to whatever arrived, so in both cases anything a client injected sits to its left. If the app is reachable without a proxy in front of it, the address check means nothing — use METRICS_TOKEN.

Terminal window
# Generate a token
openssl rand -hex 32
# Scrape it
curl -H "Authorization: Bearer $METRICS_TOKEN" http://localhost:3000/api/metrics

Startup validation warns in production when a CIDR allowlist is configured without a token, and when a token is shorter than 24 characters. See Startup validation.

All application metrics carry the holotable_ prefix, as do the default process and Node.js collectors (holotable_process_cpu_seconds_total, holotable_nodejs_heap_size_used_bytes, …).

Metric Type Labels Meaning
holotable_poller_tick_duration_seconds histogram dashboard Wall time of one poller tick, across every panel on the dashboard
holotable_query_duration_seconds histogram source, outcome One guarded query, including connect and rollback. outcome is ok or error
holotable_query_rows histogram source Rows returned by one guarded query. Not observed for a failed statement
holotable_sse_subscribers gauge dashboard Browsers attached to a dashboard’s stream on this instance
holotable_pollers_active gauge — Pollers running on this instance
holotable_pollers_limit gauge — The most pollers this instance runs before a new stream is told to retry: MAX_POLLERS, or derived from the heap. Against pollers_active, the headroom; see Sizing
holotable_llm_tokens_total counter workspace, model, direction Tokens billed to a workspace. direction is input or output
holotable_llm_requests_total counter route, outcome Model requests at the admission gate. outcome is admitted, rate_limited, over_budget or busy (the in-flight cap, LLM_MAX_IN_FLIGHT)
holotable_chat_panels_total counter outcome Panels an Explore turn asked to draw: accepted, refused (by the IR, the guard or the source) or repaired (the spec failed its schema and the one re-ask fixed it; the repaired spec is then counted again as accepted or refused)
holotable_llm_repairs_total counter route, outcome Structured-output repairs: one automatic re-ask after a generation failed its schema. outcome is repaired or failed. See AI provider
holotable_sql_validation_rejections_total counter reason Statements refused by the SQL guard
holotable_promql_validation_rejections_total counter reason Expressions refused by the PromQL guard
holotable_logql_validation_rejections_total counter reason Expressions refused by the LogQL guard. reason adds stage (a pipeline stage off the allowlist) to the PromQL guard’s set
holotable_audit_write_failures_total counter — Audit log rows lost because they could not be written. Anything above zero is a gap in audit_log; see the audit log
holotable_pool_wait_seconds histogram source Time a query waited for a connection from its source’s pool, failed or not. Healthy: near zero. Rising: the pool (MAX_POOL_PER_SOURCE) is the limit
holotable_pool_in_use gauge source Connections checked out of a source’s pool. Healthy: below MAX_POOL_PER_SOURCE. Pinned at it: queries queue, and pool_wait_seconds rises next
holotable_poller_skips_total counter reason Panel executions a poller skipped for one cycle: in_flight_cap (no free poller slot on the source, MAX_POOL_PER_SOURCE - 1) or pool_wait (a checkout timed out in a full pool). Healthy: zero. Steady: the source cannot keep up with the dashboards’ refresh
holotable_sse_bytes_total counter — Bytes written to dashboard streams. Its rate is the stream’s share of egress; a jump means a panel started sending full results
holotable_sse_drops_total counter reason Streams the server closed: slow (behind for SSE_SLOW_TICKS cycles). Healthy: zero or rare. Steady: a proxy is buffering, or clients cannot keep up
holotable_result_truncations_total counter stage Results cut short on the server: rows (MAX_QUERY_ROWS), points (a PromQL step PROMQL_MAX_POINTS widened), entries (a Loki log query that returned its whole limit), window (a Chat panel held to MAX_WINDOW_POINTS). Each is also a badge on the panel. Steady: a query to narrow or a cap to raise
holotable_llm_in_flight gauge model Model requests running now. Predicts the model concurrency limit (#496)
holotable_retention_deleted_total counter table Rows the retention sweep deleted

reason comes from a fixed enum, not the error message: empty, structure, comment, keyword, function, time, catalog, column, variable (SqlRejectionReason in src/lib/metrics.ts); for PromQL, empty, structure, function, time, catalog, bounds, variable (PromqlRejectionReason). The message names the offending table, metric, column or function and is therefore attacker-influenced text; only the reason is safe as a label. A dry run is not counted: the check behind the “hide this column?” warning asks the guard about a catalog nobody has saved, through the uncounted checkSql.

Two of these are per-instance, not per-deployment. holotable_sse_subscribers and holotable_pollers_active count what this process is doing, because the poller is per-process — see Scaling and the poller. Sum across instances; do not expect one instance to know the whole picture. One instance is the supported topology, so in practice the two are the same.

A metric label that can take unboundedly many values turns a scrape into an outage, so:

  • No user-supplied text is ever a label. Not SQL, not a prompt, not an error message, not a panel title.
  • dashboard, source, workspace and model are opaque ids passed through a cap of 500 distinct values per label. Everything past the cap is reported as other, so the scrape stays a fixed size however many ids the process has seen.
  • A dashboard’s series is dropped when its poller stops, so an instance does not accumulate one gauge per dashboard that ever existed.

docker-compose.yml runs a Prometheus service with its prometheus profile (#390). It scrapes the app with METRICS_TOKEN, the same value the app checks:

Terminal window
echo "METRICS_TOKEN=$(openssl rand -hex 32)" >> .env
docker compose --profile prometheus up -d

Prometheus is then on http://localhost:9090, scraping app:3000/api/metrics every 15s with 6 hours of retention. The seeder registers it as the prometheus-self source once it answers, which the PromQL self-monitoring dashboard reads.

If METRICS_TOKEN is unset, compose falls back to a checked-in local default so that the self-monitoring collector below still works out of the box. That default guards a scrape on the compose network and nothing else; set a real one for anything reachable from outside it.

The default docker compose up also runs self-metrics, which scrapes this endpoint into a TimescaleDB hypertable and registers it as an ordinary source, so the shipped Holotable self-monitoring dashboard is guarded SQL over the metrics above. With the prometheus profile, its twin, Holotable self-monitoring (Prometheus), asks the compose Prometheus the same questions in PromQL through the prometheus-self Prometheus source. See Demo data for the collector, both dashboards, and the end-to-end smoke test built on them.

A Kubernetes deployment scrapes the same endpoint; put the token in a Secret and reference it from the ServiceMonitor’s bearerTokenSecret, or restrict the port and use METRICS_ALLOWED_CIDRS instead.


Last verified against the code at commit 00ea858 (2026-10-05).