> ## Documentation Index
> Fetch the complete documentation index at: https://docs.novita.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox Metrics

Sandbox metrics provide timestamped CPU, memory, and disk utilization data for a sandbox.

## Getting sandbox metrics

Calling the metrics API returns a list of timestamped metric records. Metrics are sampled every 5 seconds.

### Getting sandbox metrics using the SDKs

<CodeGroup>
  ```js JavaScript & TypeScript icon="js" theme={"system"}
  import { Novita } from 'novita-sandbox'

  const novita = new Novita()
  const sbx = await novita.sandbox.create()
  console.log('Created sandbox:', sbx.sandboxId)

  // Allow time for metrics collection.
  await new Promise((resolve) => setTimeout(resolve, 10_000))

  const metrics = await sbx.getMetrics()

  // Alternative by ID:
  // const metrics = await novita.sandbox.getMetrics(sbx.sandboxId)

  console.log('Metrics:', metrics)
  ```

  ```python Python icon="python" theme={"system"}
  from time import sleep
  from novita_sandbox import Novita

  novita = Novita()
  sbx = novita.sandbox.create()
  print('Created sandbox:', sbx.sandbox_id)

  # Allow time for metrics collection.
  sleep(10)

  metrics = sbx.get_metrics()

  # Alternative by ID:
  # metrics = novita.sandbox.get_metrics(sbx.sandbox_id)

  print('Metrics:', metrics)
  ```
</CodeGroup>

### Getting sandbox metrics using the CLI

```bash CLI icon="terminal" theme={"system"}
novita-sandbox-cli sandbox metrics <sandboxID>

# Example output:
# Metrics for sandbox
#
# [2025-07-25 14:05:55Z] CPU: 8.27% / 2 Cores | Memory: 31 / 484 MiB | Disk: 1445 / 2453 MiB
# [2025-07-25 14:06:00Z] CPU: 0.5% / 2 Cores | Memory: 32 / 484 MiB | Disk: 1445 / 2453 MiB
# [2025-07-25 14:06:05Z] CPU: 0.1% / 2 Cores | Memory: 32 / 484 MiB | Disk: 1445 / 2453 MiB
# [2025-07-25 14:06:10Z] CPU: 0.3% / 2 Cores | Memory: 32 / 484 MiB | Disk: 1445 / 2453 MiB
```

Use `--follow` to stream metrics continuously in real time:

```bash CLI icon="terminal" theme={"system"}
novita-sandbox-cli sandbox metrics <sandboxID> --follow
```

Use `--format json` to output machine-readable metrics:

```bash CLI icon="terminal" theme={"system"}
novita-sandbox-cli sandbox metrics <sandboxID> --format json
```

Metrics may not appear immediately after sandbox creation; before the first sample, the response may be empty.
