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

# Metrics

> Mission performance summary (success rate, p50/p99 duration) or a metric timeseries over a window.

# crewship metrics

Fetch mission performance metrics or pull a metric timeseries. Without flags, returns the mission summary — success rate, p50/p99 durations, total runs over the last default window. With `--series <name>`, switches to a timeseries endpoint and returns time-bucketed points.

```bash theme={null}
crewship metrics [flags]
```

Requires an authenticated session and a selected workspace (`requireAuthAndWorkspace`).

The output is always structured JSON (or YAML with `--format yaml`). Pipe through `jq` or use `--filter` for ad-hoc shapes — there is no canonical table form for the records returned.

## Flags

| Flag                 | Default | Purpose                                                                                                         |
| -------------------- | ------- | --------------------------------------------------------------------------------------------------------------- |
| `--series <name>`    | `""`    | Fetch a timeseries for the named metric instead of the mission summary. Routes to `/api/v1/metrics/timeseries`. |
| `--range <window>`   | `24h`   | Window for `--series` — `1h`, `24h`, `7d` are the supported sugar values.                                       |
| `--filter <jq-expr>` | `""`    | Pipe JSON output through `jq <expr>` (requires `jq` in `$PATH`).                                                |

The global `--format` flag (`table` / `json` / `yaml` / `ndjson` / `quiet`) is honoured. The default is indented JSON because the data here is structured records without a single canonical "table" shape.

## Endpoints

| Mode              | Endpoint                                                      |
| ----------------- | ------------------------------------------------------------- |
| Default           | `GET /api/v1/mission-metrics`                                 |
| `--series <name>` | `GET /api/v1/metrics/timeseries?metric=<name>&range=<window>` |

## Examples

### Mission summary

```bash theme={null}
crewship metrics
# {
#   "total_runs": 142,
#   "success_rate": 0.93,
#   "duration_p50_ms": 4280,
#   "duration_p99_ms": 28150,
#   "cost_usd_total": 2.84
# }
```

### Active-runs timeseries over the last hour

```bash theme={null}
crewship metrics --series active_runs --range 1h
```

### Week-long window

```bash theme={null}
crewship metrics --series active_runs --range 7d
```

### Pull a single field via jq

```bash theme={null}
crewship metrics --filter '.success_rate'
```

### YAML output

```bash theme={null}
crewship metrics --format yaml
```

### Pipe to a chart

```bash theme={null}
crewship metrics --series active_runs --range 24h --format json \
  | jq -r '.points[] | "\(.ts) \(.value)"' \
  | gnuplot -p -e "plot '<cat' using 1:2 with lines"
```

## See also

* [`crewship paymaster`](/cli/paymaster) — cost-oriented view of the same underlying data.
* [`crewship telemetry`](/cli/telemetry) — distributed-trace observability across crews.
* [`crewship journal`](/cli/journal) — per-agent execution events behind the metrics aggregation.
* [`crewship history`](/cli/history) — individual run records that feed the success-rate and duration percentiles.
