Skip to main content

Extension won’t load

pg_stat_ch must be loaded at server startup. Add it to postgresql.conf and restart:
Then restart PostgreSQL:

Background worker not running

Check if the exporter process is visible:
If no row appears:
  • Verify shared_preload_libraries includes pg_stat_ch
  • Check PostgreSQL logs for startup errors
  • The worker restarts automatically after 10 seconds if it crashes — check logs for repeated crash/restart cycles

Events not appearing in ClickHouse

1

Check that collection is enabled

Should return on. If off, enable it:
2

Check queue stats

  • enqueued_events = 0: No queries are being captured. Run some queries and check again.
  • enqueued_events > 0 but exported_events = 0: The background worker cannot reach ClickHouse.
  • send_failures > 0: Check last_error_text for the specific error.
3

Check connection settings

Verify ClickHouse is reachable from the PostgreSQL host:
4

Check the ClickHouse schema exists

If the database or tables don’t exist, apply the schema:
5

Check PostgreSQL logs

Look for connection errors or export failures:

High queue usage

If queue_usage_pct from pg_stat_ch_stats() is consistently above 80%:
  1. Decrease flush interval — export more frequently:
  2. Increase batch size — drain more events per cycle:
  3. Check ClickHouse health — slow inserts cause backpressure:
  4. Increase queue capacity (requires restart):

Dropped events

Non-zero dropped_events means the queue filled up before the background worker could drain it. This is safe — queries continue running unaffected — but some telemetry is lost. Common causes:
  • ClickHouse is down or unreachable (events queue up with nowhere to go)
  • A burst of queries exceeded the queue capacity
  • The flush interval is too long for the workload
To reset the counter after resolving the issue:

DSA String Area Full

Check the dsa_oom_count counter:
If it increases, the fixed ring entry was captured but the variable-length query or error text could not be stored. Increase pg_stat_ch.string_area_size and restart PostgreSQL.

Missing I/O timing data

If shared_blk_read_time_us and related columns are always zero:
I/O timing must be enabled in postgresql.conf:
This adds a small overhead (one gettimeofday() call per block I/O operation) but provides valuable data for distinguishing CPU-bound from I/O-bound queries.

Missing query_id values

If query_id is always 0:
Enable query ID computation:
This is required for grouping queries by their normalized form. Without it, every execution gets query_id = 0 and cannot be aggregated.

TLS connection errors

If you see TLS-related errors in PostgreSQL logs:
  1. Verify pg_stat_ch.clickhouse_use_tls = on is set
  2. For self-signed certificates in testing, set pg_stat_ch.clickhouse_skip_tls_verify = on
  3. In production, ensure the ClickHouse server certificate is trusted by the system CA store

Extension health check query

Run this in PostgreSQL for a quick health summary: