Adventure Labs Logo
Scout Docs

Health metrics

Table for device health metrics (CPU, memory, storage, etc.); one row per metric per timestamp

Column NameData TypeConstraints
idbigintNOT NULL (generated)
timestamptimestamp with time zoneNOT NULL
device_idbigintNOT NULL
sourcetext
metric_nametextNOT NULL
valuedouble precisionNOT NULL
unittext
created_attimestamp with time zoneDEFAULT clock_timestamp() NOT NULL

Indexes

  • idx_health_metrics_lookup on (device_id, metric_name, timestamp DESC) for device lookups and time-ordered queries.

Foreign keys

  • device_id → devices(id) ON UPDATE CASCADE ON DELETE CASCADE

Security Policies (RLS)

RLS enabled. Herd scope: Herd from health_metrics.device_id → get_herd_id_by_device_id.

Operationhas_herd_ability ability keyOther paths
SELECTtelemetry.readOwning device API key; approved gateway in herd
INSERTtelemetry.writeOwning device API key; approved gateway in herd
UPDATEtelemetry.writeOwning device API key; approved gateway in herd
DELETEtelemetry.writeOwning device API key; approved gateway in herd

Platform superadmin: FOR ALL bypass where defined.

  • get_health_metrics_summary(p_device_id bigint, p_lookback_minutes integer DEFAULT 60) — returns per-metric min, max, avg, and count over the lookback window. Uses SECURITY INVOKER (RLS applies).

Metric names

Use snake_case; add new metrics by using new metric_name values (no migration). Examples: cpu_usage_percent, memory_usage_percent, storage_used_gb, disk_usage_percent, cpu_temperature_c, uptime_seconds.

On this page