> For the complete documentation index, see [llms.txt](https://docs.controltheory.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/metrics/cli.md). Agents can also search and read this documentation through its [MCP server](https://docs.controltheory.com/~gitbook/mcp).

# Metrics CLI

dstl8 metrics top, dstl8 metrics watch, and turning metrics on for a Kubernetes source from the CLI

Two commands read metrics. `dstl8 sources metrics`, and the metrics flags on `dstl8 sources add kubernetes`, set up collection on a Kubernetes source. All need a [logged-in CLI](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/dstl8-cli.md).

## dstl8 metrics top

Lists the latest insight for each metric group, ranked by what needs attention: anomalies first, then the highest scores. Groups a deploy or maintenance window explains come after the rest.

```bash
dstl8 metrics top
dstl8 metrics top --anomalies -w prod
dstl8 metrics top --service checkout --open
dstl8 metrics top --json | jq .headline
```

| Flag                | Description                                                                  |
| ------------------- | ---------------------------------------------------------------------------- |
| `-w`, `--workspace` | Workspace name or ID                                                         |
| `-s`, `--service`   | Only these services (comma-separated or repeatable)                          |
| `--anomalies`       | Only groups flagged as anomalies                                             |
| `--open`            | Only groups with an open issue (anomaly, forecast, silent or trend)          |
| `--min-maturity`    | Drop groups whose usual range is below `learning`, `provisional` or `mature` |
| `-n`, `--limit`     | Max groups (default 20)                                                      |
| `--json`            | One JSON object per group, one per line                                      |

The table's columns:

| Column              | Shows                                                                                                                                                                    |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `SCORE`             | How unusual the group is right now. Higher means look sooner                                                                                                             |
| `KIND`              | The open issue: `anomaly`, `forecast`, `silent` or `trend`; `-` for none                                                                                                 |
| `METRIC`, `SERVICE` | The metric and the service it belongs to                                                                                                                                 |
| `TREND`             | Direction and the last hour's change, for example `rising +4.7%`                                                                                                         |
| `LIMIT IN`          | Time until the metric's trend reaches its limit: `25m`, `3h`, `2d`, `now`; `-` when no limit is in sight. Only a time within 24 hours is a Forecast issue (marked `[~]`) |
| `SPARKLINE`         | The trailing 24 hours, one glyph per point                                                                                                                               |
| `HEADLINE`          | The group's headline; tagged `[learning]`, `[provisional]` or `[partial]` when that applies                                                                              |

The CLI also shows groups whose usual range is still being learned, tagged, so a new metric appears as soon as it's measured. See [Reading metric insights](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/metrics/insights.md) for what each kind and term means.

## dstl8 metrics watch

Follows one metric over a rolling window: one row per group (by default one per service), each with its latest, lowest and highest value and a sparkline. It refreshes until you press `q`.

```bash
dstl8 metrics watch container_memory_working_set_bytes --agg p95 --start -6h
dstl8 metrics watch queue.depth --group-by namespace --interval 10s
dstl8 metrics watch cpu.usage -s checkout --once
```

The metric name is the one as received, for example `container_memory_working_set_bytes` from cAdvisor; `dstl8 metrics top` lists the metrics in scope.

| Flag                | Description                                                                                                                            |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `--start`           | Window start, relative to now: `-30m`, `-1h` (default), `-24h`, `-7d`. The window rolls forward                                        |
| `--interval`        | How often to refresh (default `30s`, minimum `5s`)                                                                                     |
| `--agg`             | `avg`, `sum`, `min`, `max`, `last`, `p50`…`p99` for gauges; `rate` or `increase` for counters. Defaults to the metric type's usual one |
| `--group-by`        | A dimension (`service`, the default; `namespace`, `pod`, …) or `label:<key>`. Empty for one series                                     |
| `-n`, `--limit`     | Max groups, busiest first (default 10)                                                                                                 |
| `-w`, `--workspace` | Workspace name or ID                                                                                                                   |
| `-s`, `--service`   | Only these services                                                                                                                    |
| `--once`            | Print one frame and exit. Without a terminal, it always prints one frame                                                               |

A bucket with no data is a gap in the sparkline, never a zero. Each sparkline is scaled to its own row, so compare the `MIN` and `MAX` columns across rows, not the sparklines' heights. The bucket size grows with the window, and the header shows it (`step 60s`).

## dstl8 sources metrics

Shows or changes which metrics a Kubernetes source collects.

```bash
dstl8 sources metrics prod                                    # show what is on
dstl8 sources metrics prod --prom-metrics                     # the switch alone: every target on, accept Remote Write
dstl8 sources metrics prod --prom-metrics --otlp-metrics      # the same, and OTLP from pods
dstl8 sources metrics prod --prom-metrics --remote-write-port 9191
dstl8 sources metrics prod --prom-scrape kubelet,cadvisor --remote-write
dstl8 sources metrics prod --prom-scrape kubelet,no-gpu        # kubelet only, GPUs off
dstl8 sources metrics prod --off
```

| Flag                  | Description                                                                                                                                                                                                                                                                                                                   |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--prom-metrics`      | Turn the **Collect Prometheus metrics** switch on. Without `--prom-scrape` or `--remote-write` it turns on every target and accepts Remote Write, also when you add `--otlp-metrics` or `--remote-write-port`. Annotated pods is among them but keeps nothing until you list names under Extra metric names → annotated\_pods |
| `--prom-scrape`       | Scrape these targets: `kubelet`, `cadvisor`, `node_exporter`, `kube_state_metrics`, `annotated_pods`, `gpu`. `gpu` (GPUs and model servers) stays on unless you name it off with `no-gpu`, so `--prom-scrape kubelet,cadvisor` scrapes those two plus GPUs. Turns the switch on. `gpu` and `no-gpu` need CLI 0.2.14 or later  |
| `--remote-write`      | Accept Remote Write. Turns the switch on. With `--prom-scrape`, only the targets named are scraped; on its own, nothing is scraped                                                                                                                                                                                            |
| `--remote-write-port` | Remote Write port (default 9090); see the [port rules](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/metrics/collecting.md#remote-write). Needs `--remote-write`, or `--prom-metrics` without `--prom-scrape`                                                                                         |
| `--otlp-metrics`      | Collect metrics your pods push over OTLP. Needs nothing from the cluster. On its own it turns Prometheus metrics off; add `--prom-metrics` to keep them                                                                                                                                                                       |
| `--off`               | Turn every metrics option off                                                                                                                                                                                                                                                                                                 |

{% hint style="warning" %}
The flags you give are the **new set**: anything you don't name is turned off, including Prometheus metrics when you name only `--otlp-metrics`. Run `dstl8 sources metrics <source>` first to see what is on. To keep a custom Remote Write port while changing something else, name `--remote-write-port` again, or the port goes back to 9090.
{% endhint %}

After turning the switch on or off, or changing the port, re-run the install command so the agent gets the access it needs:

```bash
dstl8 sources install-script prod
```

## dstl8 sources add kubernetes

The same flags work when you create a source:

```bash
dstl8 sources add kubernetes --yes --cluster-name prod --environment production \
  --prom-scrape kubelet,cadvisor,kube_state_metrics
```

Without `--yes`, the wizard asks whether to collect metrics, which targets to scrape, whether to accept Remote Write (and on which port), and whether to collect OTLP from pods. Every answer defaults to no. The install command it prints already carries `--prom-metrics` when you chose a scrape target or Remote Write.

## Tips

* **Start with `dstl8 metrics top --open -w <workspace>`.** It lists only what has an open issue, worst first, in one workspace.
* **Pipe JSON for scripts.** `dstl8 metrics top --json` prints one object per line; `jq 'select(.time_to_threshold_seconds != null)'` keeps only groups with a forecast.
* **`--min-maturity mature` cuts noise** from metrics that started reporting in the last day or two.
* **Find the right name first.** `dstl8 metrics watch` needs the metric name exactly as received; copy it from `dstl8 metrics top` or the **All metrics** list on the [Metrics page](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/metrics/explore.md).
* **Split by a label** with `--group-by label:<key>`, for example `--group-by label:route`, to see what a service-level line is made of.
* **Counters need `rate` or `increase`.** That's the default for a counter, so leave `--agg` out unless you want the other one.
* **`metrics watch --once`** in a script or CI step prints one frame and exits.

## Troubleshooting

* **`dstl8 metrics top` says "No metric insights for the given filters."** If you passed filters, loosen one: `--open` and `--anomalies` show nothing while nothing is wrong, and `--min-maturity` hides new metrics. With no filters, check that the workspace has the source (or its service) assigned and takes **Metrics** among its signals (see [Signals](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/signals.md)). Metrics that only started arriving a few minutes ago may not be analyzed yet; `dstl8 metrics watch <metric>` shows their values in the meantime.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.controltheory.com/controltheory-documentation/dstl8-docs/metrics/cli.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
