Skip to content

feat: add the sparkline bar format, rename bar to gauge - #165

Merged
outofcoffee merged 7 commits into
mainfrom
metrics-graph
Sep 6, 2026
Merged

feat: add the sparkline bar format, rename bar to gauge#165
outofcoffee merged 7 commits into
mainfrom
metrics-graph

Conversation

@outofcoffee

Copy link
Copy Markdown
Collaborator

A 0-100% sparkline of the last 10 minutes for each metrics series, selectable as bar; the previous filled-bar drawing survives as gauge.

Summary

  • The daemon retains a rolling 10-minute history of system readings (CPU, RAM, GPU utilisation and memory), sampled at the existing 15-second sampler cadence while the engine runs; exposed on /v1/metrics, persisted across an engine stop, cleared on the next start
  • --format=bar (the default) now draws that history as a sparkline, with the latest point coloured on the 80/90 thresholds; where a daemon reports no history it draws the current reading in the gauge style, so pre-history daemons render exactly as they do today
  • New --format=gauge keeps the previous filled-bar drawing for remote metrics and fleet metrics
  • The fleet dashboard's g key toggles every tile between bar and gauge; it opens in bar
  • The remote stats Lambda relays the daemon's history unaltered; JSON output and docs/openapi.yaml carry the new field

Implementation details

  • The history lives in the daemon rather than the clients, so one-shot, watch, dashboard, and remote views all read the same window from a single read; one-shot bar works because the history is server-side
  • Samples store 0-100% figures rather than raw byte counts: the remote path relays the daemon's reply over SSM, whose output truncates at 4KB, and 40 samples at 15s fit comfortably as percentages but not as raw memory figures
  • Downsampling takes the maximum per column, so a spike survives compression to the tile width
  • OpenSpec change: openspec/changes/metrics-graph

@outofcoffee outofcoffee added enhancement New feature or request go Pull requests that update go code labels Sep 5, 2026
The daemon keeps one system reading per sampler tick for the last ten
minutes and reports them on /v1/metrics; the buffer clears on the next
engine start and a stopped engine keeps its readings to the stop.
remote metrics, fleet metrics and the dashboard draw the readings as a
bar, one block glyph per reading with the last point coloured on the
80/90 thresholds; a series with no retained readings falls back to the
old drawing, renamed gauge, so a daemon that predates the history
renders as it did.

The stats Lambda relays the history through unaltered, and the
dashboard toggles between the two formats board-wide on g.
The loop reads the cadence on every tick while it has no reading to
report, and a daemon with no scrape target never gets one, so the
restore ran against a running sampler. Cancel and wait for the sampler
to exit first.
At the tile's draw width a 29- or 30-sample window splits unevenly,
and the split's rounding can leave the newest reading outside the
final pool — so the line and its trailing figure drew one sample
behind. The final column now takes the series to its end, which the
arithmetic otherwise guarantees.
…s edge cases

fleet metrics now draws a node's retained history, a stopped node's
history alone, and the per-series gauge fallback, through the command
itself; statsFromRemote is checked to relay the history unaltered and
to keep an absence an absence. The renderer's tests add the
29-sample-at-tile-width regression, a GPU present in only some
samples, a gauge value beyond 100, and a memory reading with no
total.
@outofcoffee
outofcoffee merged commit 8c9027d into main Sep 6, 2026
3 checks passed
@outofcoffee
outofcoffee deleted the metrics-graph branch September 6, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant