All skills
clickhouse avatar

/clickhouse-managed-postgres-rca

@544384f official
by clickhouseclickhouse/agent-skills543 stars
39

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.

Use this Skill: https://skilld.dev/gh/clickhouse/agent-skills/clickhouse-managed-postgres-rca

This session only. Nothing lands on disk.

rulestriage.md

≈798 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Triage

A decision tree for picking the right heuristic. Run this after scraping Prometheus and pulling slow query patterns, but before applying any specific heuristic.

Field names below reference roles from your session's role map (per openapi-discovery.md).

Step 1 — Read system context from the single Prom scrape

From the gauges in prometheus-scrape.md:

  • CacheHitRatio well below ~95% on a workload that should fit in cache → cache thrash, real signal on its own.
  • ActiveConnections near the pool ceiling → client fan-out or stuck queries.
  • All gauges healthy → the system is fine; whatever's slow is per-query, not system-wide. Move on to Step 2.

(Confirm Prom metric names against the live scrape; user-facing docs are at https://clickhouse.com/docs/cloud/managed-postgres/monitoring/metrics.)

Note: the per-pattern rate-of-change data you'd otherwise derive from two Prom scrapes lives in Slow Query Patterns — that's Step 2. You only need a second Prom scrape when this step or Step 2 hints at write-congestion (see heuristic-write-congestion.md).

Step 2 — What does the slow query pattern shape look like?

Read the top 3 patterns by <total_duration> after filtering out CH Cloud internal probes (see slow-query-patterns-fields.md → "Expect ClickHouse Cloud internal probes"). For each, look at the relationship between <call_count>, <avg_duration>, <total_rows>, and <blocks_read_from_disk> + <blocks_served_from_cache>:

Pattern shape Likely cause Apply heuristic
One pattern dominates; high blks_touched_per_row; low derived cache hit ratio Full scan (missing or unused index) heuristic-full-scan.md
One pattern dominates; huge <call_count>, tiny <avg_duration>, large <total_duration> N+1 / hot loop in the app heuristic-hot-loop.md
High <avg_duration>, low <blocks_read_from_disk> and <blocks_served_from_cache> per call Likely waits/locks (this skill can't fully confirm) Surface and ask user to check pg_stat_activity
Many patterns simultaneously slow; low derived cache hit ratio across them Capacity / cache thrash Surface as a capacity concern, not a per-query fix
Top patterns have <db_operation> of INSERT/UPDATE/DELETE with high <total_wal_bytes> Write-path congestion heuristic-write-congestion.md

Step 3 — If signal is ambiguous, do not invent

If no single pattern matches a row above, report the top three with their key ratios and ask the user which one corresponds to a workload they recognize. Do not pick a heuristic at random.

What this skill does NOT cover yet

  • Replication lag.
  • Schema bloat / autovacuum starvation.
  • TLS/connection-pool misconfiguration.
  • Specific query rewrites (the heuristics recommend indexes/batching, not query refactors).

If the signal points at one of the above, say so and surface it rather than forcing a fit. New heuristics for these patterns are welcome as PRs.

Source: SKILL.md on GitHub

1 alert3mo3 checks · Risk SAFE
  • Gen Agent Trust Hub3mo

    This skill provides a structured diagnostic workflow for ClickHouse-managed Postgres instances. It fetches system metrics and query patterns from official ClickHouse Cloud APIs to identify performance bottlenecks like full scans or hot loops. It includes a strong 'recommend-only' guardrail, ensuring no modifications are made to the database.

  • Socket3mo

    No alerts

  • Snyk3mo

    Risk: HIGH · 3 issues

Signed by skilld at 544384f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 4 months ago
metadata
{
  "author": "ClickHouse Inc",
  "version": "0.1.0"
}
  • Performance
  • clickhouse
  • postgres
  • rca
  • troubleshooting
  • prometheus
  • slow-query
  • managed-database

README badge

README badge for clickhouse/agent-skills/clickhouse-managed-postgres-rca

Investigates performance issues on ClickHouse-managed Postgres instances by scraping Prometheus metrics and querying the Slow Query Patterns API to identify the root cause. Follows a six-step RCA workflow that reasons from system signals and query digests to recommend (but not apply) fixes like addressing full table scans, N+1 loops, or write congestion.

Generated from the current SKILL.md.

Does this skill work with self-hosted Postgres or only ClickHouse Cloud?
Only ClickHouse Cloud managed Postgres instances. The skill requires the ClickHouse Cloud API endpoints for Prometheus metrics and the Slow Query Patterns API.
What credentials do I need to use this skill?
A ClickHouse Cloud API key and secret pair for HTTP Basic auth, plus the organization ID and service ID for the Postgres instance you're investigating.
Can this skill apply fixes automatically?
No. The skill diagnoses the issue and recommends a fix, but the human must apply it. The skill never runs DDL or backend termination commands.
Does this skill provide query plans or EXPLAIN output?
No. It reasons from Prometheus system metrics and slow query pattern statistics, not from query plans. You will not get per-table scan counts or autovacuum timestamps.
How long does the RCA workflow take?
Approximately 1 second. Steps 2 and 3 (Prometheus scrape and slow query patterns) run in parallel, reducing wall time from ~2s sequential to ~1s.

Generated from the current SKILL.md. These answers refresh after source changes.