: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(metrics): drop the v1 metrics Avro Kafka ingest (#103864)
Frank Hamandd9ac09b45c85
diff --git a/posthog/clickhouse/hcl/golden/dev/apm.hcl b/posthog/clickhouse/hcl/golden/dev/apm.hclindex cf1ce405d7b6..04760e041d5f 100644--- a/posthog/clickhouse/hcl/golden/dev/apm.hcl+++ b/posthog/clickhouse/hcl/golden/dev/apm.hcl@@ -68,84 +68,6 @@ database "posthog" {}}- table "kafka_metrics_avro" {- settings = {- input_format_avro_allow_missing_fields = "1"- }- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Nullable(Int32)"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "service_name" {- type = "Nullable(String)"- }- column "metric_name" {- type = "Nullable(String)"- }- column "metric_type" {- type = "Nullable(String)"- }- column "value" {- type = "Nullable(Float64)"- }- column "count" {- type = "Nullable(Int64)"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(Int64)"- }- column "unit" {- type = "Nullable(String)"- }- column "aggregation_temporality" {- type = "Nullable(String)"- }- column "is_monotonic" {- type = "Nullable(UInt8)"- }- column "resource_attributes" {- type = "Map(String, String)"- }- column "instrumentation_scope" {- type = "Nullable(String)"- }- column "attributes" {- type = "Map(String, String)"- }- column "series_fingerprint" {- type = "Nullable(Int64)"- }- engine "kafka" {- collection = "warpstream_metrics"- topic_list = "clickhouse_metrics"- group_name = "clickhouse-metrics-avro-new"- format = "Avro"- num_consumers = 4- skip_broken_messages = 100- poll_timeout_ms = 10000- poll_max_batch_size = 1000- flush_interval_ms = 10000- thread_per_consumer = true- }- }-table "kafka_metrics_avro4" {settings = {input_format_avro_allow_missing_fields = "1"@@ -1399,45 +1321,6 @@ SQL}}- materialized_view "kafka_metrics_avro_kafka_metrics_mv" {- to_table = "posthog.writable_metrics_kafka_metrics"- query = <<SQL-SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topic-SQL-- column "_partition" {- type = "UInt64"- }- column "_topic" {- type = "LowCardinality(String)"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime)"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, Decimal(18, 6))"- }- }-materialized_view "kafka_trace_spans_avro_mv" {to_table = "posthog.writable_trace_spans"query = <<SQLdiff --git a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl b/posthog/clickhouse/hcl/golden/local-multi/logs.hclindex 865d14fe8878..8e2169f15448 100644--- a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl+++ b/posthog/clickhouse/hcl/golden/local-multi/logs.hcl@@ -1,78 +1,4 @@database "posthog" {- table "kafka_metrics_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Nullable(Int32)"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "service_name" {- type = "Nullable(String)"- }- column "metric_name" {- type = "Nullable(String)"- }- column "metric_type" {- type = "Nullable(String)"- }- column "value" {- type = "Nullable(Float64)"- }- column "count" {- type = "Nullable(Int64)"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(Int64)"- }- column "unit" {- type = "Nullable(String)"- }- column "aggregation_temporality" {- type = "Nullable(String)"- }- column "is_monotonic" {- type = "Nullable(UInt8)"- }- column "resource_attributes" {- type = "Map(String, String)"- }- column "instrumentation_scope" {- type = "Nullable(String)"- }- column "attributes" {- type = "Map(String, String)"- }- column "series_fingerprint" {- type = "Nullable(Int64)"- }- engine "kafka" {- collection = "warpstream_metrics"- topic_list = "clickhouse_metrics"- group_name = "clickhouse-metrics-avro-new"- format = "Avro"- num_consumers = 1- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }-table "kafka_metrics_avro2" {settings = {input_format_avro_allow_missing_fields = "1"@@ -4103,45 +4029,6 @@ SQL}}- materialized_view "kafka_metrics_avro_kafka_metrics_mv" {- to_table = "posthog.metrics_kafka_metrics"- query = <<SQL-SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topic-SQL-- column "_partition" {- type = "UInt64"- }- column "_topic" {- type = "LowCardinality(String)"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime)"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, Decimal(18, 6))"- }- }-materialized_view "kafka_trace_spans_avro_mv" {to_table = "posthog.trace_spans"query = <<SQLdiff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hclindex 2eebf020de57..2014c04a5839 100644--- a/posthog/clickhouse/hcl/golden/local-single/all.hcl+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl@@ -3617,80 +3617,6 @@ database "posthog" {}}- table "kafka_metrics_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Nullable(Int32)"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "service_name" {- type = "Nullable(String)"- }- column "metric_name" {- type = "Nullable(String)"- }- column "metric_type" {- type = "Nullable(String)"- }- column "value" {- type = "Nullable(Float64)"- }- column "count" {- type = "Nullable(Int64)"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(Int64)"- }- column "unit" {- type = "Nullable(String)"- }- column "aggregation_temporality" {- type = "Nullable(String)"- }- column "is_monotonic" {- type = "Nullable(UInt8)"- }- column "resource_attributes" {- type = "Map(String, String)"- }- column "instrumentation_scope" {- type = "Nullable(String)"- }- column "attributes" {- type = "Map(String, String)"- }- column "series_fingerprint" {- type = "Nullable(Int64)"- }- engine "kafka" {- collection = "warpstream_metrics"- topic_list = "clickhouse_metrics"- group_name = "clickhouse-metrics-avro-new"- format = "Avro"- num_consumers = 1- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }-table "kafka_metrics_avro2" {settings = {input_format_avro_allow_missing_fields = "1"@@ -21612,45 +21538,6 @@ SQL}}- materialized_view "kafka_metrics_avro_kafka_metrics_mv" {- to_table = "posthog.metrics_kafka_metrics"- query = <<SQL-SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topic-SQL-- column "_partition" {- type = "UInt64"- }- column "_topic" {- type = "LowCardinality(String)"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime)"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, Decimal(18, 6))"- }- }-materialized_view "kafka_trace_spans_avro_mv" {to_table = "posthog.trace_spans"query = <<SQLdiff --git a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl b/posthog/clickhouse/hcl/golden/prod-eu/logs.hclindex 7b3bdf1201e4..f4b0f97d90f1 100644--- a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl+++ b/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl@@ -1,78 +1,4 @@database "posthog" {- table "kafka_metrics_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Nullable(Int32)"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "service_name" {- type = "Nullable(String)"- }- column "metric_name" {- type = "Nullable(String)"- }- column "metric_type" {- type = "Nullable(String)"- }- column "value" {- type = "Nullable(Float64)"- }- column "count" {- type = "Nullable(Int64)"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(Int64)"- }- column "unit" {- type = "Nullable(String)"- }- column "aggregation_temporality" {- type = "Nullable(String)"- }- column "is_monotonic" {- type = "Nullable(UInt8)"- }- column "resource_attributes" {- type = "Map(String, String)"- }- column "instrumentation_scope" {- type = "Nullable(String)"- }- column "attributes" {- type = "Map(String, String)"- }- column "series_fingerprint" {- type = "Nullable(Int64)"- }- engine "kafka" {- collection = "warpstream_metrics"- topic_list = "clickhouse_metrics"- group_name = "clickhouse-metrics-avro-new"- format = "Avro"- num_consumers = 8- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }-table "kafka_metrics_avro2" {settings = {input_format_avro_allow_missing_fields = "1"@@ -3809,45 +3735,6 @@ SQL}}- materialized_view "kafka_metrics_avro_kafka_metrics_mv" {- to_table = "posthog.metrics_kafka_metrics"- query = <<SQL-SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topic-SQL-- column "_partition" {- type = "UInt64"- }- column "_topic" {- type = "LowCardinality(String)"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime)"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, Decimal(18, 6))"- }- }-materialized_view "kafka_trace_spans_avro_mv" {to_table = "posthog.trace_spans"query = <<SQLdiff --git a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl b/posthog/clickhouse/hcl/golden/prod-us/logs.hclindex 32eb973499e4..4e039b3c3da5 100644--- a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl+++ b/posthog/clickhouse/hcl/golden/prod-us/logs.hcl@@ -1,78 +1,4 @@database "posthog" {- table "kafka_metrics_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Nullable(Int32)"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "service_name" {- type = "Nullable(String)"- }- column "metric_name" {- type = "Nullable(String)"- }- column "metric_type" {- type = "Nullable(String)"- }- column "value" {- type = "Nullable(Float64)"- }- column "count" {- type = "Nullable(Int64)"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(Int64)"- }- column "unit" {- type = "Nullable(String)"- }- column "aggregation_temporality" {- type = "Nullable(String)"- }- column "is_monotonic" {- type = "Nullable(UInt8)"- }- column "resource_attributes" {- type = "Map(String, String)"- }- column "instrumentation_scope" {- type = "Nullable(String)"- }- column "attributes" {- type = "Map(String, String)"- }- column "series_fingerprint" {- type = "Nullable(Int64)"- }- engine "kafka" {- collection = "warpstream_metrics"- topic_list = "clickhouse_metrics"- group_name = "clickhouse-metrics-avro-new"- format = "Avro"- num_consumers = 8- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }-table "kafka_metrics_avro2" {settings = {input_format_avro_allow_missing_fields = "1"@@ -3791,45 +3717,6 @@ SQL}}- materialized_view "kafka_metrics_avro_kafka_metrics_mv" {- to_table = "posthog.metrics_kafka_metrics"- query = <<SQL-SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topic-SQL-- column "_partition" {- type = "UInt64"- }- column "_topic" {- type = "LowCardinality(String)"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime)"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, Decimal(18, 6))"- }- }-materialized_view "kafka_trace_spans_avro_mv" {to_table = "posthog.trace_spans"query = <<SQLdiff --git a/posthog/clickhouse/hcl/roles/apm/dev/tables.hcl b/posthog/clickhouse/hcl/roles/apm/dev/tables.hclindex bc86befc029f..2f6d2d70cd5d 100644--- a/posthog/clickhouse/hcl/roles/apm/dev/tables.hcl+++ b/posthog/clickhouse/hcl/roles/apm/dev/tables.hcl@@ -356,24 +356,6 @@ database "posthog" {}}- patch_table "kafka_metrics_avro" {- engine "kafka" {- collection = "warpstream_metrics"- topic_list = "clickhouse_metrics"- group_name = "clickhouse-metrics-avro-new"- format = "Avro"- num_consumers = 4- skip_broken_messages = 100- poll_timeout_ms = 10000- poll_max_batch_size = 1000- flush_interval_ms = 10000- thread_per_consumer = true- }- settings = {- input_format_avro_allow_missing_fields = "1"- }- }-patch_table "kafka_metrics_avro4" {engine "kafka" {collection = "warpstream_metrics"@@ -411,10 +393,6 @@ database "posthog" {}}- patch_materialized_view "kafka_metrics_avro_kafka_metrics_mv" {- to_table = "posthog.writable_metrics_kafka_metrics"- }-patch_materialized_view "kafka_trace_spans_avro_mv" {to_table = "posthog.writable_trace_spans"diff --git a/posthog/clickhouse/hcl/roles/coshared/apm_ingest/sql/kafka_metrics_avro_kafka_metrics_mv.sql b/posthog/clickhouse/hcl/roles/coshared/apm_ingest/sql/kafka_metrics_avro_kafka_metrics_mv.sqldeleted file mode 100644index 78119c311222..000000000000--- a/posthog/clickhouse/hcl/roles/coshared/apm_ingest/sql/kafka_metrics_avro_kafka_metrics_mv.sql+++ /dev/null@@ -1,11 +0,0 @@-SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topicdiff --git a/posthog/clickhouse/hcl/roles/coshared/apm_ingest/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/apm_ingest/tables.hclindex ed91e7d5e624..f7924335f5a6 100644--- a/posthog/clickhouse/hcl/roles/coshared/apm_ingest/tables.hcl+++ b/posthog/clickhouse/hcl/roles/coshared/apm_ingest/tables.hcl@@ -1,107 +1,7 @@-# The Kafka ingest for metrics and traces: the consumers and the views that-# drain them. dev runs this on its ingestion-apm nodes, the prod clusters on-# their logs nodes, so it sits here rather than inside either role.+# The Kafka ingest for traces: the consumer and the view that drains it. dev runs+# this on its ingestion-apm nodes, the prod clusters on their logs nodes, so it sits+# here rather than inside either role.database "posthog" {- table "kafka_metrics_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Nullable(Int32)"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "service_name" {- type = "Nullable(String)"- }- column "metric_name" {- type = "Nullable(String)"- }- column "metric_type" {- type = "Nullable(String)"- }- column "value" {- type = "Nullable(Float64)"- }- column "count" {- type = "Nullable(Int64)"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(Int64)"- }- column "unit" {- type = "Nullable(String)"- }- column "aggregation_temporality" {- type = "Nullable(String)"- }- column "is_monotonic" {- type = "Nullable(UInt8)"- }- column "resource_attributes" {- type = "Map(String, String)"- }- column "instrumentation_scope" {- type = "Nullable(String)"- }- column "attributes" {- type = "Map(String, String)"- }- column "series_fingerprint" {- type = "Nullable(Int64)"- }- engine "kafka" {- collection = "warpstream_metrics"- topic_list = "clickhouse_metrics"- group_name = "clickhouse-metrics-avro-new"- format = "Avro"- num_consumers = 8- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }-- materialized_view "kafka_metrics_avro_kafka_metrics_mv" {- to_table = "posthog.metrics_kafka_metrics"- query = file("sql/kafka_metrics_avro_kafka_metrics_mv.sql")- column "_partition" {- type = "UInt64"- }- column "_topic" {- type = "LowCardinality(String)"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime)"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, Decimal(18, 6))"- }- }-table "kafka_trace_spans_avro" {column "uuid" {type = "String"diff --git a/posthog/clickhouse/hcl/roles/logs/local/tables.hcl b/posthog/clickhouse/hcl/roles/logs/local/tables.hclindex af16885a54f9..c879e6beafba 100644--- a/posthog/clickhouse/hcl/roles/logs/local/tables.hcl+++ b/posthog/clickhouse/hcl/roles/logs/local/tables.hcl@@ -640,20 +640,6 @@ SQL# Local stacks create every topic with one partition, so only one consumer of this group can# get an assignment. The rest retry forever, which holds threads and floods the server log.- patch_table "kafka_metrics_avro" {- engine "kafka" {- collection = "warpstream_metrics"- topic_list = "clickhouse_metrics"- group_name = "clickhouse-metrics-avro-new"- format = "Avro"- num_consumers = 1- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }-patch_table "kafka_metrics_avro2" {engine "kafka" {collection = "warpstream_metrics"diff --git a/posthog/clickhouse/hcl/roles/logs/metrics/sql/kafka_metrics_avro_kafka_metrics_mv.sql b/posthog/clickhouse/hcl/roles/logs/metrics/sql/kafka_metrics_avro_kafka_metrics_mv.sqldeleted file mode 100644index 78119c311222..000000000000--- a/posthog/clickhouse/hcl/roles/logs/metrics/sql/kafka_metrics_avro_kafka_metrics_mv.sql+++ /dev/null@@ -1,11 +0,0 @@-SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topicdiff --git a/posthog/clickhouse/hcl/sql/dev/apm.sql b/posthog/clickhouse/hcl/sql/dev/apm.sqlindex 913f2cf627bb..3168bc537407 100644--- a/posthog/clickhouse/hcl/sql/dev/apm.sql+++ b/posthog/clickhouse/hcl/sql/dev/apm.sql@@ -20,28 +20,6 @@ CREATE TABLE posthog.kafka_logs_avro (pattern Nullable(String),pattern_version Nullable(Int32)) ENGINE = Kafka(warpstream_logs) SETTINGS input_format_avro_allow_missing_fields = 1, kafka_flush_interval_ms = 10000, kafka_format = 'Avro', kafka_group_name = 'clickhouse-logs-avro-new', kafka_num_consumers = 4, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_logs';-CREATE TABLE posthog.kafka_metrics_avro (- uuid String,- trace_id String,- span_id String,- trace_flags Nullable(Int32),- timestamp DateTime64(6),- observed_timestamp DateTime64(6),- service_name Nullable(String),- metric_name Nullable(String),- metric_type Nullable(String),- value Nullable(Float64),- count Nullable(Int64),- histogram_bounds Array(Float64),- histogram_counts Array(Int64),- unit Nullable(String),- aggregation_temporality Nullable(String),- is_monotonic Nullable(UInt8),- resource_attributes Map(String, String),- instrumentation_scope Nullable(String),- attributes Map(String, String),- series_fingerprint Nullable(Int64)-) ENGINE = Kafka(warpstream_metrics) SETTINGS input_format_avro_allow_missing_fields = 1, kafka_flush_interval_ms = 10000, kafka_format = 'Avro', kafka_group_name = 'clickhouse-metrics-avro-new', kafka_num_consumers = 4, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_metrics';CREATE TABLE posthog.kafka_metrics_avro4 (uuid String,trace_id String,@@ -432,17 +410,6 @@ WHERE kafka_metrics_avro4.series_fingerprint IS NOT NULLSETTINGSmin_insert_block_size_rows = 0,min_insert_block_size_bytes = 0;-CREATE MATERIALIZED VIEW posthog.kafka_metrics_avro_kafka_metrics_mv TO posthog.writable_metrics_kafka_metrics (_partition UInt64, _topic LowCardinality(String), max_offset SimpleAggregateFunction(max, UInt64), max_observed_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_created_at SimpleAggregateFunction(max, DateTime), max_lag SimpleAggregateFunction(max, Decimal(18, 6))) AS SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topic;CREATE MATERIALIZED VIEW posthog.kafka_trace_spans_avro_mv TO posthog.writable_trace_spans (uuid String, trace_id String, span_id String, parent_span_id String, trace_state String, name String, kind Int8, flags UInt32, timestamp DateTime64(6), end_time DateTime64(6), observed_timestamp DateTime64(6), service_name String, resource_attributes Map(String, String), instrumentation_scope String, attributes_map_str Map(String, String), dropped_attributes_count UInt32, events Array(String), dropped_events_count UInt32, links Array(String), dropped_links_count UInt32, status_code Int16, team_id Int32, original_expiry_timestamp DateTime64(6), _partition UInt64, _topic LowCardinality(String), _offset UInt64, _record_count Int64, _bytes_uncompressed Nullable(Int64), _bytes_compressed Nullable(Int64)) AS SELECTuuid,trace_id,diff --git a/posthog/clickhouse/hcl/sql/local-multi/logs.sql b/posthog/clickhouse/hcl/sql/local-multi/logs.sqlindex a7b6e868b12d..cb27908ff2d8 100644--- a/posthog/clickhouse/hcl/sql/local-multi/logs.sql+++ b/posthog/clickhouse/hcl/sql/local-multi/logs.sql@@ -1,28 +1,6 @@-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.-- Full CREATE schema for the local-multi/logs node. Apply to a fresh ClickHouse to build it.-CREATE TABLE posthog.kafka_metrics_avro (- uuid String,- trace_id String,- span_id String,- trace_flags Nullable(Int32),- timestamp DateTime64(6),- observed_timestamp DateTime64(6),- service_name Nullable(String),- metric_name Nullable(String),- metric_type Nullable(String),- value Nullable(Float64),- count Nullable(Int64),- histogram_bounds Array(Float64),- histogram_counts Array(Int64),- unit Nullable(String),- aggregation_temporality Nullable(String),- is_monotonic Nullable(UInt8),- resource_attributes Map(String, String),- instrumentation_scope Nullable(String),- attributes Map(String, String),- series_fingerprint Nullable(Int64)-) ENGINE = Kafka(warpstream_metrics) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-metrics-avro-new', kafka_num_consumers = 1, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_metrics';CREATE TABLE posthog.kafka_metrics_avro2 (uuid String,trace_id String,@@ -1064,17 +1042,6 @@ WHERE kafka_metrics_avro2.series_fingerprint IS NOT NULLSETTINGSmin_insert_block_size_rows = 0,min_insert_block_size_bytes = 0;-CREATE MATERIALIZED VIEW posthog.kafka_metrics_avro_kafka_metrics_mv TO posthog.metrics_kafka_metrics (_partition UInt64, _topic LowCardinality(String), max_offset SimpleAggregateFunction(max, UInt64), max_observed_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_created_at SimpleAggregateFunction(max, DateTime), max_lag SimpleAggregateFunction(max, Decimal(18, 6))) AS SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topic;CREATE MATERIALIZED VIEW posthog.kafka_trace_spans_avro_mv TO posthog.trace_spans (uuid String, trace_id String, span_id String, parent_span_id String, trace_state String, name String, kind Int8, flags UInt32, timestamp DateTime64(6), end_time DateTime64(6), observed_timestamp DateTime64(6), service_name String, resource_attributes Map(LowCardinality(String), String), instrumentation_scope String, attributes_map_str Map(LowCardinality(String), String), dropped_attributes_count UInt32, events Array(String), dropped_events_count UInt32, links Array(String), dropped_links_count UInt32, status_code Int16, team_id Int32, original_expiry_timestamp DateTime64(6)) AS SELECTuuid,trace_id,diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sqlindex 793dedb85673..ab22a8d24f10 100644--- a/posthog/clickhouse/hcl/sql/local-single/all.sql+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql@@ -599,28 +599,6 @@ CREATE TABLE posthog.kafka_message_assets (is_deleted UInt8,html String) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_message_assets', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_message_assets';-CREATE TABLE posthog.kafka_metrics_avro (- uuid String,- trace_id String,- span_id String,- trace_flags Nullable(Int32),- timestamp DateTime64(6),- observed_timestamp DateTime64(6),- service_name Nullable(String),- metric_name Nullable(String),- metric_type Nullable(String),- value Nullable(Float64),- count Nullable(Int64),- histogram_bounds Array(Float64),- histogram_counts Array(Int64),- unit Nullable(String),- aggregation_temporality Nullable(String),- is_monotonic Nullable(UInt8),- resource_attributes Map(String, String),- instrumentation_scope Nullable(String),- attributes Map(String, String),- series_fingerprint Nullable(Int64)-) ENGINE = Kafka(warpstream_metrics) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-metrics-avro-new', kafka_num_consumers = 1, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_metrics';CREATE TABLE posthog.kafka_metrics_avro2 (uuid String,trace_id String,@@ -5076,17 +5054,6 @@ WHERE kafka_metrics_avro4.series_fingerprint IS NOT NULLSETTINGSmin_insert_block_size_rows = 0,min_insert_block_size_bytes = 0;-CREATE MATERIALIZED VIEW posthog.kafka_metrics_avro_kafka_metrics_mv TO posthog.metrics_kafka_metrics (_partition UInt64, _topic LowCardinality(String), max_offset SimpleAggregateFunction(max, UInt64), max_observed_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_created_at SimpleAggregateFunction(max, DateTime), max_lag SimpleAggregateFunction(max, Decimal(18, 6))) AS SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topic;CREATE MATERIALIZED VIEW posthog.kafka_trace_spans_avro_mv TO posthog.trace_spans (uuid String, trace_id String, span_id String, parent_span_id String, trace_state String, name String, kind Int8, flags UInt32, timestamp DateTime64(6), end_time DateTime64(6), observed_timestamp DateTime64(6), service_name String, resource_attributes Map(LowCardinality(String), String), instrumentation_scope String, attributes_map_str Map(LowCardinality(String), String), dropped_attributes_count UInt32, events Array(String), dropped_events_count UInt32, links Array(String), dropped_links_count UInt32, status_code Int16, team_id Int32, original_expiry_timestamp DateTime64(6)) AS SELECTuuid,trace_id,diff --git a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql b/posthog/clickhouse/hcl/sql/prod-eu/logs.sqlindex 4a5cb9b6b978..e7b7a65839ba 100644--- a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql+++ b/posthog/clickhouse/hcl/sql/prod-eu/logs.sql@@ -1,28 +1,6 @@-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.-- Full CREATE schema for the prod-eu/logs node. Apply to a fresh ClickHouse to build it.-CREATE TABLE posthog.kafka_metrics_avro (- uuid String,- trace_id String,- span_id String,- trace_flags Nullable(Int32),- timestamp DateTime64(6),- observed_timestamp DateTime64(6),- service_name Nullable(String),- metric_name Nullable(String),- metric_type Nullable(String),- value Nullable(Float64),- count Nullable(Int64),- histogram_bounds Array(Float64),- histogram_counts Array(Int64),- unit Nullable(String),- aggregation_temporality Nullable(String),- is_monotonic Nullable(UInt8),- resource_attributes Map(String, String),- instrumentation_scope Nullable(String),- attributes Map(String, String),- series_fingerprint Nullable(Int64)-) ENGINE = Kafka(warpstream_metrics) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-metrics-avro-new', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_metrics';CREATE TABLE posthog.kafka_metrics_avro2 (uuid String,trace_id String,@@ -1039,17 +1017,6 @@ WHERE kafka_metrics_avro2.series_fingerprint IS NOT NULLSETTINGSmin_insert_block_size_rows = 0,min_insert_block_size_bytes = 0;-CREATE MATERIALIZED VIEW posthog.kafka_metrics_avro_kafka_metrics_mv TO posthog.metrics_kafka_metrics (_partition UInt64, _topic LowCardinality(String), max_offset SimpleAggregateFunction(max, UInt64), max_observed_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_created_at SimpleAggregateFunction(max, DateTime), max_lag SimpleAggregateFunction(max, Decimal(18, 6))) AS SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topic;CREATE MATERIALIZED VIEW posthog.kafka_trace_spans_avro_mv TO posthog.trace_spans (uuid String, trace_id String, span_id String, parent_span_id String, trace_state String, name String, kind Int8, flags UInt32, timestamp DateTime64(6), end_time DateTime64(6), observed_timestamp DateTime64(6), service_name String, resource_attributes Map(LowCardinality(String), String), instrumentation_scope String, attributes_map_str Map(LowCardinality(String), String), dropped_attributes_count UInt32, events Array(String), dropped_events_count UInt32, links Array(String), dropped_links_count UInt32, status_code Int16, team_id Int32, original_expiry_timestamp DateTime64(6)) AS SELECTuuid,trace_id,diff --git a/posthog/clickhouse/hcl/sql/prod-us/logs.sql b/posthog/clickhouse/hcl/sql/prod-us/logs.sqlindex f72701107923..fe61a8cbc88e 100644--- a/posthog/clickhouse/hcl/sql/prod-us/logs.sql+++ b/posthog/clickhouse/hcl/sql/prod-us/logs.sql@@ -1,28 +1,6 @@-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.-- Full CREATE schema for the prod-us/logs node. Apply to a fresh ClickHouse to build it.-CREATE TABLE posthog.kafka_metrics_avro (- uuid String,- trace_id String,- span_id String,- trace_flags Nullable(Int32),- timestamp DateTime64(6),- observed_timestamp DateTime64(6),- service_name Nullable(String),- metric_name Nullable(String),- metric_type Nullable(String),- value Nullable(Float64),- count Nullable(Int64),- histogram_bounds Array(Float64),- histogram_counts Array(Int64),- unit Nullable(String),- aggregation_temporality Nullable(String),- is_monotonic Nullable(UInt8),- resource_attributes Map(String, String),- instrumentation_scope Nullable(String),- attributes Map(String, String),- series_fingerprint Nullable(Int64)-) ENGINE = Kafka(warpstream_metrics) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-metrics-avro-new', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_metrics';CREATE TABLE posthog.kafka_metrics_avro2 (uuid String,trace_id String,@@ -1033,17 +1011,6 @@ WHERE kafka_metrics_avro2.series_fingerprint IS NOT NULLSETTINGSmin_insert_block_size_rows = 0,min_insert_block_size_bytes = 0;-CREATE MATERIALIZED VIEW posthog.kafka_metrics_avro_kafka_metrics_mv TO posthog.metrics_kafka_metrics (_partition UInt64, _topic LowCardinality(String), max_offset SimpleAggregateFunction(max, UInt64), max_observed_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_timestamp SimpleAggregateFunction(max, DateTime64(6)), max_created_at SimpleAggregateFunction(max, DateTime), max_lag SimpleAggregateFunction(max, Decimal(18, 6))) AS SELECT- _partition,- _topic,- maxSimpleState(_offset) AS max_offset,- maxSimpleState(observed_timestamp) AS max_observed_timestamp,- maxSimpleState(timestamp) AS max_timestamp,- maxSimpleState(now()) AS max_created_at,- maxSimpleState(now() - observed_timestamp) AS max_lag-FROM posthog.kafka_metrics_avro-GROUP BY- _partition, _topic;CREATE MATERIALIZED VIEW posthog.kafka_trace_spans_avro_mv TO posthog.trace_spans (uuid String, trace_id String, span_id String, parent_span_id String, trace_state String, name String, kind Int8, flags UInt32, timestamp DateTime64(6), end_time DateTime64(6), observed_timestamp DateTime64(6), service_name String, resource_attributes Map(LowCardinality(String), String), instrumentation_scope String, attributes_map_str Map(LowCardinality(String), String), dropped_attributes_count UInt32, events Array(String), dropped_events_count UInt32, links Array(String), dropped_links_count UInt32, status_code Int16, team_id Int32, original_expiry_timestamp DateTime64(6)) AS SELECTuuid,trace_id,diff --git a/posthog/clickhouse/migrations/0340_drop_metrics_avro1_kafka_ingest.py b/posthog/clickhouse/migrations/0340_drop_metrics_avro1_kafka_ingest.pynew file mode 100644index 000000000000..823f0b11d112--- /dev/null+++ b/posthog/clickhouse/migrations/0340_drop_metrics_avro1_kafka_ingest.py@@ -0,0 +1,17 @@+from posthog.clickhouse.client.connection import NodeRole+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions++# metrics2 and metrics4 own metrics ingest now. 0321 removed the last views that wrote+# metrics data out of kafka_metrics_avro, leaving only the consumer-lag view, so the+# consumer still reads clickhouse_metrics for bookkeeping alone. Drop the view first,+# then the Kafka table it reads. Neither is replicated, so no SYNC.+operations = [+ run_sql_with_exceptions(+ "DROP TABLE IF EXISTS kafka_metrics_avro_kafka_metrics_mv",+ node_roles=[NodeRole.LOGS, NodeRole.APM],+ ),+ run_sql_with_exceptions(+ "DROP TABLE IF EXISTS kafka_metrics_avro",+ node_roles=[NodeRole.LOGS, NodeRole.APM],+ ),+]diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txtindex a59999076869..deeab9508b11 100644--- a/posthog/clickhouse/migrations/max_migration.txt+++ b/posthog/clickhouse/migrations/max_migration.txt@@ -1 +1 @@-0339_platform_alert_events+0340_drop_metrics_avro1_kafka_ingest