Skip to main content
Labels are key=value pairs you attach to a sandbox to organize it. They let you act on many sandboxes at once with a single command, and break metrics down by whatever dimension you choose, such as user, tenant, or job.

Keys

Label keys cannot start with the reserved prefixes sandbox., microsandbox., or service.. Those namespaces belong to the runtime, which sets attributes under them itself and rejects any sandbox you try to create with a label key that uses one. Values may be empty. A valueless label such as --label gpu is stored as gpu="", matching Docker’s label semantics. Use empty values for marker labels, and use explicit values when you need filtering or metrics dimensions such as user.id=alice or tenant=acme.

Add at create time

Attach labels when you create a sandbox. Labels are repeatable, and a bare key with no value is allowed:
microsandbox imports the OCI image’s own labels (LABEL instructions, org.opencontainers.image.*, etc.) automatically at create time. A label you set yourself overrides the image’s value on a key collision. microsandbox skips image labels that use a reserved prefix.

Change while running

Add, change, or remove labels without recreating the sandbox:

Select in bulk

This is where labels earn their keep. Find every sandbox carrying a label, from the CLI or an SDK; pass more than one label to require all of them (AND-matched):
On the CLI, --label also drives the fleet commands directly, so you act on the whole group in one call instead of listing and looping:
It works the same on ps, ls, start, stop, restart, ping, touch, and rm.

Attribute metrics

Labels flow into a sandbox’s metrics as dimensions, so you can break CPU, memory, and I/O down by any label you set, for example per user or per tenant. See Labels and per-user views for the PromQL detail. High-cardinality labels can increase the number of metric series your backend stores. Suppose an image label carries a commit SHA, build timestamp, or other noisy value. Run msb-metrics with --exclude-label-key <key> to drop that label from exported metrics while keeping it in the catalog. Use --no-labels to disable metric labels entirely.

Reference

For exact label and sandbox-selection APIs, see TypeScript, Rust, Python, or Go. For label-aware fleet commands, see Sandbox commands.