Metrics and usage
A miniVM’s metrics
Section titled “A miniVM’s metrics”Each running miniVM is sampled every 10 seconds: CPU, memory and disk. Samples are kept for 7 days.
ons metrics <minivm-id><minivm-id> is the id ons create printed (ons ls lists yours).
--since <seconds>sets how much history to show (default 300).--watchkeeps printing new samples until you press Ctrl-C. With--json, it prints one JSON object per line.
from e2b import Sandbox
sbx = Sandbox.connect("<minivm-id>")for m in sbx.get_metrics(): print(m.timestamp, m.cpu_used_pct, m.mem_used, m.mem_total)import { Sandbox } from 'e2b'
const sbx = await Sandbox.connect('<minivm-id>')for (const m of await sbx.getMetrics()) { console.log(m.timestamp, m.cpuUsedPct, m.memUsed, m.memTotal)}Set E2B_DOMAIN=onshore.sh and E2B_API_KEY before you run the SDK examples. See Migrate from E2B.
What each field means
Section titled “What each field means”| Field | Meaning |
|---|---|
cpuCount |
vCPUs of the miniVM. |
cpuUsedPct |
CPU use, in percent of its vCPUs. |
memUsed |
Memory the guest uses: MemTotal - MemAvailable. |
memTotal |
The miniVM’s memory. |
diskUsed, diskTotal |
Used and total size of the root disk. |
timestamp |
When the sample was taken. |
From the REST API
Section titled “From the REST API”curl -s -H "X-API-Key: $ONS_API_KEY" "https://api.onshore.sh/sandboxes/<minivm-id>/metrics?start=<unix-start>&end=<unix-end>"<unix-start>and<unix-end>are Unix times in seconds. Leave both out for all 7 days.- It returns at most the newest 1000 samples, oldest first.
GET /sandboxes/metrics?sandbox_ids=<id-1>,<id-2>returns the newest sample of each listed running miniVM (up to 100 ids).
You only see the metrics of miniVMs your key created; any other id answers 404.
Your organization’s usage
Section titled “Your organization’s usage”In the console, open Usage. It shows the last 30 days, per day: vCPU-hours, memory GiB-hours and the number of miniVMs. Fleet shows your running and paused miniVMs, their size and how long they ran.
What you pay for this usage is on Billing: your balance, the credit ledger and invoices. See Billing and Pricing.