Skip to content

Sandbox metrics

getMetrics and get_metrics return timestamped samples for CPU, memory, and disk usage. A newly started sandbox may not have a sample immediately.

mjs
import { Sandbox } from "@abox-dev/sdk";

const sandbox = await Sandbox.create();

try {
  await new Promise((resolve) => setTimeout(resolve, 10_000));
  const metrics = await sandbox.getMetrics();
  console.log(`Metric samples: ${metrics.length}`);
  if (metrics.length > 0) console.log(metrics.at(-1));
} finally {
  await sandbox.kill();
}

Each sample includes CPU usage and count, used and total memory, used and total disk space, and a timestamp. Values for memory and disk are bytes.

Use the Sandbox SDK reference for time range options and static access by sandbox ID.