> For the complete documentation index, see [llms.txt](https://docs.ilert.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ilert.com/ai-and-agents/mcp/hosted/grafana.md).

# Grafana

Give an agent access to Grafana, Loki and Tempo with a service account token.

#### Required permissions

<table><thead><tr><th width="116.3515625">Tool</th><th width="254.4375">Required Permission</th><th>Description</th></tr></thead><tbody><tr><td><code>list_loki_label_names</code></td><td><code>query api access</code></td><td>List all label names (keys) found in logs in a Loki datasource and time range. Defaults to the last hour.</td></tr><tr><td><code>list_loki_label_values</code></td><td><code>query api access</code></td><td>List the unique values of a given label in a Loki datasource. Useful for discovering filter options.</td></tr><tr><td><code>query_loki_logs</code></td><td><code>query api access</code></td><td>Query and retrieve log entries from a Loki datasource using label filters. Returns log lines with timestamps and labels.</td></tr><tr><td><code>search_dashboards</code></td><td><code>dashboards.permissions:read</code></td><td>Search Grafana dashboards to find the ones whose graphs might be relevant to the current alert.</td></tr><tr><td><code>list_dashboards</code></td><td><code>dashboards.permissions:read</code></td><td>List dashboards in a given namespace, for discovering which graphs exist.</td></tr><tr><td><code>get_dashboard</code></td><td><code>dashboards.permissions:read</code></td><td>Get a dashboard by name, including its panels with their queries and datasources.</td></tr><tr><td><code>list_tempo_services</code></td><td><code>query api access</code></td><td>Discover the available <code>service.name</code> values in a Tempo datasource.</td></tr><tr><td><code>search_tempo_traces</code></td><td><code>query api access</code></td><td>Search Tempo traces for a service and time range, optionally filtered by duration. Returns trace summaries including trace IDs.</td></tr><tr><td><code>get_tempo_trace</code></td><td><code>query api access</code></td><td>Fetch a single Tempo trace as a compacted span tree with service names, durations, and HTTP context.</td></tr></tbody></table>

{% hint style="info" %}
The Loki and Tempo tools query datasources by UID, so the service account token must be able to read the Loki and Tempo datasources you want the agent to use. If you only use Loki, you can leave the Tempo tools disabled, and vice versa.
{% endhint %}

#### Create service account token

{% stepper %}
{% step %}
Create a [Service account token](https://grafana.com/docs/grafana/latest/administration/service-accounts/) with **Viewer** role

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FWNqSdEynKy2SAopVO9Mv%2FGrafana%20Service%20Account.png?alt=media&amp;token=c9b4bbee-413b-4b10-ae2a-b2c1e2911998" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
On the next screen, click on the **Add service account token** button

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2F8Ncq3RyCH5RzCLvoymw0%2FGrafana%20Service%20Account%20Token.png?alt=media&amp;token=5f74d262-6c03-4397-b9c5-85e2801fb32a" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
On the modal choose "No expiration" and click on the **Generate token** button

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FYIVLg6ByJHH24TAQQTvi%2FUntitled%202.png?alt=media&amp;token=f5133f22-58fa-4d83-b72a-04e6bea22c6a" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Copy your token and temporarily paste it somewhere secure (e.g. a private note). You will later need the token when setting up the Grafana MCP server in ilert.

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FXmEPsaHi03FzNUMuSUw9%2FUntitled%203.png?alt=media&amp;token=032b5890-fbf0-4174-bfe1-fed2b489a29c" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

#### **Connect Grafana with agent**

To connect Grafana with your AI SRE agent:

{% stepper %}
{% step %}
Navigate to **Agents** in the ilert navigation menu
{% endstep %}

{% step %}
Open the agent detail view for the agent you want to configure
{% endstep %}

{% step %}
Go to the **Tools** tab
{% endstep %}

{% step %}
Under the **ilert hosted MCP servers** section, locate the **Grafana** card
{% endstep %}

{% step %}
Click **Connect** on the Grafana card
{% endstep %}

{% step %}
In the connection dialog that appears:

* **Select connector:** Choose "Create new connector" (or select an existing connector if you have one)
* **Type:** Select **Bearer Token** from the dropdown
* **Secret name:** Enter a name for your connector (e.g., "Grafana Production" or "Grafana Main")
* **Secret value:** Paste the service account token you created earlier
* **Host URL:** Enter your Grafana instance URL (e.g., `https://grafana.example.com`)

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2FwLaoyY55ajC996hZcMge%2FBildschirmfoto%202025-11-24%20um%2012.48.04.png?alt=media&amp;token=af978abe-0a7d-42b2-aec9-154be4ef9c5b" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Click **Connect** to complete the connection
{% endstep %}

{% step %}
After connecting, you can enable or disable specific tools needed for alert investigation, such as:

* `list_loki_label_names` - List available label names in a Loki datasource
* `list_loki_label_values` - List the values of a given Loki label
* `query_loki_logs` - Query log entries from a Loki datasource
* `search_dashboards` - Search dashboards relevant to the alert
* `list_dashboards` - List dashboards in a namespace
* `get_dashboard` - Get a dashboard with its queries and datasources
* `list_tempo_services` - Discover services in a Tempo datasource
* `search_tempo_traces` - Search traces for a service and time range
* `get_tempo_trace` - Fetch a single trace as a span tree
  {% endstep %}
  {% endstepper %}

The Grafana integration is now connected and ready to use for root cause analysis.


---

# 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.ilert.com/ai-and-agents/mcp/hosted/grafana.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.
