clickhouse-managed-postgres-rca

作者: clickhouse

在調查 ClickHouse 管理的 Postgres 實例效能問題時必須使用。提供基於證據的 RCA 工作流程,可抓取 Prometheus…

npx skills add https://github.com/clickhouse/agent-skills --skill clickhouse-managed-postgres-rca

ClickHouse Managed Postgres RCA

When to use

Trigger whenever a user reports slowness, high CPU, low throughput, cache thrash, or any unexplained pain on a ClickHouse-managed Postgres instance.

What you have access to

Two APIs on https://api.clickhouse.cloud (HTTP Basic auth using a ClickHouse Cloud API key/secret pair):

  • Prometheus metrics — operation postgresInstancePrometheusGet under the Prometheus tag. Returns Prometheus exposition format. System and workload metrics for one Postgres service.
  • Slow Query Patterns — operation slowQueryPatternsGetList under the Postgres tag. Returns per-digest latency, IO, and call statistics for normalized query patterns. Beta.

Both endpoints require an organizationId and a serviceId as path parameters. The user must supply both, plus the API key/secret pair.

What you do NOT have

  • Query plans / EXPLAIN output.
  • Per-table scan-type counters (seq_scan / idx_scan).
  • Autovacuum or last-ANALYZE timestamps.

Reason from IO and timing signals, not from a plan tree.

Workflow

Six steps, in order. Do not skip ahead.

Steps 2 and 3 only share auth — no data dependency between them. Run them in parallel (background curls, & + wait) to cut wall time from sequential ~2s to ~1s.

1. Discover the live API shape

These endpoints are Beta — paths, params, and JSON field names can shift. Follow rules/openapi-discovery.md to:

  1. Fetch the OpenAPI spec from https://api.clickhouse.cloud/v1.
  2. Locate the two operations by operationId:
    • postgresInstancePrometheusGet (Prometheus tag)
    • slowQueryPatternsGetList (Postgres tag)
  3. Resolve their path templates, required query parameters, and (for the slow-query endpoint) the response schema.
  4. Build a session-scoped role map from the schema property descriptions: { semantic role → actual field name }.

Use the resolved names in every subsequent request and citation. Never hardcode field names from memory.

2. Scrape Prom once for system gauges

Follow rules/prometheus-scrape.md. One scrape, no wait. You're after gauges (current values) that don't need a delta: CacheHitRatio, ActiveConnections, MemoryUsedPercent, FilesystemUsedPercent.

A CacheHitRatio well below ~95% on a workload that should fit in cache is a real signal on its own. Climbing ActiveConnections toward the pool ceiling is a real signal on its own. These don't need rate-of-change.

A second scrape for counter deltas is opt-in, used only when Step 4 triage points at write-congestion (where deadlock and rollback rates matter and the Slow Query Patterns API can't substitute). For the read-path case (the most common RCA shape) the single scrape is enough.

3. Pull top slow query patterns

Request the slow query patterns. Follow rules/slow-query-patterns-fields.md for the fields that matter and how to read them. This is the primary diagnostic — it returns per-pattern accumulated totals (call count, runtime, blocks, rows) over the window you request, which is the "rate-of-change" data you'd otherwise derive from two Prom scrapes — but per query and without waiting.

If no patterns return a meaningful totalDurationUs, the report may be overstated or the issue isn't query-shaped. Stop and tell the user what you looked at.

4. Triage: pick the right heuristic

Follow rules/triage.md. Match the combined Prom + slow-query signal to one of the heuristic shapes. Each shape points to a specific heuristic file:

  • rules/heuristic-full-scan.md — read-path full scan.
  • rules/heuristic-hot-loop.md — N+1 / hot loop from the app.
  • rules/heuristic-write-congestion.md — deadlocks, slow writes, high rollback rate.

If the signal does not match any shape cleanly, do not invent a hypothesis. Surface the top patterns and ask the user which workload they recognize. New heuristics are welcome as PRs.

5. Reason, then recommend

Use the format in rules/output-template.md. Always include: symptom, evidence, hypothesis (noting any alternative cause you cannot rule out from this surface alone), short-term fix, and long-term follow-ups.

6. Do not apply the fix

Follow rules/recommend-only.md. Never run DDL. Never call pg_cancel_backend or pg_terminate_backend. Write the recommendation, explain why, and let the human apply it.

Full Compiled Document

For the complete guide with every rule expanded in a single context load: AGENTS.md.

來自 clickhouse 的更多技能

clickhouse-best-practices
clickhouse
我们要求翻译一段文本,目标语言是繁体中文。文本内容是关于ClickHouse最佳实践的规则,包括模式设计、查询优化和数据摄取策略。需要保留名称"clickhouse-best-practices"(但名称不在<text>内,所以不翻译)。注意不要添加额外内容,只翻译<text>内的文字。 翻译时注意专业术语:schema design -> 模式設計,query optimization -> 查詢優化,data ingestion strategy -> 數據攝取策略,primary key -> 主鍵,data type selection -> 數據類型選擇,immutable design decisions -> 不可變設計決策,JOIN -> JOIN(保留),insert batching -> 插入批次處理,mutation avoidance -> 避免突變,columnar storage -> 列式存儲,sparse index mechanics -> 稀疏索引機制,structured review procedures -> 結構化審查程序。 注意繁体中文用词:规则、组织、涵盖、关键、标记、提供等。 文本末尾有"for...",但原文是"for..."后面没有完整
official
clickhouse-js-node-coding
clickhouse
Write idiomatic application code with the ClickHouse Node.js client (`@clickhouse/client`). Use this skill whenever a user is *building* against the Node.js…
official
clickhousectl-cloud-deploy
clickhouse
當用戶想要將ClickHouse部署到雲端、上線生產環境、使用ClickHouse Cloud、託管受管理的ClickHouse服務,或從本地遷移時使用。
official
clickstack-otel-collector
clickhouse
當使用者想要將 OpenTelemetry collector 接入 ClickHouse Cloud 上的 Managed ClickStack 服務時使用,無論是透過部署新的本地 collector…
official
infra-clickhouse
clickhouse
使用clickhousectl CLI設定及管理ClickHouse——安裝並執行本機ClickHouse伺服器以利開發,同時建立受管理的ClickHouse Cloud…
official
infra-postgres
clickhouse
使用 clickhousectl CLI 設定並管理 Postgres — 執行本機 Docker 支援的 Postgres 以進行開發,並建立及操作受管理的 ClickHouse…
official
clickhouse-best-practices
clickhouse
審查 ClickHouse 結構、查詢或配置時必須使用。包含 31 條規則,在提供建議前必須檢查。務必閱讀…
official
setup
clickhouse
引導用戶設定與此插件捆綁的 ClickHouse MCP 伺服器連線。當用戶首次安裝插件或遇到問題時使用…
official