> ## 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.
</Note>

***

## 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

* 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)

***

## Setup

<Steps>
  <Step title="Generate a Service Account Token">
    In Grafana, go to **Administration → Service accounts**.

    Create a new service account with the **Viewer** role — read-only access is sufficient for sureops. Then click **Add token** to generate a service account token for that account.

    Copy the token; you'll need it in step 3. Grafana only shows it once.
  </Step>

  <Step title="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` with your Grafana URL and the service account token from step 1. The sureops MCP setup guide has Helm and Docker Compose examples.
  </Step>

  <Step title="Enter MCP endpoint and credentials">
    In sureops, go to **Settings → Integrations** and click **Connect** next to Grafana.

    Fill in:

    * **Service Account Token** — from step 1
    * **Grafana URL** — the base URL of your Grafana instance (e.g. `https://grafana.example.com`)
    * **Grafana MCP Endpoint** — the URL of your running `grafana-mcp` server
    * **MCP Connection Token** — only required if your `grafana-mcp` deployment uses bearer auth; leave blank otherwise
    * **Grafana Org ID** — defaults to `1` for single-org Grafana installs

    Click **Verify connection** to confirm sureops can reach the MCP server.
  </Step>
</Steps>

***

## Required credentials

| Field                 | Required | Description                                                                          |
| --------------------- | -------- | ------------------------------------------------------------------------------------ |
| Service Account Token | Yes      | Generated in Grafana → Administration → Service accounts. Viewer role is sufficient. |
| Grafana URL           | Yes      | Base URL of your Grafana instance (e.g. `https://grafana.example.com`)               |
| Grafana MCP Endpoint  | Yes      | URL of your running `grafana-mcp` server                                             |
| MCP Connection Token  | No       | Optional bearer auth for your MCP server                                             |
| Grafana Org ID        | No       | Defaults to `1` (single-org installs)                                                |

***

## Common errors

| Error                              | Fix                                                                                                                                                   |
| ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| "401 Unauthorized" on MCP endpoint | Your service account token is incorrect or expired. Regenerate it in Grafana → Administration → Service accounts.                                     |
| "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. Check Grafana → Configuration → Data sources. |

***

## Official documentation

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