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

# Monitor and troubleshoot

> Inspect sandbox activity, logs, resource use, and organization audit records.

Open a sandbox in the console to see its activity, system logs, and resource use.
You can retrieve the same information through the SDK.

```python theme={null}
from lithosbox import LithosBox

box = LithosBox()
sandbox = box.sandboxes.get("YOUR_SANDBOX_ID")
```

## Review sandbox activity

```python theme={null}
for event in sandbox.events(limit=20):
    print(event["at"], event["kind"], event.get("detail", ""))
```

Events describe actions such as creation, sleep, snapshots, and archive. They are
returned newest first. Keep the sandbox ID when reporting an issue so its timeline
can be found even after deletion.

## Read system and application logs

Use system logs to investigate startup or an unresponsive environment:

```python theme={null}
print(sandbox.logs(tail_bytes=65536))
```

These logs contain boot output and system messages. They do not replace the output
of your SDK commands. For a command, read `result.stdout` and `result.stderr`; for
a background application, redirect its output to a file and read that file with
`sandbox.files.read()`.

You can read system logs while a sandbox is paused or sleeping without waking it.
Archived sandboxes do not have live system logs. Each call reads up to 256 KiB.

## Inspect resource use

Get recent CPU, memory, and network samples:

```python theme={null}
recent = sandbox.metrics()
for sample in recent["samples"]:
    print(sample["at_unix"], sample["cpu_ms"], sample["mem_mb"])
```

Recent samples cover approximately two hours at 30-second intervals. Use history
for a longer period or for an archived sandbox:

```python theme={null}
history = sandbox.metrics(hours=24)
for point in history["points"]:
    if point.get("measured") is False:
        continue
    print(point)
```

History uses minute intervals and supports up to 15 days. You can also pass
`start` and `end` as RFC3339 timestamps. A point with `measured=false` means a
measurement is missing; it does not mean resource use was zero.

History and events remain queryable after deletion within their retention periods.
Keep an existing `sandbox` handle to query them after deleting it, or use the
[HTTP history endpoint](/reference/http-api#activity-and-metrics) with the saved ID.
Fetching a deleted sandbox with `box.sandboxes.get()` returns `NotFoundError`.

## Review organization usage and audit records

```python theme={null}
usage = box.usage()
audit = box.audit(limit=20)
for record in audit["records"]:
    print(record["at"], record["action"], record["outcome"])
box.close()
```

Use **Console → Usage** to compare resource use over time and **Audit** to review
changes made by members and API keys. Audit records identify the action, resource,
outcome, and request ID. For an issue you cannot resolve, follow the
[support checklist](/launch#support).
