# Grafana

> Read the control plane's metrics in your own Grafana: a Prometheus data source with a control plane API key that may only read metrics, a dashboard for inference and hardware to import, what the data source can and cannot do, and why the metric names can change.

The control plane keeps 30 days of metrics in its metrics store (see [Metrics](/en/platform/docs/v5.10/concepts/metrics/index.md)). It serves them in the Prometheus HTTP API, so your own Grafana reads them as a Prometheus data source. Grafana runs on your side; it must reach the control plane's address, like a browser that opens these pages.

## 1. Create a key that only reads metrics

Open **Settings → MCP access** and choose **Add key** (see [Automation via APIs and CLI](/en/platform/docs/v5.10/guides/automation/apis-and-cli/index.md)).

- **Name**: `grafana`, or the name of your Grafana instance.
- **May do**: choose *Only the permissions chosen below* and tick only `prometheus:read`. With this scope, the key reads metrics through the Prometheus HTTP API and does nothing else: no other page, no other command, no change. A key that leaks cannot change the platform.
- **Expires after**: choose a period, and create a new key before it ends. Grafana stops showing data on the day the key expires.

Create the key with an account of its own when the dashboards must outlive one person's account.

## 2. Add the data source

In Grafana, open **Connections → Data sources → Add data source → Prometheus** and set:

| Field | Value |
|---|---|
| Prometheus server URL | `https://<control-plane-address>/api/v1/prometheus` |
| Authentication | No Authentication |
| HTTP headers | Header `Authorization`, value `Bearer <the key>` |
| TLS settings | Turn on **Add self-signed certificate**, and paste the control plane's root CA into **CA Certificate** (see below) |
| HTTP method | POST |
| Manage alerts via Alerting UI | off |

`<control-plane-address>` is the address you open these pages at, for example `10.0.4.10:3443`. To get the root CA, open **Configuration → Security → Certificates (in your control plane)** and choose **Copy Root CA**: it copies the certificate as text, ready to paste into Grafana's **CA Certificate** field. The certificate goes into this data source's own settings in Grafana, not into the operating system Grafana runs on. You can skip it only when Grafana trusts the control plane's certificate already: the control plane presents a certificate from your company's or a public certificate authority, or an administrator added the root CA to the trust store of Grafana's machine or container (see [Browser Certificate Trust](/en/platform/docs/v5.10/guides/certificates-and-network/browser-certificate-trust/index.md)). Do not choose **Skip TLS certificate validation**: the key travels in every request.

No configuration file or environment variable is needed, in Grafana or in the control plane: the data source's settings above are all.

Choose **Save & test**. Grafana says that it queried the Prometheus API successfully.

## 3. Import the dashboard

The platform comes with one dashboard for inference and hardware: [download the dashboard (JSON)](/platform-docs-assets/5.10/guides/integrations/grafana-inference-and-hardware-dashboard.json).

In Grafana, open **Dashboards → New → Import**, choose **Upload dashboard JSON file**, pick the downloaded file and choose **Import**. Then pick your data source in **Data from** at the top of the dashboard.

The dashboard has these sections, from "does anything need attention" at the top to the detail of one machine at the bottom:

| Section | What it answers |
|---|---|
| Status | Which alerts fire, which machines and models are down, and one row per model with its requests, speed, failures and GPU memory |
| Usage in the selected time range | Requests and tokens in total and per API key, GPU utilization, GPU hours working and idle, GPU energy and what it cost |
| Throughput | Output and input tokens per second, requests per minute, tokens per request |
| Parallel requests and speed | How many requests run at once, how long the first token takes, how fast one request is answered |
| KV cache | How full each model copy's working memory is, and when it was full |
| Errors and availability | Refused and failed requests by reason, the built-in test requests, interrupted answers |
| GPUs | Utilization, memory, temperature and power of every GPU |
| GPU health | Hardware faults, throttled GPUs and NVLink errors. Everything here should be empty or zero |
| Machines | CPU, main memory, disk space and log errors of the GPU servers, and reports that wait to reach the control plane |
| Model containers | CPU, main memory, network and disk traffic of each model's containers |

The fields at the top narrow the dashboard to chosen models, machines and API keys. **Built-in test requests** decides whether the control plane's own test requests to every model count as traffic; they do not by default. **Electricity price per kWh** is the price the cost panel multiplies the GPU energy with: enter your own. Every panel explains itself in the text behind its info icon.

The dashboard is tested with Grafana 13.

To fetch the file without a browser, read the same address with a control plane API key that may read the documentation (the key of step 1 may not: it only reads metrics):

```bash
curl -H "Authorization: Bearer <control plane API key>" -o grafana-inference-and-hardware-dashboard.json \
  "https://<control-plane-address>/api/docs/download?group=guides&topic=integrations&file=grafana-inference-and-hardware-dashboard.json"
```

The dashboard is yours after the import: change it as you like. An update of the platform can bring a newer file. Importing it again replaces the dashboard of the same name, your changes included, so save your own version under another name first (**Save as**).

## What the data source reads

Grafana reads instant and range queries, series, label names, label values and metric metadata. Queries use PromQL; MetricsQL, the store's extension of PromQL, also works. The data source only reads: nothing in Grafana can write, change or delete metrics.

It does not serve:

- **Alert rules.** The control plane evaluates its own alert rules and sends the notifications (see [Alert notifications](/en/platform/docs/v5.10/guides/integrations/alert-notifications/index.md)). Turn **Manage alerts via Alerting UI** off, or Grafana asks for rules that the data source does not serve. Grafana's own alert rules on top of this data source work.
- **Exemplars.** Leave exemplars off in the queries.

## The metric names can change

The metric names and their labels are **experimental** for dashboards and other readers outside the platform. An update can rename, remove or relabel a metric, without notice ahead. Expect to correct dashboard queries after an update. Look up the current names before you correct a query (see [Metrics](/en/platform/docs/v5.10/concepts/metrics/index.md), "Which metrics exist"). The dashboard of step 3 changes with the names: after an update, download it again and import it.

## When a panel shows an error

The error text on the panel says what failed and what to do. A failed query leaves the same traces as every failed request to the control plane: an audit event, a log line, a count for the alerts and, with the built-in rules, an error report, whose id is the error text's last line (`Report: ...`). See [Error reports for failed requests](/en/platform/docs/v5.10/guides/errors-and-debugging/error-trace-policy/index.md).

Someone who types queries in Grafana's Explore makes mistakes, and each one is a failed request. When those reports and alerts are noise for you, an administrator adds a rule under **Configuration → Diagnostics → Error trace policy**: path `/api/v1/prometheus/*`, status `4xx`, error report off, and metric off when the alert on refused requests is noise too. Keep the error reports on for `5xx`: those failures are the ones support needs.

| Panel error | Cause | Next step |
|---|---|---|
| HTTP 401 | The key is wrong, expired or revoked. | Create a new key, and put it in the data source's `Authorization` header. |
| HTTP 403, names `prometheus:read` | The key does not hold the scope `prometheus:read`, or its account's role does not read metrics. | Create the key with the scope `prometheus:read`, with an account whose role is Administrator, Operator or Viewer. |
| `Query not run: ... other queries` (503) | The control plane runs only a few queries from Prometheus clients at the same time, so that its own pages and alert rules stay fast. More panels asked at once. | Refresh the dashboard less often, show fewer panels at a time, or narrow the time range. |
| `did not answer within ... seconds` (504) | The query reads too many series or too long a time range. | Narrow the time range or the label selectors, or set a larger **Min interval** on the panel. |
| `could not reach its metrics store` (502) | The metrics store is not running, or is restarting. | Retry in a minute. If it stays, see [Platform Containers](/en/platform/docs/v5.10/guides/machine-administration/platform-containers/index.md). |
| `has no metrics store` (503) | The deployment has no metrics store configured. | Set `VICTORIA_METRICS_QUERY_URL` in the control plane's configuration. |
