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.

rulesheuristic-write-congestion.md

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

Heuristic: write-path congestion

Use when the triage decision tree pointed here: top patterns have <db_operation> of INSERT/UPDATE/DELETE with large <total_wal_bytes>, or the user reports symptoms (timeouts, retries) that this skill's per-pattern view alone can't confirm.

This is the one heuristic that may need the opt-in second Prom scrape (see prometheus-scrape.md) — specifically to get a non-zero delta on PostgresServer_Deadlocks_Total and a rollback/commit ratio from PostgresServer_TransactionsRolledBack_Total vs _Committed_Total. Neither is exposed in Slow Query Patterns.

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

The shape

Three sub-patterns live under "write congestion." Distinguish before recommending.

Sub-pattern A: deadlocks

PostgresServer_Deadlocks_Total delta > 0 over the window. At least two concurrent transactions are taking locks in incompatible orders.

Recommend:

  • Surface the deadlock count and ask the user to check Postgres logs for deadlock detected entries — these log the exact statements involved, which the API doesn't.
  • Common cause: two transactions update the same set of rows in different orders. Fix is application-side: lock rows in a consistent order (e.g., always sort by primary key before issuing updates).

Sub-pattern B: slow individual writes

One write pattern with high <avg_duration>. Could be a wide row insert under contention, a large update touching many rows, or WAL congestion under heavy concurrent writes.

Recommend:

  • For wide rows: check column count and TOAST-eligible fields. Consider whether some columns belong in a side table.
  • For wide updates (high <total_rows> per call): batch into smaller chunks with explicit transactions, so each chunk commits separately.
  • For concurrent-write pressure: surface <total_wal_bytes>. If high, the bottleneck is WAL flush — the user may need to tune commit_delay / synchronous_commit (with durability tradeoffs the user must own) or scale the instance.

Sub-pattern C: high error rate

<error_count> is unusually large relative to <call_count>, or PostgresServer_TransactionsRolledBack_Total delta is high relative to commits.

Recommend:

  • Application is throwing exceptions mid-transaction or hitting serialization conflicts on SERIALIZABLE / REPEATABLE READ isolation.
  • Surface the error / rollback rate; ask the user to check app error logs for the actual exception traces — the API doesn't expose those.

What NOT to recommend

  • An index — write congestion is rarely indexed away. More indexes make writes slower.
  • Vacuum tuning unless there's specific evidence of bloat — this surface doesn't expose bloat metrics, so don't guess.
  • Hardware sizing — out of scope for a single-pattern RCA. Surface the WAL/commit pressure and recommend the user discuss with their account team.

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.