PluginBench
Skill
Fail
Audit score 45

clickhouse-managed-postgres-rca

clickhouse/agent-skills

Root-cause analysis for ClickHouse-managed Postgres performance issues using Prometheus metrics and slow query patterns.

What is clickhouse-managed-postgres-rca?

Diagnoses performance problems on ClickHouse-managed Postgres instances by correlating Prometheus system metrics with slow query pattern data. Use this when investigating slowness, high CPU, low throughput, or cache issues on a managed Postgres service.

  • Scrapes Prometheus metrics (cache hit ratio, active connections, memory and filesystem usage) for system-level signals
  • Retrieves per-query slow query patterns with latency, IO, and call statistics via the Slow Query Patterns API
  • Matches combined signals to diagnostic heuristics (full scans, N+1 loops, write congestion)
  • Generates evidence-based root-cause hypotheses with short-term and long-term recommendations
  • Discovers live API shape dynamically from OpenAPI spec to handle schema changes
  • Recommends fixes without applying them, preserving human control over production changes

How to install clickhouse-managed-postgres-rca

npx skills add https://github.com/clickhouse/agent-skills --skill clickhouse-managed-postgres-rca
Prerequisites
  • ClickHouse Cloud API key and secret pair
  • Organization ID and service ID for the target Postgres instance
  • Network access to https://api.clickhouse.cloud
Claude Code
Cursor
Windsurf
Cline

How to use clickhouse-managed-postgres-rca

  1. 1.Provide the organization ID, service ID, and API credentials when prompted
  2. 2.The skill will fetch the OpenAPI spec to discover current API field names and paths
  3. 3.System metrics are scraped once from Prometheus for current-state gauges
  4. 4.Slow query patterns are retrieved for the configured time window
  5. 5.Combined signals are matched against diagnostic heuristics (full scan, hot loop, write congestion)
  6. 6.Review the generated root-cause hypothesis, evidence, and recommendations
  7. 7.Apply recommended fixes manually in your Postgres instance

Use cases

Good for
  • Investigating unexplained slowness or high CPU on a ClickHouse-managed Postgres instance
  • Diagnosing cache thrash or low throughput in production workloads
  • Identifying N+1 query patterns or hot loops causing performance degradation
  • Triaging write-path congestion, deadlocks, or high rollback rates
  • Correlating system metrics with query-level evidence for targeted optimization
Who it's for
  • Database engineers supporting ClickHouse-managed Postgres instances
  • DevOps teams investigating production performance incidents
  • Application developers optimizing database query patterns
  • SREs performing root-cause analysis on managed database services

clickhouse-managed-postgres-rca FAQ

Does this skill apply fixes automatically?

No. It recommends fixes only and explains why. You must apply any DDL changes, query rewrites, or backend terminations manually.

What if no slow query patterns are returned?

The skill will surface this and ask which workload you recognize. The reported issue may be overstated or not query-shaped.

Can I use this for write-path issues like deadlocks?

Yes. For write congestion, the skill can optionally scrape Prometheus twice to measure counter deltas (deadlock and rollback rates) in addition to the single-scrape baseline.

What data does this skill NOT have access to?

Query plans, EXPLAIN output, per-table scan counters (seq_scan/idx_scan), and autovacuum or ANALYZE timestamps. Reasoning is based on IO and timing signals instead.

How long does the RCA workflow take?

Approximately 1 second. Steps 2 and 3 run in parallel to minimize wall time.

Full instructions (SKILL.md)

Source of truth, from clickhouse/agent-skills.


name: clickhouse-managed-postgres-rca description: 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. license: Apache-2.0 metadata: author: ClickHouse Inc version: "0.1.0"

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.