Grafana

Grafana

Let your AI read your Grafana: search dashboards and see their panels and queries, query Prometheus, Loki and SQL data sources, see which alerts are firing and how the rules are defined, read and add annotations, and list contact points, users and teams. Works with Grafana Cloud and self-hosted Grafana.

7 天免费 · 无需信用卡 · EU 托管

问 Grafana 任何事

通过 AnythingMCP 对 Grafana 试一个真实提示 — Claude 调用工具并返回答案。在你的消息上按 Enter 即可在 Cloud 安装。

在 Cloud 上安装 Grafana
Grafana · 通过 MCP 实时
分享
Opus 4.7

Claude 是 AI,可能会出错。请核对回答。

2 分钟设置

  1. 1在 cloud.anythingmcp.com 开始免费试用。
  2. 2在连接器商店点击 Grafana。提示时粘贴凭据。
  3. 3生成 MCP API 密钥,将 AI 客户端指向生成的 MCP URL。
立即安装 Grafana

Grafana 指南

面向主流 AI 客户端的逐步设置。

配置 Grafana

直接来自连接器定义:在哪里获取凭据、需要哪些权限,以及该适配器调用的是哪个 API。 由连接器作者以英文提供。

Grafana

This connector works with one Grafana organization, on Grafana Cloud or a self-hosted Grafana, through the Grafana HTTP API with a service account token: dashboards and folders, data sources and queries against them (Prometheus, Loki, SQL...), alert rules and the alerts firing now, annotations, contact points, and the organization's users and teams. The only change it can make is adding an annotation.

Setup (about 3 minutes)

  1. Set GRAFANA_URL to the address you open Grafana at, without a trailing slash: https://<your-stack>.grafana.net on Grafana Cloud, or for example https://grafana.example.com (or https://example.com/grafana when it runs under a path) when self-hosted. On AnythingMCP Cloud the instance must be reachable from the internet.
  2. In Grafana open Administration, Users and access, Service accounts, click Add service account, give it a name (for example AnythingMCP) and the role Viewer. Viewer is enough for every read here except users and teams, which need Admin. Adding annotations needs Editor.
  3. Open the service account, click Add service account token, pick an expiry and copy the token (it starts with glsa_ and is shown once). Paste it into GRAFANA_SERVICE_ACCOUNT_TOKEN. It is sent as Authorization: Bearer <token> and only reaches the organization the service account belongs to.
  4. Check the setup with grafana_get_current_org.

How to work

  1. Find dashboards with grafana_search (or browse grafana_list_folders), then grafana_get_dashboard for its panels and their queries.
  2. Data: grafana_list_datasources for the uid and type (grafana_get_datasource for one data source's settings), then grafana_query_datasource. Prometheus: expr = sum by (job) (rate(http_requests_total[5m])), from = now-1h, instant = true for the current value only. Loki: expr = {app="api"} |= "error" with max_lines, or a metric query such as sum(count_over_time({app="api"} |= "error" [5m])). SQL data sources: raw_sql instead of expr. A panel's own query from grafana_get_dashboard can be run the same way; replace dashboard variables such as $job or $__rate_interval with real values first.
  3. Alerting: grafana_list_firing_alerts for what fires now, grafana_list_alert_rules and grafana_get_alert_rule for the rule definitions, grafana_list_contact_points for where notifications go.
  4. Annotations: grafana_list_annotations for deployments and incidents marked on graphs; grafana_create_annotation to add one.
  5. People: grafana_list_org_users and grafana_search_teams (Admin role).
  6. grafana_get_health shows the version (no token needed).

Adding an annotation is visible to everyone: confirm first. Before grafana_create_annotation, show the user the text, time and tags and wait for their yes. Nothing here changes dashboards, data sources or alert rules, or deletes anything.

Times: annotations take and return epoch milliseconds; queries take relative times such as now-6h or epoch milliseconds. Query results give times as epoch milliseconds.

Limits: query answers are cut at about 60 KB; aggregate in the query (sum, topk, rate) and keep ranges short. Dashboards saved in the newer v2 schema (Grafana 12 dashboards with tabs or auto grid layouts) may not be readable through this API; Grafana then answers with an error naming the new API.

Common errors

  • 401 Invalid API key: the token is wrong, expired or deleted, or GRAFANA_URL points at another stack.
  • 403 You'll need additional permissions: the service account's role is too low (Admin for users and teams, Editor for annotations), or on Grafana Cloud and Enterprise it lacks query permission on that data source.
  • 404: no dashboard, data source or rule with that uid in this organization, or a wrong GRAFANA_URL path.
  • 400 on a query: the expression is not valid for that data source; the message says why.

Out of scope here: creating or changing dashboards, data sources, alert rules, contact points, silences and users; Grafana OnCall and Incident; the Grafana Cloud stack API; all deletes.

你的 AI 距离 Grafana 仅两次点击。

安装连接器、粘贴凭据、向 AI 提问。7 天免费,无需信用卡。