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

# Grafana

> Grafana alerts, Prometheus/Mimir metrics, Loki logs, and Tempo traces.

Connect Grafana to give Struct Agent access to alerts and the configured Prometheus or Mimir, Loki and Tempo sources. Verify the sources required for the requested job.

## Inspect access and existing connections

Use a claimed workspace with permission to configure connections.

```bash theme={null}
struct whoami --json
struct connections catalog grafana --json
struct connections list --json
```

Use the catalog's current fields, choices and permission requirements. Reuse an existing healthy connection instead of creating a duplicate.

## Connect with the CLI

Supply credentials from approved secret storage through `GRAFANA_TOKEN`. The catalog describes which are needed for the selected authentication method. Do not put literal secrets in shell arguments or chat.

Replace example values with the intended resource:

```bash theme={null}
struct connect grafana --url <grafana-url>
```

## Verify and recover

Use the returned connection ID:

```bash theme={null}
struct connections show CONNECTION_ID --json
struct connections test CONNECTION_ID --json
```

Inspect `ok`, `health` and missing permissions, not only the exit code. `struct connections grant-command CONNECTION_ID` prints repair instructions where supported; have an authorized operator apply them. For expired OAuth links, start the connection command again and use the new link. Do not reconnect to a different account silently.

Verify a bounded operation for the requested job. Connection health proves checked access; it does not prove telemetry arrival, an investigation or alert delivery.

## What Struct reads

Grafana alert rules, their state and their state history (when each alert fired), plus Prometheus or Mimir metrics, Loki logs, and Tempo traces through the data sources you select.

## What Struct writes

With Auto Monitors on, Struct creates and maintains its own alert rules in its folder, plus the contact point and notification policy that send their alerts back to Struct.

## Permissions

Use a Grafana service account token that can read and query the data sources you select. Auto Monitors also needs alert rule, contact point and notification policy access in Struct's folder; Struct checks each action after you connect.

### Data sources

Find and query the data sources you select.

| Permission | Used for |
| - | - |
| `datasources:read` | Finding the data sources you select |
| `datasources:query` | Querying them |

### Alert history

Lets investigations see when alerts fired: read Grafana's alert state history (when each alert went pending, firing and back to normal). Only needed for that; Grafana's Viewer role includes it. Needs alert state history turned on in Grafana.

| Permission | Used for |
| - | - |
| `alert.rules:read` | Reading alert state history, plus read access to the rules in each alert's folder |

### Manage alerting

Create and maintain Struct's alert rules in its folder, plus the contact point and notification policy that send their alerts back to Struct.

| Permission | Used for |
| - | - |
| `folders:read` | |
| `folders:create` | Only if Struct's folder does not exist yet |
| `alert.rules:read` | |
| `alert.rules:create` | |
| `alert.rules:write` | |
| `alert.rules:delete` | |
| `alert.provisioning.provenance:write` | Grafana 12 provisioning |
| `alert.notifications.receivers:read` | |
| `alert.notifications.receivers.secrets:read` | |
| `alert.notifications.receivers:create` | |
| `alert.notifications.receivers:write` | |
| `alert.notifications.receivers.protected:write` | Grafana Cloud: changing a contact point's destination |
| `alert.notifications.receivers:delete` | |
| `notifications.alerting.grafana.app/routingtrees:get` | |
| `notifications.alerting.grafana.app/routingtrees:create` | |
| `notifications.alerting.grafana.app/routingtrees:update` | |
| `notifications.alerting.grafana.app/routingtrees:delete` | |

### Mimir or Loki ruler

Only if you choose a Mimir or Loki ruler for Struct's rules.

Permissions: `alert.rules.external:read`, `alert.rules.external:write`.

### External Alertmanager

Only if you use an external Alertmanager.

Permissions: `alert.notifications.external:read`, `alert.notifications.external:write`, `alert.instances.external:read`, `alert.instances.external:write`.

### Grafana Cloud data source credentials

Only needed on Grafana Cloud: the credentials behind each data source are separate from the service account and need these access-policy scopes, depending on the sources you select.

Scopes: `metrics:read`, `logs:read`, `traces:read`, `rules:read`, `alerts:read`.

### Grafana Cloud ruler and Alertmanager writes

On Grafana Cloud, only if you choose a Mimir or Loki ruler for Struct's rules or use an external Alertmanager: the credentials behind those data sources also need these scopes.

Scopes: `rules:write`, `alerts:write`.

* Grafana authorizes each request by fine-grained action and resource, so role names alone don't decide what works. Struct checks every action against the exact folder, data source and contact point it uses, and the Auto Monitors page lists anything missing. Struct's own acceptance tests run with Grafana's built-in Editor and Admin roles.
* On Grafana 12, alerting provisioning access can stand in for the rule, contact point and notification policy actions: `alert.provisioning:read` and `alert.provisioning:write`, or the rule- and notification-specific provisioning actions.
* Grafana-managed alert rules need the organization's Alertmanager setting to be internal. Struct does not change it, and refuses to create rules while alerts are also sent to external Alertmanagers.

### How to grant

**Create a service account token.** In Grafana, open Administration → Users and access → Service accounts, create a service account with every permission above, including the optional ruler and Alertmanager actions, and add a token.

**Grafana Cloud data source credentials.** On Grafana Cloud, give the access policy behind each data source's credentials these scopes: `metrics:read`, `logs:read`, `traces:read`, `rules:read`, `rules:write`, `alerts:read`, `alerts:write`.

Permission catalog version `2026-11-04.1`. See [permission changes](https://docs.struct.ai/reference/permission-changes.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.