Sandbox
Metrics
Monitor sandbox CPU, memory, and disk usage.
Overview
Lelantos exposes resource metrics for running sandboxes, allowing you to monitor CPU, memory, and disk utilization. Use metrics to right-size your templates or detect resource pressure in long-running workloads.
Retrieving Metrics
const metrics = await sandbox.getMetrics();
console.log("CPU count:", metrics.cpuCount);
console.log("Memory:", `${metrics.memUsed} / ${metrics.memTotal} bytes`);
console.log("Disk:", `${metrics.diskUsed} / ${metrics.diskTotal} bytes`);Metrics Fields
| Field | Type | Description |
|---|---|---|
cpuCount | number | Number of vCPUs allocated to the sandbox. |
memUsed | number | Memory currently in use (bytes). |
memTotal | number | Total memory allocated (bytes). |
diskUsed | number | Disk space currently in use (bytes). |
diskTotal | number | Total disk space allocated (bytes). |
Example: Formatting Metrics
const metrics = await sandbox.getMetrics();
const memUsedMB = (metrics.memUsed / 1024 / 1024).toFixed(1);
const memTotalMB = (metrics.memTotal / 1024 / 1024).toFixed(1);
const diskUsedGB = (metrics.diskUsed / 1024 / 1024 / 1024).toFixed(2);
const diskTotalGB = (metrics.diskTotal / 1024 / 1024 / 1024).toFixed(2);
console.log(`CPU: ${metrics.cpuCount} vCPU`);
console.log(`Memory: ${memUsedMB} MB / ${memTotalMB} MB`);
console.log(`Disk: ${diskUsedGB} GB / ${diskTotalGB} GB`);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.