Skip to main content
pg_stat_ch provides four SQL functions for checking extension health, viewing statistics, and controlling the export pipeline.

pg_stat_ch_version()

Returns the extension version string.
The version is set at compile time from the git tag.

pg_stat_ch_stats()

Returns queue and exporter statistics as a single row.

Output columns

Monitoring examples

Check if events are flowing:
Check for export errors:
Monitor queue pressure over time (run periodically):

pg_stat_ch_reset()

Resets all queue counters to zero.
This resets enqueued_events, dropped_events, exported_events, and send_failures back to zero. It does not affect the queue contents or ClickHouse data. Useful for establishing a clean baseline before a load test or after resolving an issue.

pg_stat_ch_flush()

Triggers an immediate flush of queued events to ClickHouse.
Sends SIGUSR2 to the background worker, which wakes it up and starts a drain cycle immediately instead of waiting for the next flush_interval_ms tick. The function returns immediately without waiting for the flush to complete. Use this after running test queries when you want events to appear in ClickHouse right away, or as part of a deployment script that needs to verify data is flowing.