:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(logs): add logs node to clickhouse multinode smoke test (#66108)
Frank Hamandbdb226cade5d
diff --git a/.github/workflows/ci-clickhouse-multinode-migrations.yml b/.github/workflows/ci-clickhouse-multinode-migrations.ymlindex 4d97dd5fc3d0..4cb93ffe8e72 100644--- a/.github/workflows/ci-clickhouse-multinode-migrations.yml+++ b/.github/workflows/ci-clickhouse-multinode-migrations.yml@@ -72,7 +72,7 @@ jobs:- name: Add multinode hostnames to /etc/hostsrun: |- echo "127.0.0.1 clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions kafka zookeeper" | sudo tee -a /etc/hosts+ echo "127.0.0.1 clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions clickhouse-logs kafka zookeeper" | sudo tee -a /etc/hosts- name: Set up Pythonuses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0diff --git a/docker-compose.multinode-clickhouse.yml b/docker-compose.multinode-clickhouse.ymlindex a674e5d964e7..8b9449b03d10 100644--- a/docker-compose.multinode-clickhouse.yml+++ b/docker-compose.multinode-clickhouse.yml@@ -1,7 +1,7 @@## Multi-node ClickHouse smoke-test stack.#-# Boots one ClickHouse server per logical cluster (data + ai_events + aux + ops + sessions)+# Boots one ClickHouse server per logical cluster (data + ai_events + aux + ops + sessions + logs)# so migration runs can be verified against a topology that resembles production.# Opt-in only: not used by `bin/start` or any of the default dev/CI flows.# Driven by `tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke`@@ -136,5 +136,21 @@ services:- '8127:8123'- '9400:9000'+ clickhouse-logs:+ <<: *clickhouse-multinode+ hostname: clickhouse-logs+ volumes:+ - ./posthog/idl:/idl+ - ./docker/clickhouse/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d+ - ./docker/clickhouse/config.xml:/etc/clickhouse-server/config.xml+ - ./docker/clickhouse/config.d/multinode/logs_node.xml:/etc/clickhouse-server/config.d/default.xml+ - ./docker/clickhouse/config.d/dev-memory.xml:/etc/clickhouse-server/config.d/dev-memory.xml+ - ./docker/clickhouse/users-dev.xml:/etc/clickhouse-server/users.xml+ - ./docker/clickhouse/user_defined_function.xml:/etc/clickhouse-server/user_defined_function.xml+ - ./posthog/user_scripts:/var/lib/clickhouse/user_scripts+ ports:+ - '8128:8123'+ - '9500:9000'+volumes:redpanda-data:diff --git a/docker/clickhouse/config.d/multinode/ai_events_node.xml b/docker/clickhouse/config.d/multinode/ai_events_node.xmlindex d9d7914a7d95..677773d50398 100644--- a/docker/clickhouse/config.d/multinode/ai_events_node.xml+++ b/docker/clickhouse/config.d/multinode/ai_events_node.xml@@ -66,6 +66,12 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>@@ -100,6 +106,14 @@</replica></shard></sessions>+ <logs>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ </logs></remote_servers><named_collections>@@ -121,6 +135,9 @@<warpstream_cyclotron><kafka_broker_list from_env="KAFKA_HOSTS"/></warpstream_cyclotron>+ <warpstream_logs>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_logs></named_collections><macros>diff --git a/docker/clickhouse/config.d/multinode/aux_node.xml b/docker/clickhouse/config.d/multinode/aux_node.xmlindex c93ca1fb8c3b..0ebacd0eb02f 100644--- a/docker/clickhouse/config.d/multinode/aux_node.xml+++ b/docker/clickhouse/config.d/multinode/aux_node.xml@@ -66,6 +66,12 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>@@ -100,6 +106,14 @@</replica></shard></sessions>+ <logs>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ </logs></remote_servers><named_collections>@@ -121,6 +135,9 @@<warpstream_cyclotron><kafka_broker_list from_env="KAFKA_HOSTS"/></warpstream_cyclotron>+ <warpstream_logs>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_logs></named_collections><macros>diff --git a/docker/clickhouse/config.d/multinode/data_node.xml b/docker/clickhouse/config.d/multinode/data_node.xmlindex a2d4b4e1a965..8f0ad99e25b1 100644--- a/docker/clickhouse/config.d/multinode/data_node.xml+++ b/docker/clickhouse/config.d/multinode/data_node.xml@@ -66,6 +66,12 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>@@ -100,6 +106,14 @@</replica></shard></sessions>+ <logs>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ </logs></remote_servers><named_collections>@@ -121,6 +135,9 @@<warpstream_cyclotron><kafka_broker_list from_env="KAFKA_HOSTS"/></warpstream_cyclotron>+ <warpstream_logs>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_logs></named_collections><macros>diff --git a/docker/clickhouse/config.d/multinode/logs_node.xml b/docker/clickhouse/config.d/multinode/logs_node.xmlnew file mode 100644index 000000000000..443d40982ad3--- /dev/null+++ b/docker/clickhouse/config.d/multinode/logs_node.xml@@ -0,0 +1,149 @@+<clickhouse>+ <tcp_port>9000</tcp_port>++ <remote_servers>+ <posthog>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog>+ <posthog_single_shard>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_single_shard>+ <posthog_writable>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_writable>+ <posthog_primary_replica>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_primary_replica>++ <posthog_migrations>+ <shard>+ <replica>+ <host>clickhouse-data</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ai-events</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-aux</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-ops</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-sessions</host>+ <port>9000</port>+ </replica>+ </shard>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ </posthog_migrations>++ <ai_events>+ <shard>+ <replica>+ <host>clickhouse-ai-events</host>+ <port>9000</port>+ </replica>+ </shard>+ </ai_events>+ <aux>+ <shard>+ <replica>+ <host>clickhouse-aux</host>+ <port>9000</port>+ </replica>+ </shard>+ </aux>+ <ops>+ <shard>+ <replica>+ <host>clickhouse-ops</host>+ <port>9000</port>+ </replica>+ </shard>+ </ops>+ <sessions>+ <shard>+ <replica>+ <host>clickhouse-sessions</host>+ <port>9000</port>+ </replica>+ </shard>+ </sessions>+ <logs>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ </logs>+ </remote_servers>++ <named_collections>+ <msk_cluster>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </msk_cluster>+ <warpstream_ingestion>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_ingestion>+ <warpstream_calculated_events>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_calculated_events>+ <warpstream_replay>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_replay>+ <warpstream_shared>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_shared>+ <warpstream_cyclotron>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_cyclotron>+ <warpstream_logs>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_logs>+ </named_collections>++ <macros>+ <shard>01</shard>+ <replica>logs</replica>+ <hostClusterType>online</hostClusterType>+ <hostClusterRole>logs</hostClusterRole>+ </macros>+</clickhouse>diff --git a/docker/clickhouse/config.d/multinode/ops_node.xml b/docker/clickhouse/config.d/multinode/ops_node.xmlindex ed1ea91c4eca..8bad6639e632 100644--- a/docker/clickhouse/config.d/multinode/ops_node.xml+++ b/docker/clickhouse/config.d/multinode/ops_node.xml@@ -66,6 +66,12 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>@@ -100,6 +106,14 @@</replica></shard></sessions>+ <logs>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ </logs></remote_servers><named_collections>@@ -121,6 +135,9 @@<warpstream_cyclotron><kafka_broker_list from_env="KAFKA_HOSTS"/></warpstream_cyclotron>+ <warpstream_logs>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_logs></named_collections><macros>diff --git a/docker/clickhouse/config.d/multinode/sessions_node.xml b/docker/clickhouse/config.d/multinode/sessions_node.xmlindex 1fc6cda43c87..4bd857eedb73 100644--- a/docker/clickhouse/config.d/multinode/sessions_node.xml+++ b/docker/clickhouse/config.d/multinode/sessions_node.xml@@ -66,6 +66,12 @@<port>9000</port></replica></shard>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard></posthog_migrations><ai_events>@@ -100,6 +106,14 @@</replica></shard></sessions>+ <logs>+ <shard>+ <replica>+ <host>clickhouse-logs</host>+ <port>9000</port>+ </replica>+ </shard>+ </logs></remote_servers><named_collections>@@ -121,6 +135,9 @@<warpstream_cyclotron><kafka_broker_list from_env="KAFKA_HOSTS"/></warpstream_cyclotron>+ <warpstream_logs>+ <kafka_broker_list from_env="KAFKA_HOSTS"/>+ </warpstream_logs></named_collections><macros>diff --git a/posthog/clickhouse/cluster.py b/posthog/clickhouse/cluster.pyindex 150349d5a96c..258b964d18a5 100644--- a/posthog/clickhouse/cluster.py+++ b/posthog/clickhouse/cluster.py@@ -62,6 +62,7 @@ _MULTINODE_HOST_PORT_OVERRIDES: dict[str, tuple[str, int]] = {"clickhouse-aux": ("localhost", 9200),"clickhouse-ops": ("localhost", 9300),"clickhouse-sessions": ("localhost", 9400),+ "clickhouse-logs": ("localhost", 9500),}diff --git a/tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke b/tools/infra-scripts/clickhouse-multinode/multinode-migration-smokeindex e514e49fba59..1ef15c3739ae 100755--- a/tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke+++ b/tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke@@ -2,7 +2,7 @@## End-to-end smoke test for ClickHouse migrations against a multi-node topology.#-# Boots one ClickHouse server per logical cluster (data + ai_events + aux + ops + sessions),+# Boots one ClickHouse server per logical cluster (data + ai_events + aux + ops + sessions + logs),# runs `manage.py migrate_clickhouse` with MULTINODE_CLICKHOUSE=1 (so migrations respect# their declared NodeRole instead of being collapsed to NodeRole.ALL), then runs the# verification script to assert each node ended up with the tables it should have.@@ -24,7 +24,7 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)cd "$SCRIPT_DIR/../../.."COMPOSE_FILE="docker-compose.multinode-clickhouse.yml"-CH_SERVICES=(clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions)+CH_SERVICES=(clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions clickhouse-logs)INFRA_SERVICES=(zookeeper kafka db redis7)ALL_SERVICES=("${INFRA_SERVICES[@]}" "${CH_SERVICES[@]}")HEALTH_TIMEOUT="${HEALTH_TIMEOUT:-180}"diff --git a/tools/infra-scripts/clickhouse-multinode/start-multinode-clickhouse b/tools/infra-scripts/clickhouse-multinode/start-multinode-clickhouseindex ca04c7962535..9afcf9bf9529 100755--- a/tools/infra-scripts/clickhouse-multinode/start-multinode-clickhouse+++ b/tools/infra-scripts/clickhouse-multinode/start-multinode-clickhouse@@ -1,7 +1,7 @@#!/usr/bin/env bash## Boot the multinode ClickHouse smoke-test stack in the background.-# One ClickHouse server per logical cluster (data + ai_events + aux + ops + sessions).+# One ClickHouse server per logical cluster (data + ai_events + aux + ops + sessions + logs).# This is opt-in tooling for verifying migration routing — `bin/start` is unaffected.#@@ -12,7 +12,7 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)cd "$SCRIPT_DIR/../../.."COMPOSE_FILE="docker-compose.multinode-clickhouse.yml"-SERVICES=(zookeeper kafka db redis7 clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions)+SERVICES=(zookeeper kafka db redis7 clickhouse-data clickhouse-ai-events clickhouse-aux clickhouse-ops clickhouse-sessions clickhouse-logs)case "${1:-up}" inup)@@ -24,6 +24,7 @@ case "${1:-up}" inecho " clickhouse-aux localhost:9200 (HTTP 8125)"echo " clickhouse-ops localhost:9300 (HTTP 8126)"echo " clickhouse-sessions localhost:9400 (HTTP 8127)"+ echo " clickhouse-logs localhost:9500 (HTTP 8128)"echoecho "To run migrations against this stack, set:"echo " export MULTINODE_CLICKHOUSE=1"diff --git a/tools/infra-scripts/clickhouse-multinode/verify-multinode-clickhouse.py b/tools/infra-scripts/clickhouse-multinode/verify-multinode-clickhouse.pyindex dfc910d1b7b0..fe2526a53532 100755--- a/tools/infra-scripts/clickhouse-multinode/verify-multinode-clickhouse.py+++ b/tools/infra-scripts/clickhouse-multinode/verify-multinode-clickhouse.py@@ -42,6 +42,7 @@ NODES: list[Node] = [Node("clickhouse-aux", "localhost", 9200, "aux"),Node("clickhouse-ops", "localhost", 9300, "ops"),Node("clickhouse-sessions", "localhost", 9400, "sessions"),+ Node("clickhouse-logs", "localhost", 9500, "logs"),]# Logical cluster -> expected member hosts (sorted). Each multinode XML file@@ -55,6 +56,7 @@ EXPECTED_CLUSTERS: dict[str, list[str]] = {"clickhouse-ai-events","clickhouse-aux","clickhouse-data",+ "clickhouse-logs","clickhouse-ops","clickhouse-sessions",],@@ -62,6 +64,7 @@ EXPECTED_CLUSTERS: dict[str, list[str]] = {"aux": ["clickhouse-aux"],"ops": ["clickhouse-ops"],"sessions": ["clickhouse-sessions"],+ "logs": ["clickhouse-logs"],}@@ -86,6 +89,10 @@ SATELLITE_TABLE_MANIFEST: dict[str, SatelliteTables] = {"aux": SatelliteTables(on_satellite=[], forbidden_on_data=[]),"ops": SatelliteTables(on_satellite=[], forbidden_on_data=[]),"sessions": SatelliteTables(on_satellite=[], forbidden_on_data=[]),+ "logs": SatelliteTables(+ on_satellite=["logs34"],+ forbidden_on_data=["logs34"],+ ),}DATABASE = "posthog"