pg_stat_ch_version()
Returns the extension version string.
pg_stat_ch_stats()
Returns queue and exporter statistics as a single row.
Output columns
| Column | Type | Description |
|---|---|---|
enqueued_events | bigint | Total events successfully written to the ring buffer since startup or last reset |
dropped_events | bigint | Events dropped because the ring buffer was full. Non-zero means the queue cannot keep up with query throughput |
exported_events | bigint | Events successfully sent to ClickHouse (or OTel collector) |
send_failures | bigint | Failed export attempts (network errors, ClickHouse down, etc.) |
last_success_ts | timestamptz | Timestamp of the last successful batch export. NULL if no export has succeeded yet |
last_error_text | text | Error message from the most recent failed export. NULL if no errors have occurred |
last_error_ts | timestamptz | Timestamp of the most recent failed export. NULL if no errors have occurred |
queue_size | integer | Number of events currently in the ring buffer waiting to be exported |
queue_capacity | integer | Maximum ring buffer capacity (set by pg_stat_ch.queue_capacity) |
queue_usage_pct | double precision | Percentage of the ring buffer currently in use: 100 * queue_size / queue_capacity |
Monitoring examples
Check if events are flowing:pg_stat_ch_reset()
Resets all queue counters to zero.
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.
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.
