Skip to content

Metrics, logs and usage

There are two sources:

  • Inside the sandbox. The data plane’s sandbox.metrics gives live CPU, memory and disk, once or as a stream.
  • From the API. The client reads a sandbox’s metrics and logs, including those of sandboxes that have ended.
from svm import Sandbox, SandboxClient
client = SandboxClient() # SVM_API_KEY and SVM_DOMAIN from the environment
with Sandbox.create(template="base", client=client) as sandbox:
sandbox.commands.run("echo doing some work")
live = sandbox.metrics.get() # read inside the sandbox
print(f"cpu {live.cpu_used_percent:.0f}% of {live.cpu_count}, "
f"memory {live.mem_used_bytes >> 20}/{live.mem_total_bytes >> 20} MiB, "
f"{live.process_count} processes")
samples = client.get_sandbox_metrics(sandbox.id) # from the control plane
for point in samples["items"][-3:]:
print(point)
logs = client.get_sandbox_logs(sandbox.id, page_size=20)
for line in logs["items"]:
print(line["timestamp"], line.get("stream", ""), line["line"])

client.get_usage(start=, end=, group_by=) returns billed usage in whole one-minute windows that begin at or after start and before end. Pass minute-aligned times to see everything. complete_through in the answer says how far the meter has caught up.

From the CLI: svm sandbox metrics <id> and svm sandbox logs <id> --start 2026-11-01T00:00:00Z.