使用 Grafana Cloud 的指标 API
Grafana Cloud 为你提供了一个完全托管的 Prometheus 端点以及托管的 Grafana 仪表板,这使得探索 Supabase Metrics API 成为最快的方式,而无需自己管理基础设施。
🌐 Grafana Cloud gives you a fully managed Prometheus endpoint plus hosted Grafana dashboards, which makes it the fastest way to explore the Supabase Metrics API without operating your own infrastructure.
安装 #
🌐 Installation
Grafana Cloud 集成可以在 Supabase 仪表板中使用。添加集成 并选择一个项目,即可一键获取完全配置的实例:认证、指标抓取,以及一个自动设置的预建仪表板,跟踪 200 多个指标。
🌐 The Grafana Cloud integration is available in the Supabase Dashboard. Add the integration and select a project to get a fully-configured instance in one click: authentication, metric scraping, and a pre-built dashboard tracking 200+ metrics, set up automatically.
通过将 Supabase 与 Grafana Cloud 集成,用户可以监控 Supabase 的性能和运行情况。附带的仪表板提供了对 Supabase 性能的全面概览,并辅以 Postgres 指标。
🌐 By integrating Supabase with Grafana Cloud, users gain monitoring capabilities for Supabase performance and operations. The included dashboard offers a comprehensive overview of Supabase performance, supplemented with Postgres metrics.
手动设置 #
🌐 Manual setup
Supabase 仪表板中提供的 Grafana Cloud 集成 是推荐的方式。你仍然可以按照以下步骤手动配置和运行设置。
🌐 The Grafana Cloud integration available in the Supabase Dashboard is the recommended path. You can still configure and run the setup manually by following the steps below.
只有在你需要完全手动控制(自定义抓取拓扑、自己部署的 Prometheus 或非标准认证)时才使用这个指南。
🌐 Use this guide only if you need full manual control (custom scrape topology, self-hosted Prometheus or non-standard auth).
先决条件 #
🌐 Prerequisites
- 一个可以访问指标 API 的 Supabase 项目(秘密 API 密钥
sb_secret_...)。 - 一个启用了 Prometheus 指标的 Grafana Cloud 账户(免费或专业版)。
- 如果你打算手动推送数据,需要一个带有
metrics:write和metrics:read权限的 Grafana API 令牌。
1. 创建一个 Grafana Cloud 堆栈 #
🌐 1. Create a Grafana Cloud stack
- 登录到 Grafana Cloud。
- 创建或选择一个已启用 Prometheus 指标 的堆栈。
2. 为 Grafana Cloud 安装 Supabase 集成 #
🌐 2. Install the Supabase integration for Grafana Cloud
- 在你的 Grafana Cloud 套件中,点击左侧菜单的 Connections。
- 选择 Supabase 集成,然后按照 配置 页面上列出的步骤操作:
- 给你的抓取任务起个描述性的名字,比如
production-eu-central-1。 - 设置你的项目ID并输入服务账户API密钥。
- 测试连接并保存抓取任务。
- 一旦抓取作业配置好后,点击安装就可以把预建仪表板添加到你的 Grafana Cloud 实例里。
3. 配置 Supabase 集成 #
🌐 3. Configure the Supabase integration
- 在 Grafana Cloud 中导航到 连接 → 添加新连接 → Supabase。
- 提供:
- 你的 Supabase 项目引用(例如
abcd1234)。 - 指标 API 端点(例如
https://<project-ref>.supabase.co/customer/v1/privileged/metrics)。 - HTTP 基本认证凭据(
sb_secret_...)。
- 你的 Supabase 项目引用(例如
- 选择抓取间隔。推荐1分钟,并测试连接。Grafana Cloud 会在后台部署一个代理,抓取指标 API 并将数据转发给 Prometheus。
如果你更愿意重用现有的 Grafana Agent 部署,可以使用相同的 URL 和凭据来配置一个 集成管道。
🌐 If you prefer to reuse an existing Grafana Agent deployment, configure an integration pipeline with the same URL and credentials.
4. 导入 Supabase 仪表板 #
🌐 4. Import the Supabase dashboard
- 打开你的 Grafana Cloud 仪表板列表,然后点击 新建 → 导入。
- 粘贴
supabase-grafana/dashboard.json的原始内容。 - 当系统提示选择数据源时,选择接收 Supabase 指标的 Prometheus 实例。
这个仪表板包括 200 多个图表,按 CPU、IO、连接、复制、WAL 和膨胀指标分组。
🌐 This dashboard includes 200+ charts grouped by CPU, IO, connections, replication, WAL, and bloat indicators.

5. 配置提醒(可选) #
🌐 5. Configure alerts (optional)
docs/example-alerts.md 文件包含建议的告警规则(磁盘饱和、长时间运行的查询、复制延迟等)。将这些告警规则导入到 Grafana Cloud 的告警界面,或将它们转换为 Grafana Cloud 的托管告警规则格式。
🌐 The docs/example-alerts.md file contains suggested alert rules (disk saturation, long-running queries, replication lag, etc.). Import the alert rules into Grafana Cloud’s Alerting UI or translate them into Grafana Cloud’s managed alert rule format.
6. 故障排除 #
🌐 6. Troubleshooting
- 指标丢失了吗?请确保 Grafana Cloud 代理能够访问
https://<project-ref>.supabase.co,并且所选的 Secret API 密钥仍然有效。 - 401 错误?在 项目设置 → API 密钥 中创建/轮换一个新的 Secret API 密钥,并更新 Grafana Cloud 凭据。
- 抓取时间很长?降低 Grafana 查询中的标签基数,或者缩短时间范围以专注于最近的数据。