LelantosLelantos
Sandbox

Metrics

Monitor sandbox resources and network usage.

Overview

Lelantos exposes metrics for running sandboxes, allowing you to monitor CPU, memory, disk, and network usage. Use metrics to right-size your templates, detect resource pressure in long-running workloads, and track managed-proxy usage.

Retrieving Metrics

const metrics = await sandbox.getMetrics();
const latest = metrics.at(-1);

if (latest) {
  console.log("CPU count:", latest.cpuCount);
  console.log("Memory:", `${latest.memUsed} / ${latest.memTotal} bytes`);
  console.log("Disk:", `${latest.diskUsed} / ${latest.diskTotal} bytes`);
  console.log("Network up:", latest.bytesUp ?? "unavailable");
  console.log("Managed proxy bytes:", latest.proxiedBytes ?? "none");
}

Metrics Fields

FieldTypeDescription
cpuCountnumberNumber of vCPUs allocated to the sandbox.
memUsednumberMemory currently in use (bytes).
memTotalnumberTotal memory allocated (bytes).
diskUsednumberDisk space currently in use (bytes).
diskTotalnumberTotal disk space allocated (bytes).
bytesUpnumber | nullCumulative guest egress/upload bytes for the session, when available.
bytesDownnumber | nullCumulative guest ingress/download bytes for the session, when available.
networkCounterSourcestring | nullProvenance of the network counters, such as the sandbox netns and TAP device.
proxiedBytesnumber | nullCumulative managed-proxy bytes for the session. This is the billing basis for managed proxy usage.
proxyClassstring | nullManaged proxy class, such as residential or residential-premium.

Example: Formatting Metrics

const metrics = await sandbox.getMetrics();
const latest = metrics.at(-1);

if (!latest) throw new Error("No metrics returned");

const memUsedMB = (latest.memUsed / 1024 / 1024).toFixed(1);
const memTotalMB = (latest.memTotal / 1024 / 1024).toFixed(1);
const diskUsedGB = (latest.diskUsed / 1024 / 1024 / 1024).toFixed(2);
const diskTotalGB = (latest.diskTotal / 1024 / 1024 / 1024).toFixed(2);

console.log(`CPU: ${latest.cpuCount} vCPU`);
console.log(`Memory: ${memUsedMB} MB / ${memTotalMB} MB`);
console.log(`Disk: ${diskUsedGB} GB / ${diskTotalGB} GB`);
if (latest.proxiedBytes != null) {
  console.log(`Managed proxy: ${latest.proxiedBytes} bytes (${latest.proxyClass ?? "unknown"})`);
}

Coming Soon

Real-time CPU usage percentage collection is currently under development. The cpuCount field reports the number of allocated vCPUs, but per-second CPU utilization metrics will be available in a future release.

On this page