连接器指南阅读约 4 分钟16 个 MCP 工具7 种语言

如何通过 MCP 将 Grafana 连接到 Claude

让你的 AI 读取你的 Grafana:搜索仪表板并查看其面板和查询,查询 Prometheus、Loki 和 SQL 数据源,查看哪些告警正在触发以及规则是如何定义的,读取和添加注释,并列出联系点、用户和团队。支持 Grafana Cloud 和自托管的 Grafana。

HC作者:HelpCode 团队更新于 4 分钟阅读 在 GitHub 开源

无需信用卡 · 7 天试用 · 提供自托管方案

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.

个工具

16

区域

INTL

类别

监控

身份验证

Bearer Token

所需环境变量

GRAFANA_URLGRAFANA_SERVICE_ACCOUNT_TOKEN
在 Cloud 上一键安装

7 天免费试用 · 无需信用卡

  • 7 天免费试用
    无需信用卡
  • 符合 GDPR,SOC 2 就绪
    数据驻留欧盟,审计日志
  • 在 GitHub 开源
    开源 · AGPL-3.0
  • 支持 ChatGPT、Claude、Gemini
    任何兼容 MCP 的客户端

跳过安装。2 分钟内即可运行。

在 cloud.anythingmcp.com 开始免费试用,一键添加 Grafana,然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。

开始免费试用

AnythingMCP 已收录在 Claude 的连接器目录中:一键添加到 Claude (在新标签页中打开),然后登录并选择 Claude 可以使用哪些 MCP 服务器。

摘要

让你的 AI 读取你的 Grafana:搜索仪表板并查看其面板和查询,查询 Prometheus、Loki 和 SQL 数据源,查看哪些告警正在触发以及规则是如何定义的,读取和添加注释,并列出联系点、用户和团队。支持 Grafana Cloud 和自托管的 Grafana。

试试这样问

Grafana 的示例提示

点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。

Grafana · 通过 MCP 实时
分享
Opus 4.7

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

💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → Grafana、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无 git clone、无本地服务器。

Grafana + Claude

让你的 AI 读取你的 Grafana:搜索仪表板并查看其面板和查询,查询 Prometheus、Loki 和 SQL 数据源,查看哪些告警正在触发以及规则是如何定义的,读取和添加注释,并列出联系点、用户和团队。支持 Grafana Cloud 和自托管的 Grafana。

前提条件

完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:

GRAFANA_URL, GRAFANA_SERVICE_ACCOUNT_TOKEN

步骤 1 — 获取凭证

  1. 把 GRAFANA_URL 设为你打开 Grafana 时使用的地址,末尾不要带斜杠:Grafana Cloud 上是 https://your-stack.grafana.net,自有地址则如 https://grafana.example.com(如果 Grafana 运行在某个路径下,则为 https://example.com/grafana)。在 AnythingMCP Cloud 上,该实例必须能从互联网访问。
  2. 在 Grafana 中打开 Administration → Users and access → Service accounts,点击 Add service account,为它命名(例如 AnythingMCP),并赋予 Viewer 角色。
  3. 打开该服务账户,点击 Add service account token,选择有效期并复制令牌。它以 glsa_ 开头,Grafana 只显示一次。
  4. 把它粘贴到 GRAFANA_SERVICE_ACCOUNT_TOKEN,不要加 Bearer 一词,然后安装连接器。令牌只能访问该服务账户所属的组织。
  5. 用 grafana_get_current_org 检查设置:它会显示令牌对应的组织。grafana_get_health 即使没有令牌也会响应,因此它会显示 Grafana 版本,但不能证明令牌可用。

选择哪个角色:Viewer 涵盖仪表板、文件夹、数据源、查询、告警规则、正在触发的告警、注释和联系点。列出用户和团队需要 Admin,添加注释需要 Editor。在 Grafana Cloud 和 Grafana Enterprise 上,服务账户还需要对每个要读取的数据源拥有查询权限。

它能做什么:搜索仪表板和文件夹,读取仪表板的面板及其 PromQL、LogQL 或 SQL 查询;通过 Grafana 对 Prometheus(或 Mimir)、Loki 和 SQL 数据源运行查询;查看当前有哪些告警正在触发、它们的规则如何定义,以及哪些联系点会收到通知;读取在图表上标记部署和事故的注释;列出组织的用户和团队。

只有一项修改,而且 AI 会先问你:连接器唯一能做的修改是用 grafana_create_annotation 添加注释,所有人都会在仪表板上看到它。添加之前,AI 会给你看文本、时间和标签,并等你同意。这里没有任何操作会修改仪表板、数据源或告警规则,也不会删除任何内容。

机密信息留在 Grafana 中:数据源的密码和密钥永远不会返回;联系点也不附带其设置,因为设置中包含 Webhook URL 和密钥。

限制:查询结果在约 60 KB 处截断,因此 AI 会在查询中进行聚合(sum、topk、rate),并让时间范围保持较短。以较新的 v2 schema 保存的仪表板(带标签页或自动网格布局的 Grafana 12 仪表板)可能无法通过此 API 读取;这时 Grafana 会返回一个指明新 API 的错误。

常见错误:401 Invalid API key:令牌错误、已过期或已删除,或者 GRAFANA_URL 指向了另一个 stack。403:服务账户的角色太低(用户和团队需要 Admin,注释需要 Editor),或者它对该数据源没有查询权限。404:此组织中没有该 uid 的仪表板、数据源或规则,或者 GRAFANA_URL 中的路径有误。查询返回 400:表达式对该数据源无效,错误信息会说明原因。

该连接器不会创建或修改仪表板、数据源、告警规则、联系点、静默规则或用户,不会删除任何内容,也不涉及 Grafana OnCall、Grafana Incident 或 Grafana Cloud stack API。

步骤 2 — 安装 adapter

curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d

步骤 3 — 在 Claude 中添加连接器

你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(https://cloud.anythingmcp.com/mcp/…)。本指南中出现 YOUR_SERVER_ID 的地方都用它替换。

推荐路径:在 claude.ai web 上工作,无需触碰任何配置文件。

  1. 在 Claude 中打开 Customize → Connectors。
  2. 点击 +,然后点击 Add custom connector。
  3. 输入名称(例如 Grafana)和远程 MCP 服务器 URL https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID,然后点击 Add。
  4. 点击 Connect,登录 AnythingMCP(OAuth)并允许访问。

下面所有工具都会出现在你的聊天中,开始输入提示。

可用工具

ToolWhat it does
grafana_get_healthCheck that the Grafana instance is up: database state, Grafana version and commit
grafana_get_current_orgRead the Grafana organization the service account token belongs to: id and name
grafana_searchSearch dashboards and folders by title, tag or folder: uid, title, type (dash-db for dashboards, dash-folder for folders), tags, folder and…
grafana_list_foldersList folders: uid and title, top level by default or the subfolders of a parent
grafana_get_dashboardRead a dashboard by uid in a compact form: title, tags, folder, time range, variables (name, type, current value) and panels with id…
grafana_list_datasourcesList the data sources: uid, name, type (prometheus, loki, postgres...), URL, access mode and which one is the default
grafana_get_datasourceRead one data source by uid: name, type, URL, access mode, default flag and its non-secret settings (jsonData)
grafana_query_datasourceRun a query against a data source through Grafana and return the result frames: a PromQL query for Prometheus or Mimir, a LogQL query for…
grafana_list_alert_rulesList the Grafana-managed alert rules: uid, title, folder, rule group, paused or not, pending period (for), labels, summary, what happens on…
grafana_get_alert_ruleRead one alert rule by uid: title, folder, group, condition, the queries and expressions it evaluates (data source uid, expression, time…
grafana_list_firing_alertsList the alert instances in Grafana's Alertmanager, by default the active ones (firing): alert name and labels, summary and description…
grafana_list_annotationsList annotations (event markers on graphs such as deployments or incidents, and alert state changes): id, time and end time (epoch…
grafana_create_annotationAdd an annotation (an event marker such as a deployment, incident or maintenance window) that shows on graphs for everyone who opens the…
grafana_list_org_usersList the users of the organization: user id, login, email, name, role (Viewer, Editor, Admin), last seen and disabled flag
grafana_search_teamsSearch the teams of the organization: id, uid, name, email and member count
grafana_list_contact_pointsList the alerting contact points (where notifications go): uid, name, integration type (email, slack, pagerduty, webhook...) and whether…

示例提示

  • “Grafana 里现在有哪些告警正在触发?对每个告警,给我看它背后的规则以及接收通知的联系点。”
  • “找到我们的 API 延迟仪表板,解释每个面板显示什么、运行的是哪个查询。”
  • “在 Prometheus 中查询过去一小时每个服务的 5xx 响应速率,告诉我哪个服务最差。”
  • “给我看 Loki 在过去 30 分钟内为 checkout 应用记录的错误日志行,并按消息分组。”
  • “在今天 14:05 添加一条注释‘Deployed v2.4.1’,标签为 deploy。添加前先给我看文本、时间和标签。”

FAQ

Claude Code 和 Claude Desktop 一样工作吗? 是的,两者都指向 https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID。

下一步

这份指南对你有帮助吗?

你的 Grafana 智能体只差一次点击。

安装连接器,粘贴密钥,向 Claude 提问。免费试用 7 天,无需信用卡。

相关指南

连接器

如何通过 MCP 将 Grafana 连接到 ChatGPT

让你的 AI 读取你的 Grafana:搜索仪表板并查看其面板和查询,查询 Prometheus、Loki 和 SQL 数据源,查看哪些告警正在触发以及规则是如何定义的,读取和添加注释,并列出联系点、用户和团队。支持 Grafana Cloud 和自托管的 Grafana。

连接器

如何通过 MCP 将 Grafana 连接到 Cursor

让你的 AI 读取你的 Grafana:搜索仪表板并查看其面板和查询,查询 Prometheus、Loki 和 SQL 数据源,查看哪些告警正在触发以及规则是如何定义的,读取和添加注释,并列出联系点、用户和团队。支持 Grafana Cloud 和自托管的 Grafana。

连接器

如何通过 MCP 将 Grafana 连接到 Gemini

让你的 AI 读取你的 Grafana:搜索仪表板并查看其面板和查询,查询 Prometheus、Loki 和 SQL 数据源,查看哪些告警正在触发以及规则是如何定义的,读取和添加注释,并列出联系点、用户和团队。支持 Grafana Cloud 和自托管的 Grafana。

连接器

如何通过 MCP 将 Grafana 连接到 Meta Muse

让你的 AI 读取你的 Grafana:搜索仪表板并查看其面板和查询,查询 Prometheus、Loki 和 SQL 数据源,查看哪些告警正在触发以及规则是如何定义的,读取和添加注释,并列出联系点、用户和团队。支持 Grafana Cloud 和自托管的 Grafana。

连接器

Grafana 接入 MCP:在任意 AI 代理中使用仪表板、查询和告警

让你的 AI 读取你的 Grafana:搜索仪表板并查看其面板和查询,查询 Prometheus、Loki 和 SQL 数据源,查看哪些告警正在触发以及规则是如何定义的,读取和添加注释,并列出联系点、用户和团队。支持 Grafana Cloud 和自托管的 Grafana。

连接器

如何通过 MCP 将 Avito 连接到 Claude

让你的 AI 使用你的 Avito 企业账户:列出广告并修改价格,读取浏览、联系和来电统计,检查自动上传 (autoload) 的上传记录及其错误、Feed 格式和钱包,并读取 Avito Messenger 聊天。发送消息和修改自动上传设置为可选功能,默认关闭。