reference

Metrics

Daemon Prometheus scrape endpoint and per-sandbox guest stats history on the host.

Two related surfaces:

  1. Prometheus text at GET /metrics (daemon-wide counters/gauges)
  2. Per-sandbox guest history on the host (metrics.ring under each VM dir), sampled in the background and shown in Desktop

Prometheus endpoint

When TCP API is enabled (default api: 127.0.0.1:7474):

bash
curl -s http://127.0.0.1:7474/metrics

Also available on the unix socket:

bash
curl -s --unix-socket ~/.grain/grain.sock http://grain/metrics

Series

Names may grow; common series:

MetricMeaning
grain_vms_created_totalVMs created
grain_vms_deleted_totalVMs deleted
grain_vms_runningRunning VM count (gauge-style; scrape carefully)
grain_create_errors_totalFailed creates

Optional compose stack for Prometheus/Grafana: deploy/observability/ (just obs-up).

Guest stats history (host-side ring)

By default, new sandboxes enable host-side metrics (sandbox_metrics_enabled: true in config). The daemon samples guest /stats on an interval into:

text
~/.grain/vms/<name>/metrics.ring
Config keyDefaultMeaning
sandbox_metrics_enabledtrueDefault for new creates
sandbox_metrics_interval15sSample period
sandbox_metrics_points5760Ring capacity (~24h at 15s)

Per-create override: create body / Desktop checkbox metrics_enabled. History remains readable after disable. Background sampling runs while the daemon is up (not only when Desktop polls).

Desktop: inspector overview charts when history exists. API: GET /vms/{name}/metrics (when implemented by the daemon route for Desktop).

Control-plane activity (create/start/stop/…) is a separate ring at data_dir/activity.json, exposed as GET /activity. See HTTP API and Desktop activity.

Logging

Daemon logs are structured JSON on stderr with grain up --fg. Create and pool claim paths log timing lines (create timing, pool claim timing, spawn timing) at INFO for latency debugging.