llm-watch

Live llama.cpp and GPU status for apollo

RouteMethodsWhat
/ GET
/api/containers GET What else is running on apollo, so "what is this machine doing" has a full answer.
/api/current GET The one thing the dashboard most needs and /metrics cannot answer: what now?
details
Reuses collect(), so it shares the 2 s cache with the page and the sampler and
answers from exactly the log lines and /slots the snapshot read.
/api/live GET The last 30 minutes of speed, context and reply size, one point every 2 s.
details
The data behind the page's top chart, for drawing the same graph elsewhere.

Query parameters (all optional):
  since=<epoch seconds>  only points newer than this; poll with the last t you have
  minutes=<n>            only the last n minutes (1-30)

Each point: t (epoch s), pp and gen (tok/s, 0 when not doing that), ctx (tokens in
the slot while a task runs, 0 when idle, null when llama is unreachable -- draw a
gap), reply (tokens generated so far in the current reply, 0 when idle), action,
task (the task id from /slots while the server reports one, else the log's),
cached (prompt tokens served from the KV cache; 0 when idle, null when unreachable
or when the build does not report it), processed (prompt tokens actually read; same
rules) and pwr (GPU power in W, null when the GPU is unavailable -- draw a gap).
cached and processed follow ctx's idle/outage rules, so they line up with it on
the chart: the gap between the cached band and the context line is what was read.

`tasks` lists every task in the window, in full on every call: each has start and
end (the t of its first and last point), cached/ctx/cache_pct taken at its first
point with context (cache_pct under 50 is a cache miss), and, once the task has
finished, accept_pct/accepted/drafted/mean_len from the log's draft acceptance
line and prompt_tokens/prompt_tps from its prompt done line. Polling with `since`
must not filter them: a task's draft line appears only after its last point.

`series` gives label, unit, kind, colour and max for each key, so a client needs
no constants from this repo. `area` and `line` are meant to be drawn on their own
scale, except `reread`, drawn on ctx's scale; `task` (draft) is drawn from
`tasks`, not from points, on a fixed 0-100 scale.
/api/llama-log GET The tail of llama.cpp's own log.
details
The server narrates what it is doing -- slot timings, draft acceptance, cache
behaviour -- in far more detail than any metric exposes, and reading it is how you tell
a slow request from a stuck one.
/api/summary GET What the model is doing right now, in one small object, for a header chip.
details
state is `busy`, `idle` or `down` (llama unreachable). While busy, activity is
`reading`, `generating` or `working`; gen and pp are tok/s over the last 6 s, ctx and
ctx_max are tokens, pwr is GPU watts (null when unknown), model is the loaded file.
Busy means a task in the slot within 6 s, or the GPU above LLM_WATCH_BUSY_W (100 W),
so a chip does not flicker between an agent's back-to-back tasks. CORS open.
/api/usage GET Usage over time. `hours` (default 24) selects the window in hours,
details
`bucket` (default 60) the bucket in minutes.

This is the series behind the chart, and the one cm-coder queries for raw numbers.

Each bucket, and `totals`, has ctx_peak and ctx_mean: the highest and the mean
context in the slot (the prompt of the request in flight, in tokens) over the 2 s
points that had a task running. null when no task ran, or for history recorded
before 2026-10-28, when context was not kept.
/changelog GET What changed, day by day, newest first: the app's changelog, written for users.
details
The top heading is the current version, the one /version reports. A trailing
(#n) in a bullet links to that pull request.
/docs GET
/embed GET The Live chart alone, to show in another app's page (an iframe).
details
The same chart as `/` -- same code, legend toggles and 3/5/10/30 min buttons --
without the rest of the dashboard. `?theme=light|dark` forces a theme; without it
the page follows the browser's. Meant to be framed: no frame-blocking header.
/health GET Liveness of this app. 200 even when the model is offline -- read `llama` to tell.
/status GET Everything in one object: model, slot, speed, speculative decoding and GPU.
/version GET Which commit this instance is running, and how long it has been up.
details
`version` is the top heading of CHANGELOG.md (the date it was written), so it
says what this code set can show.

`sha` is baked in at build time; "unknown" means a local run rather than a deploy.