GET /v2/ai/sandboxes/{sandbox_id}/metrics returns the latest sample and a per-minute series for a time range.
The metrics currently cover CPU, memory, disk, and network. GPU usage isn’t reported yet:
gpus is always null.--since sets the range’s length before --to or now, and --json prints the data object of the response below.
A range spans at most 24 hours. An invalid range is
400. Metrics are kept for 30 days.
Response
latestis the most recent sample, taken every 15 seconds;nullif there is none yet.serieshas one point per minute (step_secondsis always 60), starting at the minute. It is empty where nothing is stored.
Sources
CPU (cpu_cores, cpu_cores_avg, cpu_cores_max) and network (net_rx_bytes, net_tx_bytes) are measured on the host, outside the sandbox. Disk (disk_bytes) is the bytes used on /data, also measured outside the sandbox, every one to two minutes; it doesn’t include the root filesystem. Memory (mem_bytes, mem_bytes_avg, mem_bytes_max) is reported from inside the sandbox. Memory and disk are for display only: billing uses the sandbox’s requested resources, never these numbers. Each is null for a period in which it wasn’t measured.
Field Notes
- CPU is in cores, for the whole sandbox VM including its virtualization overhead. A busy sandbox can read above its
cpu, by up to 1 core.latest.cpu_coresis the average since the previous sample;cpu_cores_maxis the busiest interval between two samples in the minute. - Memory is in bytes: what’s in use inside the sandbox, meaning its processes, page cache in active use, and what it keeps in memory, such as files in
/dev/shmand the kept output of its execs. It isn’t the sandbox VM’s total.latest.mem_bytesis the latest sample;mem_bytes_avgandmem_bytes_maxare the average and the highest of the minute’s samples (about every 15 seconds). - Network counts bytes received (
net_rx_bytes) and sent (net_tx_bytes): since the previous sample inlatest, and within the minute inseries. After a gap in measurement, the gap’s bytes are in the first minute measured after it. - A sandbox’s last few seconds, and a sandbox that lives less than about 15 seconds, may not be measured.