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

# Grafana

> Connect Grafana for dashboard context, metric queries, and unified alerts

The Grafana integration gives sureops agents access to your Grafana instance for metric queries, log search, unified alert state, and dashboard context — all through a single MCP server. If you run the standard Grafana observability stack (Grafana + Prometheus + Loki), this is the recommended single-integration path.

> [!NOTE]
>
> The Grafana MCP connection covers Prometheus and Loki datasource queries. You do **not** need to connect Prometheus or Loki separately if they are already configured as Grafana datasources. However, if you use Tempo for distributed tracing, connect Tempo separately — the Grafana MCP does not expose Tempo's full TraceQL surface.

***

## What this integration enables

* **Metric queries** — agents run PromQL against your Prometheus datasource via Grafana
* **Log search** — agents run LogQL against your Loki datasource via Grafana
* **Unified alert state** — agents can read Grafana-managed alert rules and their current state
* **Dashboard context** — agents can reference your dashboards during diagnosis and in RCA documents

***

## Prerequisites

* An environment selected in the top-right context switcher — **Settings → Environment → Integrations** is scoped to that environment and stays disabled until one is selected
* A running Grafana instance (self-hosted or Grafana Cloud)
* Admin access to Grafana to create a service account
* The `grafana-mcp` server running and reachable from sureops (see step 2 below)

> [!NOTE]
>
> Integration connections are per-environment. Connecting Grafana here only applies to the environment that was selected in the context switcher at the time — it does not carry over to your other environments. Repeat this connect flow for each environment that needs Grafana.

***

## Setup

**1. Generate a Service Account Token**

In Grafana, go to **Administration → Service accounts**.

Create a new service account. If you only need metric/log queries, dashboard context, and unified alert *reads*, the **Viewer** role is enough (unless your Grafana restricts data source permissions, in which case grant the service account access to the data sources it should query). If you plan to use [Proposed Monitor Export](https://docs.sureops.ai/getting-started/pricing-and-tiers.md) (Growth plan and above) to push approved sureops monitors into Grafana as alert rules, Viewer is **not** enough — that push writes alert rules through Grafana's provisioning API, so assign the service account the **Editor** role or above on Grafana 11 and later, or **Admin** (the `alert.provisioning:write` permission) on Grafana 9–10, or a custom role that grants `alert.provisioning:write`. Then click **Add token** to generate a service account token for that account.

Copy the token; you'll need it in the next step to configure `grafana-mcp`. It isn't entered directly into sureops. Grafana only shows it once.

**2. Stand up grafana-mcp**

Run `grafana-mcp` pointed at your Grafana instance. If you're using the sureops demo environment, `grafana-mcp` is already provisioned in-cluster — you can skip this step.

For your own environment, deploy [`grafana-mcp`](https://github.com/grafana/mcp-grafana) with your Grafana URL and the service account token from step 1 as its upstream config — the repository documents both Docker and binary deployment.

**3. Connect in sureops**

In sureops, go to **Settings → Environment → Integrations** and click **Connect** next to Grafana.

Fill in:

* **Integration Name** — prefilled; change it if you need to tell two configurations of this integration apart
* **MCP Server Endpoint** — the URL of your running `grafana-mcp` server
* **Bearer Token** — the token your `grafana-mcp` endpoint (or the proxy in front of it) expects. sureops always sends this to `grafana-mcp` as an `Authorization: Bearer` header, so there is no authentication method to choose. The form won't save a blank token, so if nothing in front of `grafana-mcp` checks a token, put it behind an ingress or proxy that does. This is not your Grafana service account token — that one goes to `grafana-mcp` only

Click **Save & Connect**.

**4. Configure Org ID and Alert Folder UID (after connecting)**

Once connected, reopen the Grafana integration from **Settings → Environment → Integrations**. A **Settings** section appears below the connection status with two additional fields you set post-connect:

* **Grafana Org ID** — leave blank to use the org your `grafana-mcp` is configured for; set it only to override
* **Alert Folder UID** — the folder alert rules are created in. Optional to connect, but required before you can push a Proposed Monitor — it's the part of the folder's URL after `/dashboards/f/`, or ask your Grafana admin

These aren't part of the initial connect form — they're configured afterward, once the integration shows as connected.

On the sureops demo environment, sureops sets both during provisioning (alert rules go to the **SureOps** folder, UID `sureops`) and the settings show **Managed by sureops**, so you can skip this step. Don't delete the **SureOps** folder: Grafana deletes the rules in it too, and sureops still shows those monitors as **Pushed**. If pushing a Proposed Monitor fails with "Grafana alert\_folder\_uid is not configured for this integration", contact your sureops support contact.

***

## Required credentials

Fields collected when you connect the integration:

| Field | Required | Description |
| - | - | - |
| Integration Name | No | Prefilled with a default name; distinguishes two configurations of the same integration in one environment |
| MCP Server Endpoint | Yes | URL of your running `grafana-mcp` server |
| Bearer Token | Yes | Token your `grafana-mcp` endpoint (or the proxy in front of it) expects. Required; sent to `grafana-mcp` as an `Authorization: Bearer` header |

Fields configured afterward, via the integration's Settings section once connected:

| Field | Required | Description |
| - | - | - |
| Grafana Org ID | No | Leave blank to use the org your `grafana-mcp` is configured for; set only to override |
| Alert Folder UID | No | Grafana folder alert rules are created in. Optional to connect; required to push a Proposed Monitor. |

The **Service Account Token** and **Grafana URL** from steps 1–2 are never entered into sureops — they configure `grafana-mcp`, which handles authentication to Grafana on sureops' behalf.

***

## Common errors

| Error | Fix |
| - | - |
| "401 Unauthorized" on MCP endpoint | Either the token sureops sends to `grafana-mcp` is wrong, or `grafana-mcp`'s own service account token (configured when you stood it up) is incorrect or expired. Check both — regenerate the service account token in Grafana → Administration → Service accounts if needed. |
| "Connection timed out" | Your `grafana-mcp` server is not reachable from sureops. Check that the endpoint is accessible and the port is open. |
| "Datasource not found" | The Grafana service account can see the instance but your Prometheus/Loki datasource is not configured, or (if your Grafana restricts data source permissions) the service account has no access to it. Check Grafana → Connections → Data sources and the data source's **Permissions** tab. |

***

## Official documentation

* [Grafana service accounts](https://grafana.com/docs/grafana/latest/administration/service-accounts/)
* [grafana-mcp on GitHub](https://github.com/grafana/mcp-grafana)


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