: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
fix(alerts-platform): query the logs cluster as the insight alert user (#130632)
Jimmy Zhu3d3e23587695
diff --git a/posthog/clickhouse/client/connection.py b/posthog/clickhouse/client/connection.pyindex 69f813b72686..5314236256ae 100644--- a/posthog/clickhouse/client/connection.py+++ b/posthog/clickhouse/client/connection.py@@ -453,8 +453,13 @@ def get_http_client(**overrides):# Named users that exist on the logs cluster. Every other named user exists on the main cluster# only, and sync_execute assigns some of them (APP, API) from tags without checking the workload.+# ALERTS_PLATFORM_INSIGHT exists on both, because an insight can read logs, spans or metrics.LOGS_CLUSTER_USERS: frozenset[ClickHouseUser] = frozenset(- {ClickHouseUser.ALERTS_PLATFORM_LOGS, ClickHouseUser.ALERTS_PLATFORM_METRICS}+ {+ ClickHouseUser.ALERTS_PLATFORM_INSIGHT,+ ClickHouseUser.ALERTS_PLATFORM_LOGS,+ ClickHouseUser.ALERTS_PLATFORM_METRICS,+ })diff --git a/posthog/clickhouse/client/test/test_connection.py b/posthog/clickhouse/client/test/test_connection.pyindex 97020e9f90e3..865f26476f3b 100644--- a/posthog/clickhouse/client/test/test_connection.py+++ b/posthog/clickhouse/client/test/test_connection.py@@ -375,6 +375,7 @@ def reset_state():[(True, ClickHouseUser.ALERTS_PLATFORM_LOGS, "alerts_platform_logs", "logs-token"),(False, ClickHouseUser.ALERTS_PLATFORM_LOGS, "logs-user", "logs-static"),+ (True, ClickHouseUser.ALERTS_PLATFORM_INSIGHT, "alerts_platform_insight", "logs-token"),(True, ClickHouseUser.DEFAULT, "logs-user", "logs-static"),(True, ClickHouseUser.APP, "logs-user", "logs-static"),],@@ -395,6 +396,9 @@ def test_logs_workload_uses_a_named_user_only_when_registered(users[ClickHouseUser.ALERTS_PLATFORM_LOGS] = ClickHouseCredentials(user="alerts_platform_logs", password="fallback", password_file=str(logs_token))+ users[ClickHouseUser.ALERTS_PLATFORM_INSIGHT] = ClickHouseCredentials(+ user="alerts_platform_insight", password="", password_file=str(logs_token)+ )users[ClickHouseUser.APP] = ClickHouseCredentials(user="app", password="app-static")monkeypatch.setattr(connection, "__user_dict", users)