Skip to main content
This guide uses the Docker quickstart to run PostgreSQL and ClickHouse together with the schema pre-loaded.

Prerequisites

  • Docker and Docker Compose
  • The pg_stat_ch repository cloned locally

Setup

1

Start the stack

From the repository root:
This starts PostgreSQL (with pg_stat_ch pre-loaded) and ClickHouse with the full schema applied. See docker/quickstart/ for stack details.
2

Run some queries

Connect to PostgreSQL and run a few queries to generate telemetry:
3

Flush events to ClickHouse

Events are flushed automatically every 200ms, but you can trigger an immediate flush:
4

Query events in ClickHouse

Open a ClickHouse client:
See your queries:
5

Check for errors

You should see the 42P01 (undefined table) error from the nonexistent_table query.

Check extension health

Back in PostgreSQL, verify the extension is working:
Key things to check:
  • enqueued_events should be increasing as you run queries
  • dropped_events should be 0 (events are being processed faster than produced)
  • exported_events should match or be close to enqueued_events
  • send_failures should be 0

Try a latency percentile query

Use the pre-aggregated materialized view to get p95/p99 latencies:

Tear down

Next steps

ClickHouse setup

Production ClickHouse deployment and schema

Configuration

Tune queue size, flush interval, and connection settings

Monitoring queries

Practical query recipes for common use cases

Events schema

Every field in the events_raw table explained