# dflow apps:metrics

> Read CPU, memory, and network usage metrics and metered integrals for one application.

Web page: /docs/cli/apps/apps-metrics/

This reads CPU, memory, network receive, and network transmit metrics for one application through the API, along with allocated capacity, observed pods (including pods that exited during the window), coverage status, and deterministic metered totals (`core_seconds`, `byte_seconds`, `bytes`).

```bash
dflow apps:metrics APP [--range 1h] [--from RFC3339 --to RFC3339] [--step 60s] [--metrics cpu,memory,network_rx,network_tx] [--pods POD] [--group-by service|pod] [--summary-only]
```

## Flags

`--range` picks a preset window (`15m`, `1h`, `6h`, `24h`, `7d`, `30d`). Default is `1h`. `--from` and `--to` pass an explicit UTC half-open window `[from, to)` (RFC3339, whole seconds) and cannot be combined with `--range`. A bucket counts toward the window that contains its start time, so adjacent windows never count the same bucket twice; an unaligned window leaves out its partial edge buckets. `--step` picks a fixed bucket size (`60s`, `300s`, `900s`, `3600s`, `14400s`, `86400s`); omitted picks a deterministic default for the window span (at most 744 buckets). `--metrics` selects a comma-separated subset of `cpu`, `memory`, `network_rx`, `network_tx`. `--pods` limits results to one or more pod names (at most 100). `--group-by` accepts `service` (default) or `pod`. `--summary-only` omits series points (`include_series=false`). The usual global flags (`--output json`) still apply.

## What you see

Text mode prints the window, coverage, observed pods, an `allocated:` line (CPU, memory, and replicas), and a summary table (`METRIC`, `LATEST`, `AVG`, `PEAK`, `METERED TOTAL`, `ALLOCATED`). A window with no samples still exits 0: the header shows `coverage=empty (0/N)`, and every value cell is `-`. With `--output json`, stdout is the API response with `schema_version`, `resource`, `window`, `allocated`, `coverage`, `observed_pods`, and `metrics`. Missing buckets are `null`, never `0`.

## When it fails

Exit 1 is validation (bad range, step, metric name, or over 744 buckets). Exit 2 is auth. Exit 3 means the application was not found. Exit 6 is precondition (`metrics_sink_not_configured` when the API has no metrics query source configured). Exit 10 means the API could not be reached.
