Loading...
Loading...
Compare original and translation side by side
| Plugin Kind | Backend | Common Endpoints |
|---|---|---|
| PrometheusDatasource | Prometheus | |
| TempoDatasource | Tempo | |
| LokiDatasource | Loki | |
| PyroscopeDatasource | Pyroscope | |
| ClickHouseDatasource | ClickHouse | N/A (direct connection) |
| VictoriaLogsDatasource | VictoriaLogs | |
| 插件类型 | 后端 | 常用端点 |
|---|---|---|
| PrometheusDatasource | Prometheus | |
| TempoDatasource | Tempo | |
| LokiDatasource | Loki | |
| PyroscopeDatasource | Pyroscope | |
| ClickHouseDatasource | ClickHouse | N/A (direct connection) |
| VictoriaLogsDatasource | VictoriaLogs | |
perses_create_global_datasource(name="prometheus", type="PrometheusDatasource", url="http://prometheus:9090")percli apply -f - <<EOF
kind: GlobalDatasource
metadata:
name: prometheus
spec:
default: true
plugin:
kind: PrometheusDatasource
spec:
proxy:
kind: HTTPProxy
spec:
url: http://prometheus:9090
allowedEndpoints:
- endpointPattern: /api/v1/.*
method: POST
- endpointPattern: /api/v1/.*
method: GET
EOFpercli apply -f - <<EOF
kind: Datasource
metadata:
name: prometheus
project: <project-name>
spec:
default: true
plugin:
kind: PrometheusDatasource
spec:
proxy:
kind: HTTPProxy
spec:
url: http://prometheus:9090
allowedEndpoints:
- endpointPattern: /api/v1/.*
method: POST
- endpointPattern: /api/v1/.*
method: GET
EOFperses_create_global_datasource(name="prometheus", type="PrometheusDatasource", url="http://prometheus:9090")percli apply -f - <<EOF
kind: GlobalDatasource
metadata:
name: prometheus
spec:
default: true
plugin:
kind: PrometheusDatasource
spec:
proxy:
kind: HTTPProxy
spec:
url: http://prometheus:9090
allowedEndpoints:
- endpointPattern: /api/v1/.*
method: POST
- endpointPattern: /api/v1/.*
method: GET
EOFpercli apply -f - <<EOF
kind: Datasource
metadata:
name: prometheus
project: <project-name>
spec:
default: true
plugin:
kind: PrometheusDatasource
spec:
proxy:
kind: HTTPProxy
spec:
url: http://prometheus:9090
allowedEndpoints:
- endpointPattern: /api/v1/.*
method: POST
- endpointPattern: /api/v1/.*
method: GET
EOFundefinedundefined
Or via MCP:
**Gate**: Datasource listed and configuration confirmed. Task complete.
---
或通过MCP:
**准入条件**:数据源已列出且配置确认无误。任务完成。
---| Symptom | Cause | Solution |
|---|---|---|
| Datasource proxy returns 403 Forbidden | | Add the missing endpoint patterns to |
MCP tool | A GlobalDatasource with that name already exists | Use |
| MCP tool fails with invalid plugin kind | The | Use the exact casing: |
| Datasource connectivity test fails (proxy returns 502/504) | Backend URL is unreachable from the Perses server. The server cannot connect to the datasource backend at the configured URL | Verify the backend URL is reachable from the Perses server's network context. For Docker, use |
| Proxy returns TLS handshake error | Backend uses HTTPS but Perses cannot verify the certificate (self-signed or missing CA) | For self-signed certs, configure the CA in the Perses server's trust store or set the |
| Project datasource does not override global datasource | The project datasource | Ensure the project-scoped |
| 症状 | 原因 | 解决方案 |
|---|---|---|
| 数据源代理返回 403 Forbidden | 未配置 | 向 |
MCP工具 | 同名全局数据源已存在 | 改用 |
| MCP工具返回invalid plugin kind错误 | | 使用精确的大小写格式: |
| 数据源连通性测试失败(代理返回502/504) | Perses服务器无法访问配置的后端URL | 验证后端URL在Perses服务器的网络环境中是否可达。对于Docker环境,使用 |
| 代理返回TLS handshake error | 后端使用HTTPS但Perses无法验证证书(自签名证书或缺少CA证书) | 对于自签名证书,可在Perses服务器的信任存储中配置CA证书,或在允许的情况下设置 |
| 项目范围数据源未覆盖全局数据源 | 项目数据源的 | 确保项目范围 |
| Anti-Pattern | Why It Fails | Do This Instead |
|---|---|---|
| Creating all datasources at global scope | Pollutes the namespace, makes per-team access control impossible, and forces every project to see every datasource | Use global scope only for organization-wide defaults. Use project-scoped datasources for team-specific backends |
Omitting | Queries are blocked silently — the proxy returns 403 with no useful error message in dashboards, making debugging difficult | Always define |
Not setting | Dashboard panels cannot auto-discover the datasource. Users must manually select it in every panel, and panel YAML must hardcode the datasource name | Set |
| Using dashboard-scoped datasources when project scope would enable reuse | Dashboard-scoped datasource config is embedded in the dashboard JSON and cannot be shared. Every dashboard that needs it must duplicate the config | Use project-scoped datasources for any datasource used by more than one dashboard. Reserve dashboard scope for true one-off test configurations |
Hardcoding | Breaks when Perses runs in Docker or Kubernetes because | Use container/service names: Docker network names for Compose, K8s service DNS for Helm deployments |
| 反模式 | 失败原因 | 正确做法 |
|---|---|---|
| 所有数据源都创建在全局范围 | 会污染命名空间,无法实现按团队的访问控制,且每个项目都会看到所有数据源 | 仅将全局范围用于组织级默认配置,为团队专属后端使用项目范围数据源 |
HTTP代理数据源省略 | 查询会被静默阻止——代理返回403错误,但仪表板中无有用错误信息,调试难度大 | 始终为每个HTTP代理数据源定义包含 |
未为主数据源设置 | 仪表板面板无法自动发现数据源。用户必须在每个面板中手动选择,且面板YAML必须硬编码数据源名称 | 在每个范围的每种插件类型中,为恰好一个数据源设置 |
| 当项目范围可实现复用仍使用仪表板范围数据源 | 仪表板范围数据源配置嵌入在仪表板JSON中,无法共享。每个需要该数据源的仪表板都必须重复配置 | 对于被多个仪表板使用的数据源,使用项目范围数据源。仅将仪表板范围用于真正的一次性测试配置 |
在非本地部署中硬编码 | 当Perses运行在Docker或Kubernetes中时会失效,因为 | 使用容器/服务名称:Compose环境使用Docker网络名称,Helm部署使用K8s服务DNS |
| Rationalization | Why It's Wrong | Required Action |
|---|---|---|
| "The datasource was created successfully, so it must be working" | Creation succeeding only means the API accepted the resource definition. It does not validate that the backend URL is reachable or that allowedEndpoints are correct | Test the proxy endpoint with a real query: |
| "I don't need allowedEndpoints because I'm only doing GET requests" | Prometheus | Always configure both GET and POST for the relevant endpoint patterns unless the datasource documentation explicitly states only one method is used |
| "Global scope is fine — we can always move it later" | Moving from global to project scope requires deleting the global datasource and recreating it as project-scoped. All dashboards referencing it by name will keep working only if the project datasource name matches exactly. This is a disruptive migration | Choose scope deliberately at creation time. Ask: "Does every project need this, or just one team?" |
| "The datasource type name is probably case-insensitive" | Plugin kind names are case-sensitive Go type identifiers. | Use exact casing: |
| 错误认知 | 错误原因 | 必要操作 |
|---|---|---|
| "数据源创建成功,所以肯定能正常工作" | 创建成功仅表示API接受了资源定义,不验证后端URL是否可达或 | 测试代理端点:使用真实查询调用 |
"我不需要配置 | Prometheus的 | 始终配置GET和POST相关端点模式,除非数据源文档明确说明仅使用一种方法 |
| "全局范围没问题——以后可以再迁移" | 从全局范围迁移到项目范围需要删除全局数据源并重新创建为项目范围数据源。所有引用该数据源的仪表板仅在名称完全相同时才能继续工作。这是一项破坏性迁移 | 创建时谨慎选择范围:询问自己「所有项目都需要这个数据源,还是只有一个团队需要?」 |
| "数据源类型名称应该不区分大小写" | 插件类型名称是区分大小写的Go类型标识符。 | 使用精确的大小写: |
allowedEndpointsmethod: *methoddefault: truepercli get datasource --project <project>allowedEndpointsallowedEndpointsmethod: *methoddefault: truepercli get datasource --project <project>| Resource | URL |
|---|---|
| Perses datasource documentation | https://perses.dev/docs/user-guides/datasources/ |
| Perses HTTP proxy configuration | https://perses.dev/docs/user-guides/datasources/#http-proxy |
| Perses API: GlobalDatasource | https://perses.dev/docs/api/datasource/ |
| Perses MCP server (datasource tools) | https://github.com/perses/perses-mcp-server |
| percli reference | https://perses.dev/docs/user-guides/percli/ |
| Perses GitHub repository | https://github.com/perses/perses |
| 资源 | 链接 |
|---|---|
| Perses 数据源文档 | https://perses.dev/docs/user-guides/datasources/ |
| Perses HTTP代理配置 | https://perses.dev/docs/user-guides/datasources/#http-proxy |
| Perses API: GlobalDatasource | https://perses.dev/docs/api/datasource/ |
| Perses MCP服务器(数据源工具) | https://github.com/perses/perses-mcp-server |
| percli 参考文档 | https://perses.dev/docs/user-guides/percli/ |
| Perses GitHub仓库 | https://github.com/perses/perses |