Clickhouse Managed Postgres Rca

作者 ClickHouse2f6ec4b17a81Apache-2.0544 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫9 天前更新

MUST USE when investigating performance issues on a ClickHouse-managed Postgres instance. Provides an evidence-based RCA workflow that scrapes the Prometheus endpoint for system signal, pulls per-digest evidence from the Slow Query Patterns API, and recommends (does not apply) a fix.

僅含說明DevOps & Cloud
AI 產生的概覽

針對 ClickHouse 代管 Postgres 執行個體效能問題、以證據為基礎的根因分析工作流程。

功能
引導代理依六個步驟調查 ClickHouse 代管 Postgres 服務的變慢、高 CPU、低輸送量或快取抖動問題。它會探索即時 API 結構、抓取 Prometheus 指標以取得系統量測值、拉取依摘要分組的慢查詢模式統計、將合併訊號與啟發式形態比對,並撰寫建議。它從不套用修正,不執行 DDL,也不取消或終止後端程序。
適用情境
當使用者回報 ClickHouse 代管 Postgres 執行個體出現無法解釋的效能問題(例如變慢、高 CPU、低輸送量或快取抖動)時使用。它適用於讀取路徑全表掃描、應用程式熱迴圈與寫入壅塞情境,當訊號不符合任何已知形態時會停下來詢問使用者。
執行需求
需要 ClickHouse Cloud API 金鑰與密鑰組進行 HTTP 基本驗證,以及目標 Postgres 服務的 organizationId 與 serviceId。需要網路存取 api.clickhouse.cloud 以取得 OpenAPI 規格、Prometheus 指標與 Beta 版慢查詢模式 API。僅為指示文件,未隨附指令碼。

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/agent-skills位於skills/clickhouse-managed-postgres-rca提交2f6ec4b

授權條款: Apache-2.0

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架

更多來自 ClickHouse/agent-skills 的技能

Clickhouse Js Node Troubleshooting

ClickHouse

排查並解決 ClickHouse Node.js 客戶端(@clickhouse/client)的常見錯誤與設定問題。

Software Development5449 天前更新

Clickhouse Best Practices

ClickHouse

依據 31 條最佳實務規則審查 ClickHouse 的結構定義、查詢與寫入策略。

Data & Analytics5449 天前更新

Clickhouse Architecture Advisor

ClickHouse

針對特定工作負載指導 ClickHouse 架構決策,並將每項建議標註為官方、推導或經驗。

Data & Analytics5449 天前更新

Chdb Sql

ClickHouse

Use when the user wants to run SQL — especially analytical SQL — on local files (parquet/csv/json), URLs, S3 paths, or remote databases (Postgres, MySQL, MongoDB, ClickHouse Cloud, Iceberg, Delta Lake) without setting up a server. Provides chDB — embedded ClickHouse SQL in Python with 1000+ functions, Session for stateful multi-step pipelines, parametrized queries, and cross-source joins via `s3()`, `mysql()`, `postgresql()`, `iceberg()`, `deltaLake()`, `remoteSecure()` table functions. TRIGGER when: user wants SQL on parquet/csv/files or across remote analytical sources; uses ClickHouse SQL features (window functions, windowFunnel, geoToH3, JSON path ops, Session, parametrized queries); imports `chdb` or calls `chdb.query()`. SKIP this skill for pandas-style DataFrame method-chaining (use chdb-datastore instead) or ClickHouse server administration.

包含腳本
待分類5449 天前更新

Chdb Datastore

ClickHouse

使用 chdb DataStore 作為 pandas 的替代方案,以 ClickHouse 為底層查詢、合併與彙總表格資料。

包含腳本
Data & Analytics5449 天前更新