Skip to main content

Host Metrics

@svendowideit/host-metricsv2026.10.17.1· MIT· 6d agoBEHAVIORSWORKFLOWSACCEPTED WARNINGS
01README

Sample every host in a swamp fleet — disk, network IO, load and memory — and push each sample to the swamp-managed OpenTelemetry system, every 15 minutes. WHAT IT DOES

The missing reporting half of a swamp fleet's host telemetry. It reuses @aaronge/host-health for the local disk (df), load, memory and thermal reads, and adds the two pieces host-health lacks: network IO counters (/proc/net/dev) and an OTLP push. listWorkers materialises the connected worker pool as ordinary data; a scheduled workflow fans a per-host sample out over every worker (dispatched to that worker, so it reads that host's /proc) plus the serve host itself, then emit resolves the OTLP endpoint and bearer token from the @svendowideit/otel-settings contract and POSTs one log record plus gauges — including the change in / free space since the previous sample. Prefer it over per-host scripts or a second metrics agent: the read methods already exist, the fleet list comes from swamp itself, and a host's whole report is one model instance.

INSTALL

swamp extension pull @svendowideit/host-metrics

DEPENDENCIES

@aaronge/host-health (the disk/load/memory/thermal reads this model consumes, pulled separately) and a rendered @svendowideit/otel-settings contract (the otel model) with a reachable OTLP gateway. Linux only (host-health is Linux-only). Without the contract, emit is a no-op that records why.

RUN

# Sample this machine once — network counter, then the fleet report.
swamp model @svendowideit/host-metrics method run readNetwork host-metrics-host
swamp model @svendowideit/host-metrics method run emit host-metrics-host \
  --input healthModel=host-health-host

# List the swamp worker pool as ordinary data (run on the orchestrator).
swamp model @svendowideit/host-metrics method run listWorkers host-metrics-fleet
swamp data query 'modelName == "host-metrics-fleet" && name == "workers"' --select content

# The scheduled pipeline: sample the serve host and every attached worker
# every 15 minutes and push each to OTel (run through `swamp serve`).
swamp workflow run @svendowideit/host-metrics-fleet --server ws://127.0.0.1:9090

CONFIGURE

Global arguments (set at model creation with --global-arg key=value):

  healthInstancePrefix  per-host host-health instance prefix  (host-health-)
  otelModel             @svendowideit/otel-settings model     (otel)
  otelVaultName         vault holding the OTLP bearer token   (empty)
  otelTokenRef          vault/env key for the bearer token    (OTEL_EXPORTER_OTLP_TOKEN)

Method arguments: readNetwork and listWorkers take none. emit takes host, healthModel, endpoint, mesh, otelModel, otelVaultName and otelTokenRef. The @svendowideit/host-metrics-fleet workflow takes otelModel, otelVaultName and otelTokenRef, and reads the worker list from listWorkers.

WHAT IT INSTALLS

Nothing on the host — no services, daemons, cron triggers or webhooks. It reads /proc and calls df through @aaronge/host-health, writes swamp resources, and POSTs to the collector. The schedule is a swamp trigger evaluated by swamp serve.

02Behaviors1
@svendowideit/host-metricsv2026.10.17.1host_metrics.ts

Global Arguments

ArgumentTypeDescription
name?stringModel instance name (supplied by swamp).
healthInstancePrefix?stringPrefix used to derive the per-host @aaronge/host-health instance name
otelModel?stringDefault @svendowideit/otel-settings model for `emit`.
otelVaultName?stringDefault vault holding the OTLP gateway bearer token for `emit`.
otelTokenRef?stringDefault vault/environment key for the OTLP gateway bearer token.
fn listWorkers()
Read the swarm worker pool this orchestrator knows about and write
fn readNetwork()
Read /proc/net/dev and write the `network` resource: per-interface
fn emit(host?: string, endpoint?: string, mesh?: string, otelModel?: string, otelVaultName?: string, otelTokenRef?: string, healthModel?: string)
Push this host's latest filesystems/load/memory/thermal/network
ArgumentTypeDescription
host?stringHost name to attribute the OTLP sample to. Empty detects the local
endpoint?stringOTLP/HTTP base URL overriding both the settings contract and any global.
mesh?stringContract mesh to use for this emit.
otelModel?stringName of the @svendowideit/otel-settings model supplying the contract.
otelVaultName?stringVault holding the OTLP gateway bearer token (empty = none).
otelTokenRef?stringVault/environment key for the OTLP gateway bearer token.
healthModel?stringName of the per-host @aaronge/host-health model instance whose
03Workflows1
@svendowideit/host-metrics-fleet45de2e7d-700f-4e0f-aa20-80a3cd47f502

Sample every host in a swamp fleet — the serve (orchestrator) host and every worker attached to it — and push each sample to the swamp-managed OpenTelemetry system, every 15 minutes. One pass per host: host-health's `readFilesystems` (disk, incl. / free bytes), `readLoad`, `readMemory`, this extension's `readNetwork` (/proc/net/dev IO counters + deltas), then `emit` (one OTLP log record plus gauges, including the change in / free space since the previous snapshot). Fan-out: `listWorkers` mater

discoverMaterialise the connected worker pool as ordinary data.
1.list-workers— Read the worker pool the orchestrator knows about.
workersSample each connected swamp worker on its own host.
1.read-filesystems— Read disk usage (incl. / free bytes) on each worker.
2.read-load— Read load averages on each worker.
3.read-memory— Read memory usage on each worker.
4.read-network— Read /proc/net/dev network IO counters on each worker.
5.emit— Push each worker's sample to the OTel collector.
serve-hostSample the serve (orchestrator) host itself, locally.
1.read-filesystems-local— Read disk usage (incl. / free bytes) on the serve host.
2.read-load-local— Read load averages on the serve host.
3.read-memory-local— Read memory usage on the serve host.
4.read-network-local— Read /proc/net/dev network IO counters on the serve host.
5.emit-local— Push the serve host's sample to the OTel collector.
04Stats
A
100 / 100
Downloads
4
Archive size
23.6 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License2/2earned
  • Verified public repository2/2earned

06Platforms