: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
feat(ingestion): add ingestion warnings v2 clickhouse schema (#68845)
José Sequeira4c37c26da9f2
diff --git a/posthog/clickhouse/hcl/check.sh b/posthog/clickhouse/hcl/check.shindex 86fe1e0f4908..0fb35f367ad1 100755--- a/posthog/clickhouse/hcl/check.sh+++ b/posthog/clickhouse/hcl/check.sh@@ -42,7 +42,7 @@ skip_for() {# DATA is the hub: it hosts Distributed read proxies into every satellite cluster# (aux web/marketing preaggregated, ai_events, sessions), none of whose sharded# remotes live on the data node.- data) echo "${_shared},${_qla},ai_events,conversion_goal_attributed_preaggregated,distributed_system_processes,error_tracking_fingerprint_issue_state,experiment_metric_events_preaggregated,hog_invocation_results,marketing_conversions_preaggregated,marketing_costs_preaggregated,marketing_touchpoints_preaggregated,message_assets,property_values_distributed,session_replay_features,usage_report_events_preagg,web_bot_definition,web_bounces_dimensional_preaggregated,web_goals_preaggregated,web_overview_preaggregated,web_stats_dimensional_preaggregated,web_stats_frustration_preaggregated,web_stats_paths_preaggregated,web_stats_paths_preaggregated_pathkey,web_stats_preaggregated,web_vitals_paths_preaggregated" ;;+ data) echo "${_shared},${_qla},ai_events,conversion_goal_attributed_preaggregated,distributed_system_processes,error_tracking_fingerprint_issue_state,experiment_metric_events_preaggregated,hog_invocation_results,ingestion_warnings_v2_distributed,marketing_conversions_preaggregated,marketing_costs_preaggregated,marketing_touchpoints_preaggregated,message_assets,property_values_distributed,session_replay_features,usage_report_events_preagg,web_bot_definition,web_bounces_dimensional_preaggregated,web_goals_preaggregated,web_overview_preaggregated,web_stats_dimensional_preaggregated,web_stats_frustration_preaggregated,web_stats_paths_preaggregated,web_stats_paths_preaggregated_pathkey,web_stats_preaggregated,web_vitals_paths_preaggregated" ;;*) echo "" ;;esac}diff --git a/posthog/clickhouse/hcl/golden/local-aux.hcl b/posthog/clickhouse/hcl/golden/local-aux.hclindex 4baa66734de5..9deb863759cc 100644--- a/posthog/clickhouse/hcl/golden/local-aux.hcl+++ b/posthog/clickhouse/hcl/golden/local-aux.hcl@@ -346,6 +346,131 @@ database "posthog" {}}+ table "ingestion_warnings_v2" {+ order_by = ["team_id", "type", "timestamp"]+ partition_by = "toYYYYMM(timestamp)"+ ttl = "toDateTime(timestamp) + toIntervalDay(90)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.ingestion_warnings_v2"+ replica_name = "{replica}-{shard}"+ }+ }++ table "ingestion_warnings_v2_distributed" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "ingestion_warnings_v2"+ }+ }+table "kafka_error_tracking_fingerprint_issue_state" {column "team_id" {type = "Int64"@@ -461,6 +586,30 @@ database "posthog" {}}+ table "kafka_ingestion_warnings_v2" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"+ group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }+table "kafka_message_assets" {column "team_id" {type = "Int64"@@ -3451,6 +3600,47 @@ SQL}}+ materialized_view "ingestion_warnings_v2_mv" {+ to_table = "posthog.ingestion_warnings_v2"+ query = <<SQL+SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings_v2+SQL++ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }+materialized_view "message_assets_mv" {to_table = "posthog.message_assets_data"query = <<SQLdiff --git a/posthog/clickhouse/hcl/golden/local-data.hcl b/posthog/clickhouse/hcl/golden/local-data.hclindex e3d7d1524671..4823226595d7 100644--- a/posthog/clickhouse/hcl/golden/local-data.hcl+++ b/posthog/clickhouse/hcl/golden/local-data.hcl@@ -1747,6 +1747,66 @@ database "posthog" {}}+ table "ingestion_warnings_v2_distributed" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "ingestion_warnings_v2"+ }+ }+table "kafka_events_json" {column "uuid" {type = "UUID"diff --git a/posthog/clickhouse/hcl/golden/prod-eu-aux.hcl b/posthog/clickhouse/hcl/golden/prod-eu-aux.hclindex 7f4363aa69b3..da291c2d2f81 100644--- a/posthog/clickhouse/hcl/golden/prod-eu-aux.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu-aux.hcl@@ -347,6 +347,131 @@ database "posthog" {}}+ table "ingestion_warnings_v2" {+ order_by = ["team_id", "type", "timestamp"]+ partition_by = "toYYYYMM(timestamp)"+ ttl = "toDateTime(timestamp) + toIntervalDay(90)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.ingestion_warnings_v2"+ replica_name = "{replica}-{shard}"+ }+ }++ table "ingestion_warnings_v2_distributed" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "ingestion_warnings_v2"+ }+ }+table "kafka_hog_invocation_results" {column "team_id" {type = "Int64"@@ -420,6 +545,30 @@ database "posthog" {}}+ table "kafka_ingestion_warnings_v2" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"+ group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }+table "kafka_message_assets" {column "team_id" {type = "Int64"@@ -3345,6 +3494,47 @@ SQL}}+ materialized_view "ingestion_warnings_v2_mv" {+ to_table = "posthog.ingestion_warnings_v2"+ query = <<SQL+SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings_v2+SQL++ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }+materialized_view "message_assets_mv" {to_table = "posthog.message_assets_data"query = <<SQLdiff --git a/posthog/clickhouse/hcl/golden/prod-us-aux.hcl b/posthog/clickhouse/hcl/golden/prod-us-aux.hclindex 1f699b6dffef..4dda85b1494a 100644--- a/posthog/clickhouse/hcl/golden/prod-us-aux.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us-aux.hcl@@ -381,6 +381,131 @@ database "posthog" {}}+ table "ingestion_warnings_v2" {+ order_by = ["team_id", "type", "timestamp"]+ partition_by = "toYYYYMM(timestamp)"+ ttl = "toDateTime(timestamp) + toIntervalDay(90)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.ingestion_warnings_v2"+ replica_name = "{replica}-{shard}"+ }+ }++ table "ingestion_warnings_v2_distributed" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "ingestion_warnings_v2"+ }+ }+table "kafka_hog_invocation_results" {column "team_id" {type = "Int64"@@ -458,6 +583,30 @@ database "posthog" {}}+ table "kafka_ingestion_warnings_v2" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"+ group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }+table "kafka_message_assets" {column "team_id" {type = "Int64"@@ -3419,6 +3568,47 @@ SQL}}+ materialized_view "ingestion_warnings_v2_mv" {+ to_table = "posthog.ingestion_warnings_v2"+ query = <<SQL+SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings_v2+SQL++ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }+materialized_view "message_assets_mv" {to_table = "posthog.message_assets_data"query = <<SQLdiff --git a/posthog/clickhouse/hcl/roles/auxiliary/shared/sql/ingestion_warnings_v2_mv.sql b/posthog/clickhouse/hcl/roles/auxiliary/shared/sql/ingestion_warnings_v2_mv.sqlnew file mode 100644index 000000000000..be0f11c29e1d--- /dev/null+++ b/posthog/clickhouse/hcl/roles/auxiliary/shared/sql/ingestion_warnings_v2_mv.sql@@ -0,0 +1,10 @@+SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings_v2diff --git a/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl b/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hclindex f596e9e2a34f..ac9ca5a6e120 100644--- a/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl+++ b/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl@@ -95,6 +95,61 @@ database "posthog" {default = "today() + toIntervalDay(7)"}}+ table "_ingestion_warnings_v2_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }table "_marketing_conversions_preaggregated_columns" {abstract = truecolumn "team_id" {@@ -974,6 +1029,50 @@ database "posthog" {remote_table = "hog_invocation_results_data"}}+ table "ingestion_warnings_v2" {+ order_by = ["team_id", "type", "timestamp"]+ partition_by = "toYYYYMM(timestamp)"+ ttl = "toDateTime(timestamp) + toIntervalDay(90)"+ settings = {+ index_granularity = "8192"+ }+ extend = "_ingestion_warnings_v2_columns"+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.ingestion_warnings_v2"+ replica_name = "{replica}-{shard}"+ }+ }+ table "ingestion_warnings_v2_distributed" {+ extend = "_ingestion_warnings_v2_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "ingestion_warnings_v2"+ }+ }+ table "kafka_ingestion_warnings_v2" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"+ group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"+ format = "kafka_format = 'JSONEachRow'"+ }+ }table "kafka_message_assets" {column "team_id" {type = "Int64"@@ -1915,6 +2014,35 @@ database "posthog" {type = "UInt64"}}+ materialized_view "ingestion_warnings_v2_mv" {+ to_table = "posthog.ingestion_warnings_v2"+ query = file("sql/ingestion_warnings_v2_mv.sql")++ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "Nullable(DateTime)"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }materialized_view "message_assets_mv" {to_table = "posthog.message_assets_data"query = file("sql/message_assets_mv.sql")diff --git a/posthog/clickhouse/hcl/roles/data/local/tables.hcl b/posthog/clickhouse/hcl/roles/data/local/tables.hclindex 51cd845196e0..029105a168d0 100644--- a/posthog/clickhouse/hcl/roles/data/local/tables.hcl+++ b/posthog/clickhouse/hcl/roles/data/local/tables.hcl@@ -1720,6 +1720,65 @@ database "posthog" {sharding_key = "rand()"}}+ table "ingestion_warnings_v2_distributed" {+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "ingestion_warnings_v2"+ }+ }table "kafka_events_json" {column "uuid" {type = "UUID"diff --git a/posthog/clickhouse/hcl/sql/local-aux.sql b/posthog/clickhouse/hcl/sql/local-aux.sqlindex e61fddea42e0..c56b24c3aaa0 100644--- a/posthog/clickhouse/hcl/sql/local-aux.sql+++ b/posthog/clickhouse/hcl/sql/local-aux.sql@@ -31,6 +31,40 @@ CREATE TABLE posthog.hog_invocation_results_data (INDEX event_uuid_idx event_uuid TYPE bloom_filter(0.01) GRANULARITY 1,INDEX is_retry_idx is_retry TYPE set(2) GRANULARITY 1) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.hog_invocation_results_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id) PARTITION BY toYYYYMMDD(scheduled_at) TTL toDate(scheduled_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, ttl_only_drop_parts = 1;+CREATE TABLE posthog.ingestion_warnings_v2 (+ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.ingestion_warnings_v2', '{replica}-{shard}') ORDER BY (team_id, type, timestamp) PARTITION BY toYYYYMM(timestamp) TTL toDateTime(timestamp) + toIntervalDay(90) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.ingestion_warnings_v2_distributed (+ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('aux', 'posthog', 'ingestion_warnings_v2');CREATE TABLE posthog.kafka_error_tracking_fingerprint_issue_state (team_id Int64,fingerprint String,@@ -67,6 +101,13 @@ CREATE TABLE posthog.kafka_hog_invocation_results (version UInt64,is_deleted UInt8) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';+CREATE TABLE posthog.kafka_ingestion_warnings_v2 (+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String,+ timestamp DateTime64(6, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ingestion_warnings_v2\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';CREATE TABLE posthog.kafka_message_assets (team_id Int64,function_kind LowCardinality(String),@@ -786,6 +827,16 @@ CREATE MATERIALIZED VIEW posthog.hog_invocation_results_mv TO posthog.hog_invoca_offset,_partitionFROM posthog.kafka_hog_invocation_results;+CREATE MATERIALIZED VIEW posthog.ingestion_warnings_v2_mv TO posthog.ingestion_warnings_v2 (team_id Int64, source LowCardinality(String), type String, details String, timestamp DateTime64(6, 'UTC'), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings_v2;CREATE MATERIALIZED VIEW posthog.message_assets_mv TO posthog.message_assets_data (team_id Int64, function_kind LowCardinality(String), function_id String, parent_run_id String, invocation_id String, action_id String, kind LowCardinality(String), distinct_id String, person_id String, recipient String, subject String, status LowCardinality(String), sent_at DateTime64(6, 'UTC'), version UInt64, is_deleted UInt8, html String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECTteam_id,function_kind,diff --git a/posthog/clickhouse/hcl/sql/local-data.sql b/posthog/clickhouse/hcl/sql/local-data.sqlindex 72ab1619ee75..9d80926c4773 100644--- a/posthog/clickhouse/hcl/sql/local-data.sql+++ b/posthog/clickhouse/hcl/sql/local-data.sql@@ -284,6 +284,23 @@ CREATE TABLE posthog.hog_invocation_results (_offset UInt64,_partition UInt64) ENGINE = Distributed('aux', 'posthog', 'hog_invocation_results_data');+CREATE TABLE posthog.ingestion_warnings_v2_distributed (+ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('aux', 'posthog', 'ingestion_warnings_v2');CREATE TABLE posthog.kafka_events_json (uuid UUID,event String,diff --git a/posthog/clickhouse/hcl/sql/prod-eu-aux.sql b/posthog/clickhouse/hcl/sql/prod-eu-aux.sqlindex e17174061bd9..bb9dace79d18 100644--- a/posthog/clickhouse/hcl/sql/prod-eu-aux.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu-aux.sql@@ -31,6 +31,40 @@ CREATE TABLE posthog.hog_invocation_results_data (INDEX event_uuid_idx event_uuid TYPE bloom_filter(0.01) GRANULARITY 1,INDEX is_retry_idx is_retry TYPE set(2) GRANULARITY 1) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.hog_invocation_results_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id) PARTITION BY toYYYYMMDD(scheduled_at) TTL toDate(scheduled_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, storage_policy = 's3_tiered', ttl_only_drop_parts = 1;+CREATE TABLE posthog.ingestion_warnings_v2 (+ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.ingestion_warnings_v2', '{replica}-{shard}') ORDER BY (team_id, type, timestamp) PARTITION BY toYYYYMM(timestamp) TTL toDateTime(timestamp) + toIntervalDay(90) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.ingestion_warnings_v2_distributed (+ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('aux', 'posthog', 'ingestion_warnings_v2');CREATE TABLE posthog.kafka_hog_invocation_results (team_id Int64,function_kind LowCardinality(String),@@ -54,6 +88,13 @@ CREATE TABLE posthog.kafka_hog_invocation_results (version UInt64,is_deleted UInt8) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';+CREATE TABLE posthog.kafka_ingestion_warnings_v2 (+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String,+ timestamp DateTime64(6, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ingestion_warnings_v2\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';CREATE TABLE posthog.kafka_message_assets (team_id Int64,function_kind LowCardinality(String),@@ -757,6 +798,16 @@ CREATE MATERIALIZED VIEW posthog.hog_invocation_results_mv TO posthog.hog_invoca_offset,_partitionFROM posthog.kafka_hog_invocation_results;+CREATE MATERIALIZED VIEW posthog.ingestion_warnings_v2_mv TO posthog.ingestion_warnings_v2 (team_id Int64, source LowCardinality(String), type String, details String, timestamp DateTime64(6, 'UTC'), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings_v2;CREATE MATERIALIZED VIEW posthog.message_assets_mv TO posthog.message_assets_data (team_id Int64, function_kind LowCardinality(String), function_id String, parent_run_id String, invocation_id String, action_id String, kind LowCardinality(String), distinct_id String, person_id String, recipient String, subject String, status LowCardinality(String), sent_at DateTime64(6, 'UTC'), version UInt64, is_deleted UInt8, html String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECTteam_id,function_kind,diff --git a/posthog/clickhouse/hcl/sql/prod-us-aux.sql b/posthog/clickhouse/hcl/sql/prod-us-aux.sqlindex 09dc62dd0d25..6daf2e6887bc 100644--- a/posthog/clickhouse/hcl/sql/prod-us-aux.sql+++ b/posthog/clickhouse/hcl/sql/prod-us-aux.sql@@ -31,6 +31,40 @@ CREATE TABLE posthog.hog_invocation_results_data (INDEX event_uuid_idx event_uuid TYPE bloom_filter(0.01) GRANULARITY 1,INDEX is_retry_idx is_retry TYPE set(2) GRANULARITY 1) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/noshard/posthog.hog_invocation_results_data', '{replica}-{shard}', version) ORDER BY (team_id, function_kind, function_id, invocation_id) PARTITION BY toYYYYMMDD(scheduled_at) TTL toDate(scheduled_at) + toIntervalDay(30) SETTINGS index_granularity = 1024, storage_policy = 's3_tiered', ttl_only_drop_parts = 1;+CREATE TABLE posthog.ingestion_warnings_v2 (+ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.ingestion_warnings_v2', '{replica}-{shard}') ORDER BY (team_id, type, timestamp) PARTITION BY toYYYYMM(timestamp) TTL toDateTime(timestamp) + toIntervalDay(90) SETTINGS index_granularity = 8192;+CREATE TABLE posthog.ingestion_warnings_v2_distributed (+ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+) ENGINE = Distributed('aux', 'posthog', 'ingestion_warnings_v2');CREATE TABLE posthog.kafka_hog_invocation_results (team_id Int64,function_kind LowCardinality(String),@@ -54,6 +88,13 @@ CREATE TABLE posthog.kafka_hog_invocation_results (version UInt64,is_deleted UInt8) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_max_block_size = 100000, kafka_num_consumers = 1, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';+CREATE TABLE posthog.kafka_ingestion_warnings_v2 (+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String,+ timestamp DateTime64(6, 'UTC')+) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ingestion_warnings_v2\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';CREATE TABLE posthog.kafka_message_assets (team_id Int64,function_kind LowCardinality(String),@@ -767,6 +808,16 @@ CREATE MATERIALIZED VIEW posthog.hog_invocation_results_mv TO posthog.hog_invoca_offset,_partitionFROM posthog.kafka_hog_invocation_results;+CREATE MATERIALIZED VIEW posthog.ingestion_warnings_v2_mv TO posthog.ingestion_warnings_v2 (team_id Int64, source LowCardinality(String), type String, details String, timestamp DateTime64(6, 'UTC'), _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM posthog.kafka_ingestion_warnings_v2;CREATE MATERIALIZED VIEW posthog.message_assets_mv TO posthog.message_assets_data (team_id Int64, function_kind LowCardinality(String), function_id String, parent_run_id String, invocation_id String, action_id String, kind LowCardinality(String), distinct_id String, person_id String, recipient String, subject String, status LowCardinality(String), sent_at DateTime64(6, 'UTC'), version UInt64, is_deleted UInt8, html String, _timestamp Nullable(DateTime), _offset UInt64, _partition UInt64) AS SELECTteam_id,function_kind,diff --git a/posthog/clickhouse/kafka_engine.py b/posthog/clickhouse/kafka_engine.pyindex 1df66b6fd207..d6cc1ca8269d 100644--- a/posthog/clickhouse/kafka_engine.py+++ b/posthog/clickhouse/kafka_engine.py@@ -43,6 +43,8 @@ CONSUMER_GROUP_PERSON_DISTINCT_ID_OVERRIDES_WS = "clickhouse_person_distinct_id_CONSUMER_GROUP_AI_EVENTS_WS = "clickhouse_ai_events_ws"CONSUMER_GROUP_HEATMAPS_WS = "clickhouse_heatmaps_ws"CONSUMER_GROUP_INGESTION_WARNINGS_WS = "clickhouse_ingestion_warnings_ws"+# v2 reads the same topic as v1 via its own consumer group, so it gets the full stream independently.+CONSUMER_GROUP_INGESTION_WARNINGS_V2 = "clickhouse_ingestion_warnings_v2"CONSUMER_GROUP_SESSION_REPLAY_EVENTS_WS = "clickhouse_session_replay_events_ws"CONSUMER_GROUP_SESSION_REPLAY_FEATURES_WS = "clickhouse_session_replay_features_ws"CONSUMER_GROUP_COHORT_MEMBERSHIP_WS = "clickhouse_cohort_membership_ws"diff --git a/posthog/clickhouse/migrations/0286_ingestion_warnings_v2.py b/posthog/clickhouse/migrations/0286_ingestion_warnings_v2.pynew file mode 100644index 000000000000..52c7dd60af93--- /dev/null+++ b/posthog/clickhouse/migrations/0286_ingestion_warnings_v2.py@@ -0,0 +1,31 @@+from posthog.clickhouse.client.connection import NodeRole+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions+from posthog.models.ingestion_warnings.sql_v2 import (+ DISTRIBUTED_INGESTION_WARNINGS_V2_TABLE_SQL,+ INGESTION_WARNINGS_V2_DATA_TABLE_SQL,+ INGESTION_WARNINGS_V2_MV_SQL,+ KAFKA_INGESTION_WARNINGS_V2_TABLE_SQL,+)++operations = [+ # 1. Data table on aux (single shard, replicated)+ run_sql_with_exceptions(+ INGESTION_WARNINGS_V2_DATA_TABLE_SQL(),+ node_roles=[NodeRole.AUX],+ ),+ # 2. Kafka engine table on aux (consumes the clickhouse_ingestion_warnings topic via a v2 consumer group)+ run_sql_with_exceptions(+ KAFKA_INGESTION_WARNINGS_V2_TABLE_SQL(),+ node_roles=[NodeRole.AUX],+ ),+ # 3. MV on aux (Kafka -> data table, deriving structured dimensions from `details`)+ run_sql_with_exceptions(+ INGESTION_WARNINGS_V2_MV_SQL(),+ node_roles=[NodeRole.AUX],+ ),+ # 4. Distributed read table on aux and data nodes+ run_sql_with_exceptions(+ DISTRIBUTED_INGESTION_WARNINGS_V2_TABLE_SQL(),+ node_roles=[NodeRole.AUX, NodeRole.DATA],+ ),+]diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txtindex d6319e3ddfb5..c72e3ffd790b 100644--- a/posthog/clickhouse/migrations/max_migration.txt+++ b/posthog/clickhouse/migrations/max_migration.txt@@ -1 +1 @@-0285_metric_series_temporality_samples_histograms+0286_ingestion_warnings_v2diff --git a/posthog/clickhouse/schema.py b/posthog/clickhouse/schema.pyindex bfadc00d7bb8..b9439f6cade4 100644--- a/posthog/clickhouse/schema.py+++ b/posthog/clickhouse/schema.py@@ -199,6 +199,12 @@ from posthog.models.ingestion_warnings.sql import (KAFKA_INGESTION_WARNINGS_TABLE_SQL,WRITABLE_INGESTION_WARNINGS_TABLE_SQL,)+from posthog.models.ingestion_warnings.sql_v2 import (+ DISTRIBUTED_INGESTION_WARNINGS_V2_TABLE_SQL,+ INGESTION_WARNINGS_V2_DATA_TABLE_SQL,+ INGESTION_WARNINGS_V2_MV_SQL,+ KAFKA_INGESTION_WARNINGS_V2_TABLE_SQL,+)from posthog.models.message_assets.sql import (DISTRIBUTED_MESSAGE_ASSETS_TABLE_SQL,KAFKA_MESSAGE_ASSETS_TABLE_SQL,@@ -334,6 +340,7 @@ CREATE_MERGETREE_TABLE_QUERIES = (RAW_ERROR_TRACKING_FINGERPRINT_ISSUE_STATE_TABLE_SQL,PLUGIN_LOG_ENTRIES_TABLE_SQL,INGESTION_WARNINGS_DATA_TABLE_SQL,+ INGESTION_WARNINGS_V2_DATA_TABLE_SQL,APP_METRICS_DATA_TABLE_SQL,APP_METRICS2_DATA_TABLE_SQL,HOG_INVOCATION_RESULTS_DATA_TABLE_SQL,@@ -394,6 +401,7 @@ CREATE_DISTRIBUTED_TABLE_QUERIES = (EVENTS_RECENT_TABLE_SQL,DISTRIBUTED_EVENTS_RECENT_TABLE_SQL,DISTRIBUTED_INGESTION_WARNINGS_TABLE_SQL,+ DISTRIBUTED_INGESTION_WARNINGS_V2_TABLE_SQL,DISTRIBUTED_APP_METRICS_TABLE_SQL,DISTRIBUTED_APP_METRICS2_TABLE_SQL,DISTRIBUTED_HOG_INVOCATION_RESULTS_TABLE_SQL,@@ -477,6 +485,7 @@ CREATE_KAFKA_TABLE_QUERIES = (KAFKA_DOCUMENT_EMBEDDINGS_TABLE_SQL,KAFKA_PLUGIN_LOG_ENTRIES_TABLE_SQL,KAFKA_INGESTION_WARNINGS_TABLE_SQL,+ KAFKA_INGESTION_WARNINGS_V2_TABLE_SQL,KAFKA_APP_METRICS_TABLE_SQL,KAFKA_APP_METRICS2_TABLE_SQL,KAFKA_HOG_INVOCATION_RESULTS_TABLE_SQL,@@ -508,6 +517,7 @@ CREATE_MV_TABLE_QUERIES = (DOCUMENT_EMBEDDINGS_MV_SQL,PLUGIN_LOG_ENTRIES_TABLE_MV_SQL,INGESTION_WARNINGS_MV_TABLE_SQL,+ INGESTION_WARNINGS_V2_MV_SQL,APP_METRICS_MV_TABLE_SQL,APP_METRICS2_MV_TABLE_SQL,HOG_INVOCATION_RESULTS_MV_SQL,diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambrindex 1471b89eff48..305181def734 100644--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr@@ -329,6 +329,22 @@'''# ---+# name: test_create_kafka_table_with_different_kafka_host[kafka_ingestion_warnings_v2]+ '''++ CREATE TABLE IF NOT EXISTS kafka_ingestion_warnings_v2+ (++ team_id Int64,+ source LowCardinality(String),+ type String,+ details String,+ timestamp DateTime64(6, 'UTC')++ ) ENGINE = Kafka(warpstream_ingestion, kafka_topic_list = 'clickhouse_ingestion_warnings_test', kafka_group_name = 'clickhouse_ingestion_warnings_v2', kafka_format = 'JSONEachRow')++ '''+# ---# name: test_create_kafka_table_with_different_kafka_host[kafka_log_entries]'''@@ -1933,6 +1949,79 @@'''# ---+# name: test_create_table_query[ingestion_warnings_v2]+ '''++ CREATE TABLE IF NOT EXISTS ingestion_warnings_v2+ (++ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64++ ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.ingestion_warnings_v2', '{replica}-{shard}')+ PARTITION BY toYYYYMM(timestamp)+ ORDER BY (team_id, type, timestamp)+ TTL toDateTime(timestamp) + INTERVAL 90 DAY++ '''+# ---+# name: test_create_table_query[ingestion_warnings_v2_distributed]+ '''++ CREATE TABLE IF NOT EXISTS ingestion_warnings_v2_distributed+ (++ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64++ ) ENGINE = Distributed('aux', 'posthog_test', 'ingestion_warnings_v2')++ '''+# ---+# name: test_create_table_query[ingestion_warnings_v2_mv]+ '''++ CREATE MATERIALIZED VIEW IF NOT EXISTS ingestion_warnings_v2_mv+ TO posthog_test.ingestion_warnings_v2+ AS SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+ FROM posthog_test.kafka_ingestion_warnings_v2++ '''+# ---# name: test_create_table_query[kafka_ai_events_json]'''@@ -2216,6 +2305,22 @@'''# ---+# name: test_create_table_query[kafka_ingestion_warnings_v2]+ '''++ CREATE TABLE IF NOT EXISTS kafka_ingestion_warnings_v2+ (++ team_id Int64,+ source LowCardinality(String),+ type String,+ details String,+ timestamp DateTime64(6, 'UTC')++ ) ENGINE = Kafka(warpstream_ingestion, kafka_topic_list = 'clickhouse_ingestion_warnings_test', kafka_group_name = 'clickhouse_ingestion_warnings_v2', kafka_format = 'JSONEachRow')++ '''+# ---# name: test_create_table_query[kafka_log_entries]'''@@ -9238,6 +9343,35 @@'''# ---+# name: test_create_table_query_replicated_and_storage[ingestion_warnings_v2]+ '''++ CREATE TABLE IF NOT EXISTS ingestion_warnings_v2+ (++ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64++ ) ENGINE = ReplicatedMergeTree('/clickhouse/tables/77f1df52-4b43-11e9-910f-b8ca3a9b9f3e_noshard/posthog.ingestion_warnings_v2', '{replica}-{shard}')+ PARTITION BY toYYYYMM(timestamp)+ ORDER BY (team_id, type, timestamp)+ TTL toDateTime(timestamp) + INTERVAL 90 DAY++ '''+# ---# name: test_create_table_query_replicated_and_storage[log_attributes2]'''diff --git a/posthog/models/ingestion_warnings/sql_v2.py b/posthog/models/ingestion_warnings/sql_v2.pynew file mode 100644index 000000000000..4755090f8eb4--- /dev/null+++ b/posthog/models/ingestion_warnings/sql_v2.py@@ -0,0 +1,126 @@+from django.conf import settings++from posthog.clickhouse.kafka_engine import CONSUMER_GROUP_INGESTION_WARNINGS_V2, kafka_engine+from posthog.clickhouse.table_engines import Distributed, MergeTreeEngine, ReplicationScheme+from posthog.kafka_client.topics import KAFKA_INGESTION_WARNINGS++# Ingestion warnings v2: additive, structured warnings table living on the aux cluster+# (single shard, replicated). It reads the same `clickhouse_ingestion_warnings` Kafka topic+# as v1 through a dedicated consumer group, so it receives the full stream independently+# without touching the legacy path.+#+# Structured dimensions (category, severity, pipeline_step) and entity ids are DEFAULT+# expressions parsing the `details` JSON, so agents/MCP can filter without re-parsing JSON+# at query time. DEFAULT rather than MATERIALIZED: the MV (or producers) can later set the+# columns explicitly without a schema change, which MATERIALIZED would forbid.++TABLE_NAME = "ingestion_warnings_v2"+KAFKA_TABLE_NAME = f"kafka_{TABLE_NAME}"+MV_NAME = f"{TABLE_NAME}_mv"+DISTRIBUTED_TABLE_NAME = f"{TABLE_NAME}_distributed"++# Storage columns for the data + distributed tables. Derived dimensions and entity ids have+# DEFAULT expressions over the raw `details` JSON; the JSON key names must match what the+# producers emit (a mismatch just yields the default/NULL, it does not break ingestion).+INGESTION_WARNINGS_V2_COLUMNS = """+ team_id Int64,+ source LowCardinality(String),+ type LowCardinality(String),+ details String,+ timestamp DateTime64(6, 'UTC'),+ category LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown'),+ severity LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning'),+ pipeline_step LowCardinality(String) DEFAULT coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown'),+ event_uuid Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'eventUuid')),+ distinct_id Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'distinctId'), ''),+ group_key Nullable(String) DEFAULT nullIf(JSONExtractString(details, 'groupKey'), ''),+ person_id Nullable(UUID) DEFAULT toUUIDOrNull(JSONExtractString(details, 'personId')),+ _timestamp DateTime,+ _offset UInt64,+ _partition UInt64+"""++# Kafka engine table mirrors the current producer message shape only (team_id, source, type,+# details, timestamp). New dimensions are derived from `details` in the MV, so no producer or+# topic-schema change is required to start populating v2.+KAFKA_INGESTION_WARNINGS_V2_COLUMNS = """+ team_id Int64,+ source LowCardinality(String),+ type String,+ details String,+ timestamp DateTime64(6, 'UTC')+"""+++def INGESTION_WARNINGS_V2_DATA_TABLE_SQL() -> str:+ return """+CREATE TABLE IF NOT EXISTS {table_name}+(+ {columns}+) ENGINE = {engine}+PARTITION BY toYYYYMM(timestamp)+ORDER BY (team_id, type, timestamp)+TTL toDateTime(timestamp) + INTERVAL 90 DAY+""".format(+ table_name=TABLE_NAME,+ columns=INGESTION_WARNINGS_V2_COLUMNS,+ engine=MergeTreeEngine(TABLE_NAME, replication_scheme=ReplicationScheme.REPLICATED),+ )+++def KAFKA_INGESTION_WARNINGS_V2_TABLE_SQL() -> str:+ return """+CREATE TABLE IF NOT EXISTS {table_name}+(+ {columns}+) ENGINE = {engine}+""".format(+ table_name=KAFKA_TABLE_NAME,+ columns=KAFKA_INGESTION_WARNINGS_V2_COLUMNS,+ engine=kafka_engine(+ topic=KAFKA_INGESTION_WARNINGS,+ group=CONSUMER_GROUP_INGESTION_WARNINGS_V2,+ named_collection=settings.CLICKHOUSE_KAFKA_WARPSTREAM_INGESTION_NAMED_COLLECTION,+ ),+ )+++def INGESTION_WARNINGS_V2_MV_SQL() -> str:+ return """+CREATE MATERIALIZED VIEW IF NOT EXISTS {mv_name}+TO {database}.{target_table}+AS SELECT+ team_id,+ source,+ type,+ details,+ timestamp,+ _timestamp,+ _offset,+ _partition+FROM {database}.{kafka_table}+""".format(+ mv_name=MV_NAME,+ target_table=TABLE_NAME,+ kafka_table=KAFKA_TABLE_NAME,+ database=settings.CLICKHOUSE_DATABASE,+ )+++def DISTRIBUTED_INGESTION_WARNINGS_V2_TABLE_SQL() -> str:+ return """+CREATE TABLE IF NOT EXISTS {table_name}+(+ {columns}+) ENGINE = {engine}+""".format(+ table_name=DISTRIBUTED_TABLE_NAME,+ columns=INGESTION_WARNINGS_V2_COLUMNS,+ engine=Distributed(data_table=TABLE_NAME, cluster=settings.CLICKHOUSE_AUX_CLUSTER),+ )+++DROP_INGESTION_WARNINGS_V2_MV_SQL = f"DROP TABLE IF EXISTS {MV_NAME}"+DROP_KAFKA_INGESTION_WARNINGS_V2_TABLE_SQL = f"DROP TABLE IF EXISTS {KAFKA_TABLE_NAME}"+DROP_DISTRIBUTED_INGESTION_WARNINGS_V2_TABLE_SQL = f"DROP TABLE IF EXISTS {DISTRIBUTED_TABLE_NAME}"+DROP_INGESTION_WARNINGS_V2_DATA_TABLE_SQL = f"DROP TABLE IF EXISTS {TABLE_NAME} SYNC"