# Diagnostics

Settings → Diagnostics shows the state of every part of the running
workstation, read from it when the page opens or on **Check again**.
Nothing is cached or guessed: each check asks the component itself.
**Copy report** puts the whole report on the clipboard as JSON, ready to
paste into a bug report.

| Check | What it reads | States |
|---|---|---|
| Database | A query against the database | ok, failing when it does not answer |
| Schema migrations | The migration the database is at, against the newest one the code ships | ok, failing when the database is behind (run the migrations), warning when the scripts cannot be read |
| File storage | A small file written to the storage root and removed | ok, failing when it cannot be written |
| Disk space | Free and total space on the storage disk | ok, warning under 1 GiB or 5% free |
| Scan workers | Workers alive against those configured, scans queued and running | ok, failing when a worker stopped |
| Background tasks | The Agent Bridge sweeper and the task that removes a deleted vault's files | ok, failing when one stopped |
| Proxy listener | Whether the proxy listens, and its last error | ok, off when stopped on purpose, failing on an error |

The overall state is the worst check; a stopped proxy does not count.

The same report is served at `GET /api/v1/system/diagnostics`. It names
local paths and the platform, so it is for the user only: a request
that comes through an agent transport (a bearer token or MCP headers) is
refused. Agents read `system_info` instead. `GET /api/v1/system/health`
stays a plain liveness probe for the launcher and Docker.

## Metrics

`GET /api/v1/system/metrics` serves Prometheus metrics: build, uptime,
scan workers and queue, whether the proxy listens, open findings by
severity, webhook deliveries by status and audit rows waiting for their
seal. Totals only, nothing about hosts or content. When an
[access token](./access.md) is set, the endpoint asks for it like the
rest of the API:

```yaml
scrape_configs:
  - job_name: phantom
    metrics_path: /api/v1/system/metrics
    authorization:
      credentials: <the access token>
    static_configs:
      - targets: ['127.0.0.1:8000']
```

## Tracing

Each API request runs in a W3C Trace Context trace. When a client sends
a `traceparent` header, Phantom continues that trace with a span of its
own; otherwise it starts a new one. Every response carries the
`traceparent` of Phantom's span and a `Server-Timing` header with the
time it took, and every log line written during the request shows the
trace ID in brackets, so a request can be followed from the client into
Phantom's log. Requests slower than `TRACE_SLOW_MS` (2000 by default)
are logged with their method, path, status and duration. Traffic Phantom
sends to targets never gets a trace header.
