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:
psql -h localhost -U postgres -d postgres
-- Create a test tableCREATE TABLE test_data (id serial PRIMARY KEY, value text);-- Generate some loadINSERT INTO test_data (value) SELECT md5(random()::text) FROM generate_series(1, 1000);SELECT count(*) FROM test_data;SELECT * FROM test_data WHERE id = 42;-- Trigger an error (for error tracking)SELECT * FROM nonexistent_table;
3
Flush events to ClickHouse
Events are flushed automatically every 200ms, but you can trigger an immediate flush:
SELECT pg_stat_ch_flush();
4
Query events in ClickHouse
Open a ClickHouse client:
clickhouse-client
See your queries:
SELECT ts_start, db, cmd_type, duration_us / 1000 AS ms, rows, substring(query, 1, 80) AS query_previewFROM pg_stat_ch.events_rawORDER BY ts_start DESCLIMIT 10;
5
Check for errors
SELECT ts_start, err_sqlstate, err_message, substring(query, 1, 80) AS query_previewFROM pg_stat_ch.errors_recentORDER BY ts_start DESCLIMIT 10;
You should see the 42P01 (undefined table) error from the nonexistent_table query.