Skip to content

: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.

feat(logs): drop the two materialized views writing to log_attributes2 (#90996)

Jon McCallum7e7144115371
diff --git a/posthog/clickhouse/hcl/golden/dev/logs.hcl b/posthog/clickhouse/hcl/golden/dev/logs.hcl
index da618c7eb096..d6719677bdc5 100644
--- a/posthog/clickhouse/hcl/golden/dev/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/dev/logs.hcl
@@ -2752,68 +2752,6 @@ SQL
}
}
- materialized_view "logs34_to_log_attributes" {
- to_table = "posthog.log_attributes2"
- query = <<SQL
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- )
-SQL
-
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_log_attributes3" {
to_table = "posthog.log_attributes3"
query = <<SQL
@@ -2881,67 +2819,6 @@ SQL
}
}
- materialized_view "logs34_to_resource_attributes" {
- to_table = "posthog.log_attributes2"
- query = <<SQL
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- )
-SQL
-
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_resource_attributes3" {
to_table = "posthog.log_attributes3"
query = <<SQL
diff --git a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl b/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
index a6189e60c20b..a8da37cb56e1 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
@@ -3207,68 +3207,6 @@ SQL
}
}
- materialized_view "logs34_to_log_attributes" {
- to_table = "posthog.log_attributes2"
- query = <<SQL
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- )
-SQL
-
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_log_attributes3" {
to_table = "posthog.log_attributes3"
query = <<SQL
@@ -3336,67 +3274,6 @@ SQL
}
}
- materialized_view "logs34_to_resource_attributes" {
- to_table = "posthog.log_attributes2"
- query = <<SQL
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- )
-SQL
-
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_resource_attributes3" {
to_table = "posthog.log_attributes3"
query = <<SQL
diff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hcl
index 6c9e898b265a..f56e99f908e7 100644
--- a/posthog/clickhouse/hcl/golden/local-single/all.hcl
+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl
@@ -20320,68 +20320,6 @@ SQL
}
}
- materialized_view "logs34_to_log_attributes" {
- to_table = "posthog.log_attributes2"
- query = <<SQL
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- )
-SQL
-
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_log_attributes3" {
to_table = "posthog.log_attributes3"
query = <<SQL
@@ -20449,67 +20387,6 @@ SQL
}
}
- materialized_view "logs34_to_resource_attributes" {
- to_table = "posthog.log_attributes2"
- query = <<SQL
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- )
-SQL
-
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_resource_attributes3" {
to_table = "posthog.log_attributes3"
query = <<SQL
diff --git a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl b/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
index bf6d12bfae6b..b9d795bc03de 100644
--- a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
@@ -2789,68 +2789,6 @@ SQL
}
}
- materialized_view "logs34_to_log_attributes" {
- to_table = "posthog.log_attributes2"
- query = <<SQL
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- )
-SQL
-
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_log_attributes3" {
to_table = "posthog.log_attributes3"
query = <<SQL
@@ -2918,67 +2856,6 @@ SQL
}
}
- materialized_view "logs34_to_resource_attributes" {
- to_table = "posthog.log_attributes2"
- query = <<SQL
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- )
-SQL
-
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_resource_attributes3" {
to_table = "posthog.log_attributes3"
query = <<SQL
diff --git a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl b/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
index 0ec50c0921a4..36dc99dfec8e 100644
--- a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
@@ -2771,68 +2771,6 @@ SQL
}
}
- materialized_view "logs34_to_log_attributes" {
- to_table = "posthog.log_attributes2"
- query = <<SQL
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- )
-SQL
-
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_log_attributes3" {
to_table = "posthog.log_attributes3"
query = <<SQL
@@ -2900,67 +2838,6 @@ SQL
}
}
- materialized_view "logs34_to_resource_attributes" {
- to_table = "posthog.log_attributes2"
- query = <<SQL
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- )
-SQL
-
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_resource_attributes3" {
to_table = "posthog.log_attributes3"
query = <<SQL
diff --git a/posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_log_attributes.sql b/posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_log_attributes.sql
deleted file mode 100644
index d91daf759806..000000000000
--- a/posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_log_attributes.sql
+++ /dev/null
@@ -1,28 +0,0 @@
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- )
diff --git a/posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_resource_attributes.sql b/posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_resource_attributes.sql
deleted file mode 100644
index 79176a74ef32..000000000000
--- a/posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_resource_attributes.sql
+++ /dev/null
@@ -1,27 +0,0 @@
-SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- )
diff --git a/posthog/clickhouse/hcl/roles/logs/base/tables.hcl b/posthog/clickhouse/hcl/roles/logs/base/tables.hcl
index 07d65d1a0b87..3b65b22c5369 100644
--- a/posthog/clickhouse/hcl/roles/logs/base/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/logs/base/tables.hcl
@@ -99,38 +99,6 @@ database "posthog" {
}
}
- materialized_view "logs34_to_log_attributes" {
- to_table = "posthog.log_attributes2"
- query = file("sql/logs34_to_log_attributes.sql")
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_log_attributes3" {
to_table = "posthog.log_attributes3"
query = file("sql/logs34_to_log_attributes3.sql")
@@ -167,38 +135,6 @@ database "posthog" {
}
}
- materialized_view "logs34_to_resource_attributes" {
- to_table = "posthog.log_attributes2"
- query = file("sql/logs34_to_resource_attributes.sql")
- column "team_id" {
- type = "Int32"
- }
- column "time_bucket" {
- type = "DateTime64(0)"
- }
- column "original_expiry_time_bucket" {
- type = "DateTime64(0)"
- }
- column "service_name" {
- type = "LowCardinality(String)"
- }
- column "resource_fingerprint" {
- type = "UInt64"
- }
- column "attribute_key" {
- type = "LowCardinality(String)"
- }
- column "attribute_value" {
- type = "String"
- }
- column "attribute_type" {
- type = "LowCardinality(String)"
- }
- column "attribute_count" {
- type = "SimpleAggregateFunction(sum, UInt64)"
- }
- }
-
materialized_view "logs34_to_resource_attributes3" {
to_table = "posthog.log_attributes3"
query = file("sql/logs34_to_resource_attributes3.sql")
diff --git a/posthog/clickhouse/hcl/sql/dev/logs.sql b/posthog/clickhouse/hcl/sql/dev/logs.sql
index a70755423fa5..4eb15c4983ee 100644
--- a/posthog/clickhouse/hcl/sql/dev/logs.sql
+++ b/posthog/clickhouse/hcl/sql/dev/logs.sql
@@ -735,34 +735,6 @@ CREATE MATERIALIZED VIEW posthog.kafka_trace_spans_avro_mv TO posthog.trace_span
toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) AS _bytes_uncompressed,
toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) AS _bytes_compressed
FROM posthog.kafka_trace_spans_avro;
-CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- );
CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
team_id,
time_bucket,
@@ -793,33 +765,6 @@ FROM
GROUP BY
team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, severity_text, attributes
);
-CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- );
CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
team_id,
time_bucket,
diff --git a/posthog/clickhouse/hcl/sql/local-multi/logs.sql b/posthog/clickhouse/hcl/sql/local-multi/logs.sql
index 91580af78b82..cbaadd04fe33 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/logs.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/logs.sql
@@ -830,34 +830,6 @@ FROM
GROUP BY
team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
);
-CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- );
CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
team_id,
time_bucket,
@@ -888,33 +860,6 @@ FROM
GROUP BY
team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, severity_text, attributes
);
-CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- );
CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
team_id,
time_bucket,
diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sql
index c62e800eb3f5..1af8538bf9cb 100644
--- a/posthog/clickhouse/hcl/sql/local-single/all.sql
+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql
@@ -4682,34 +4682,6 @@ FROM
GROUP BY
team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
);
-CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- );
CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
team_id,
time_bucket,
@@ -4740,33 +4712,6 @@ FROM
GROUP BY
team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, severity_text, attributes
);
-CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- );
CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
team_id,
time_bucket,
diff --git a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql b/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
index 8cb706d18955..5300630f964c 100644
--- a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
+++ b/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
@@ -750,34 +750,6 @@ CREATE MATERIALIZED VIEW posthog.kafka_trace_spans_avro_mv TO posthog.trace_span
toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) AS _bytes_uncompressed,
toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) AS _bytes_compressed
FROM posthog.kafka_trace_spans_avro;
-CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- );
CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
team_id,
time_bucket,
@@ -808,33 +780,6 @@ FROM
GROUP BY
team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, severity_text, attributes
);
-CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- );
CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
team_id,
time_bucket,
diff --git a/posthog/clickhouse/hcl/sql/prod-us/logs.sql b/posthog/clickhouse/hcl/sql/prod-us/logs.sql
index cb079f884f58..da60c22d42bf 100644
--- a/posthog/clickhouse/hcl/sql/prod-us/logs.sql
+++ b/posthog/clickhouse/hcl/sql/prod-us/logs.sql
@@ -744,34 +744,6 @@ CREATE MATERIALIZED VIEW posthog.kafka_trace_spans_avro_mv TO posthog.trace_span
toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) AS _bytes_uncompressed,
toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) AS _bytes_compressed
FROM posthog.kafka_trace_spans_avro;
-CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes
- );
CREATE MATERIALIZED VIEW posthog.logs34_to_log_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
team_id,
time_bucket,
@@ -802,33 +774,6 @@ FROM
GROUP BY
team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, severity_text, attributes
);
-CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes TO posthog.log_attributes2 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog.logs34
- GROUP BY
- team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes
- );
CREATE MATERIALIZED VIEW posthog.logs34_to_resource_attributes3 TO posthog.log_attributes3 (team_id Int32, time_bucket DateTime64(0), original_expiry_time_bucket DateTime64(0), service_name LowCardinality(String), resource_fingerprint UInt64, attribute_key LowCardinality(String), attribute_value String, attribute_type LowCardinality(String), severity_text LowCardinality(String), attribute_count SimpleAggregateFunction(sum, UInt64)) AS SELECT
team_id,
time_bucket,
diff --git a/posthog/clickhouse/logs/__init__.py b/posthog/clickhouse/logs/__init__.py
index 19ba3060148b..19e88cedf9d1 100644
--- a/posthog/clickhouse/logs/__init__.py
+++ b/posthog/clickhouse/logs/__init__.py
@@ -18,9 +18,7 @@ from .logs34 import (
KAFKA_LOGS_AVRO_TABLE_SQL,
LOGS34_TABLE_SQL,
LOGS34_TO_LOG_ATTRIBUTES3_MV,
- LOGS34_TO_LOG_ATTRIBUTES_MV,
LOGS34_TO_RESOURCE_ATTRIBUTES3_MV,
- LOGS34_TO_RESOURCE_ATTRIBUTES_MV,
LOGS34_TO_VOLUME_BUCKETS_MV,
LOGS_DISTRIBUTED_TABLE_SQL as LOGS34_DISTRIBUTED_TABLE_SQL,
WRITABLE_LOGS34_TABLE_SQL,
@@ -43,8 +41,6 @@ __all__ = [
"LOGS_KAFKA_METRICS_DISTRIBUTED_TABLE_SQL",
"LOGS34_TABLE_SQL",
"LOGS34_DISTRIBUTED_TABLE_SQL",
- "LOGS34_TO_LOG_ATTRIBUTES_MV",
- "LOGS34_TO_RESOURCE_ATTRIBUTES_MV",
"LOGS34_TO_LOG_ATTRIBUTES3_MV",
"LOGS34_TO_RESOURCE_ATTRIBUTES3_MV",
"KAFKA_LOGS_AVRO_TABLE_SQL",
diff --git a/posthog/clickhouse/logs/logs34.py b/posthog/clickhouse/logs/logs34.py
index af6986b7095b..9851e3d43c6f 100644
--- a/posthog/clickhouse/logs/logs34.py
+++ b/posthog/clickhouse/logs/logs34.py
@@ -3,7 +3,6 @@ from django.conf import settings
from posthog.clickhouse.kafka_engine import kafka_engine
from posthog.clickhouse.table_engines import Distributed, MergeTreeEngine, ReplicationScheme
-from .log_attributes2 import TABLE_NAME as LOG_ATTRIBUTES_TABLE_NAME
from .log_attributes3 import TABLE_NAME as LOG_ATTRIBUTES3_TABLE_NAME
TABLE_NAME = "logs34"
@@ -155,105 +154,6 @@ SETTINGS background_insert_batch = 1
"""
-def LOGS34_TO_LOG_ATTRIBUTES_MV():
- return f"""
-CREATE MATERIALIZED VIEW IF NOT EXISTS {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{TABLE_NAME}_to_log_attributes TO {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{LOG_ATTRIBUTES_TABLE_NAME}
-(
- `team_id` Int32,
- `time_bucket` DateTime64(0),
- `original_expiry_time_bucket` DateTime64(0),
- `service_name` LowCardinality(String),
- `resource_fingerprint` UInt64,
- `attribute_key` LowCardinality(String),
- `attribute_value` String,
- `attribute_type` LowCardinality(String),
- `attribute_count` SimpleAggregateFunction(sum, UInt64)
-)
-AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
-(
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{TABLE_NAME}
- GROUP BY
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attributes
-)
-"""
-
-
-def LOGS34_TO_RESOURCE_ATTRIBUTES_MV():
- return f"""
-CREATE MATERIALIZED VIEW IF NOT EXISTS {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{TABLE_NAME}_to_resource_attributes TO {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{LOG_ATTRIBUTES_TABLE_NAME}
-(
- `team_id` Int32,
- `time_bucket` DateTime64(0),
- `original_expiry_time_bucket` DateTime64(0),
- `service_name` LowCardinality(String),
- `resource_fingerprint` UInt64,
- `attribute_key` LowCardinality(String),
- `attribute_value` String,
- `attribute_type` LowCardinality(String),
- `attribute_count` SimpleAggregateFunction(sum, UInt64)
-)
-AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
-FROM
-(
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{TABLE_NAME}
- GROUP BY
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- resource_attributes
-)
-"""
-
-
def LOGS34_TO_LOG_ATTRIBUTES3_MV():
return f"""
CREATE MATERIALIZED VIEW IF NOT EXISTS {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{TABLE_NAME}_to_log_attributes3 TO {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{LOG_ATTRIBUTES3_TABLE_NAME}
diff --git a/posthog/clickhouse/migrations/0280_logs34.py b/posthog/clickhouse/migrations/0280_logs34.py
index 76fb66231d98..40de0f25edad 100644
--- a/posthog/clickhouse/migrations/0280_logs34.py
+++ b/posthog/clickhouse/migrations/0280_logs34.py
@@ -1,3 +1,5 @@
+from django.conf import settings
+
from posthog.clickhouse.client.connection import NodeRole
from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions
from posthog.clickhouse.logs import (
@@ -9,14 +11,119 @@ from posthog.clickhouse.logs import (
LOG_ATTRIBUTES2_TABLE_SQL,
LOGS34_DISTRIBUTED_TABLE_SQL,
LOGS34_TABLE_SQL,
- LOGS34_TO_LOG_ATTRIBUTES_MV,
- LOGS34_TO_RESOURCE_ATTRIBUTES_MV,
LOGS_BILLING_METRICS_DISTRIBUTED_TABLE_SQL,
LOGS_BILLING_METRICS_TABLE_SQL,
LOGS_KAFKA_METRICS_DISTRIBUTED_TABLE_SQL,
LOGS_KAFKA_METRICS_TABLE_SQL,
)
+# These views no longer exist outside this file, so their SQL has to stay
+# local. Migration discovery imports every migration, so an import of a deleted
+# definition stops every run.
+
+TABLE_NAME = "logs34"
+LOG_ATTRIBUTES_TABLE_NAME = "log_attributes2"
+
+
+def LOGS34_TO_LOG_ATTRIBUTES_MV():
+ return f"""
+CREATE MATERIALIZED VIEW IF NOT EXISTS {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{TABLE_NAME}_to_log_attributes TO {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{LOG_ATTRIBUTES_TABLE_NAME}
+(
+ `team_id` Int32,
+ `time_bucket` DateTime64(0),
+ `original_expiry_time_bucket` DateTime64(0),
+ `service_name` LowCardinality(String),
+ `resource_fingerprint` UInt64,
+ `attribute_key` LowCardinality(String),
+ `attribute_value` String,
+ `attribute_type` LowCardinality(String),
+ `attribute_count` SimpleAggregateFunction(sum, UInt64)
+)
+AS SELECT
+ team_id,
+ time_bucket,
+ original_expiry_time_bucket,
+ service_name,
+ resource_fingerprint,
+ attribute_key,
+ attribute_value,
+ attribute_type,
+ attribute_count
+FROM
+(
+ SELECT
+ team_id AS team_id,
+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
+ service_name AS service_name,
+ resource_fingerprint,
+ mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
+ arrayJoin(attributes) AS attribute,
+ 'log' AS attribute_type,
+ attribute.1 AS attribute_key,
+ attribute.2 AS attribute_value,
+ sumSimpleState(1) AS attribute_count
+ FROM {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{TABLE_NAME}
+ GROUP BY
+ team_id,
+ time_bucket,
+ original_expiry_time_bucket,
+ service_name,
+ resource_fingerprint,
+ attributes
+)
+"""
+
+
+def LOGS34_TO_RESOURCE_ATTRIBUTES_MV():
+ return f"""
+CREATE MATERIALIZED VIEW IF NOT EXISTS {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{TABLE_NAME}_to_resource_attributes TO {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{LOG_ATTRIBUTES_TABLE_NAME}
+(
+ `team_id` Int32,
+ `time_bucket` DateTime64(0),
+ `original_expiry_time_bucket` DateTime64(0),
+ `service_name` LowCardinality(String),
+ `resource_fingerprint` UInt64,
+ `attribute_key` LowCardinality(String),
+ `attribute_value` String,
+ `attribute_type` LowCardinality(String),
+ `attribute_count` SimpleAggregateFunction(sum, UInt64)
+)
+AS SELECT
+ team_id,
+ time_bucket,
+ original_expiry_time_bucket,
+ service_name,
+ resource_fingerprint,
+ attribute_key,
+ attribute_value,
+ attribute_type,
+ attribute_count
+FROM
+(
+ SELECT
+ team_id AS team_id,
+ toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
+ toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
+ service_name AS service_name,
+ resource_fingerprint,
+ arrayJoin(resource_attributes) AS attribute,
+ 'resource' AS attribute_type,
+ attribute.1 AS attribute_key,
+ attribute.2 AS attribute_value,
+ sumSimpleState(1) AS attribute_count
+ FROM {settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE}.{TABLE_NAME}
+ GROUP BY
+ team_id,
+ time_bucket,
+ original_expiry_time_bucket,
+ service_name,
+ resource_fingerprint,
+ resource_attributes
+)
+"""
+
+
operations = [
run_sql_with_exceptions(LOGS34_TABLE_SQL(), node_roles=[NodeRole.LOGS]),
run_sql_with_exceptions(LOG_ATTRIBUTES2_TABLE_SQL(), node_roles=[NodeRole.LOGS]),
diff --git a/posthog/clickhouse/migrations/0311_drop_log_attributes_mvs.py b/posthog/clickhouse/migrations/0311_drop_log_attributes_mvs.py
new file mode 100644
index 000000000000..34a7252d0f30
--- /dev/null
+++ b/posthog/clickhouse/migrations/0311_drop_log_attributes_mvs.py
@@ -0,0 +1,25 @@
+from django.conf import settings
+
+from posthog.clickhouse.client.connection import NodeRole
+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions
+
+DB = settings.CLICKHOUSE_LOGS_CLUSTER_DATABASE
+
+# These two views are the only writers left to log_attributes2. 0288 pointed
+# log_attributes_distributed at log_attributes3, so readers reach 3 through the
+# alias and nothing consumes what these views produce.
+#
+# Dropping them stops the write and replication load straight away. The table
+# stays, so this step is reversible: the SQL to recreate both views sits in
+# 0280, which created them.
+
+operations = [
+ run_sql_with_exceptions(
+ f"DROP TABLE IF EXISTS {DB}.logs34_to_log_attributes",
+ node_roles=[NodeRole.LOGS],
+ ),
+ run_sql_with_exceptions(
+ f"DROP TABLE IF EXISTS {DB}.logs34_to_resource_attributes",
+ node_roles=[NodeRole.LOGS],
+ ),
+]
diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txt
index 852caf500265..ae7a878b4330 100644
--- a/posthog/clickhouse/migrations/max_migration.txt
+++ b/posthog/clickhouse/migrations/max_migration.txt
@@ -1 +1 @@
-0310_add_cleanup_snapshot_tables
+0311_drop_log_attributes_mvs
diff --git a/posthog/clickhouse/schema.py b/posthog/clickhouse/schema.py
index 335b39129c12..72ab8a2b62f5 100644
--- a/posthog/clickhouse/schema.py
+++ b/posthog/clickhouse/schema.py
@@ -20,9 +20,7 @@ from posthog.clickhouse.logs import (
LOGS32_TABLE_SQL,
LOGS34_TABLE_SQL,
LOGS34_TO_LOG_ATTRIBUTES3_MV,
- LOGS34_TO_LOG_ATTRIBUTES_MV,
LOGS34_TO_RESOURCE_ATTRIBUTES3_MV,
- LOGS34_TO_RESOURCE_ATTRIBUTES_MV,
LOGS34_TO_VOLUME_BUCKETS_MV,
LOGS_BILLING_METRICS_DISTRIBUTED_TABLE_SQL,
LOGS_BILLING_METRICS_TABLE_SQL,
@@ -607,8 +605,6 @@ CREATE_MV_TABLE_QUERIES = (
DISTINCT_ID_USAGE_MV_SQL,
LOG_ATTRIBUTES3_MV,
LOG_RESOURCE_ATTRIBUTES3_MV,
- LOGS34_TO_LOG_ATTRIBUTES_MV,
- LOGS34_TO_RESOURCE_ATTRIBUTES_MV,
LOGS34_TO_LOG_ATTRIBUTES3_MV,
LOGS34_TO_RESOURCE_ATTRIBUTES3_MV,
LOGS34_TO_VOLUME_BUCKETS_MV,
diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
index 1a928fcc0245..33b1765e09fb 100644
--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr
+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
@@ -3652,57 +3652,6 @@
'''
# ---
-# name: test_create_table_query[logs34_to_log_attributes]
- '''
-
- CREATE MATERIALIZED VIEW IF NOT EXISTS posthog_test.logs34_to_log_attributes TO posthog_test.log_attributes2
- (
- `team_id` Int32,
- `time_bucket` DateTime64(0),
- `original_expiry_time_bucket` DateTime64(0),
- `service_name` LowCardinality(String),
- `resource_fingerprint` UInt64,
- `attribute_key` LowCardinality(String),
- `attribute_value` String,
- `attribute_type` LowCardinality(String),
- `attribute_count` SimpleAggregateFunction(sum, UInt64)
- )
- AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
- FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes) AS attributes,
- arrayJoin(attributes) AS attribute,
- 'log' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog_test.logs34
- GROUP BY
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attributes
- )
-
- '''
-# ---
# name: test_create_table_query[logs34_to_resource_attributes3]
'''
@@ -3757,56 +3706,6 @@
'''
# ---
-# name: test_create_table_query[logs34_to_resource_attributes]
- '''
-
- CREATE MATERIALIZED VIEW IF NOT EXISTS posthog_test.logs34_to_resource_attributes TO posthog_test.log_attributes2
- (
- `team_id` Int32,
- `time_bucket` DateTime64(0),
- `original_expiry_time_bucket` DateTime64(0),
- `service_name` LowCardinality(String),
- `resource_fingerprint` UInt64,
- `attribute_key` LowCardinality(String),
- `attribute_value` String,
- `attribute_type` LowCardinality(String),
- `attribute_count` SimpleAggregateFunction(sum, UInt64)
- )
- AS SELECT
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- attribute_key,
- attribute_value,
- attribute_type,
- attribute_count
- FROM
- (
- SELECT
- team_id AS team_id,
- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,
- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,
- service_name AS service_name,
- resource_fingerprint,
- arrayJoin(resource_attributes) AS attribute,
- 'resource' AS attribute_type,
- attribute.1 AS attribute_key,
- attribute.2 AS attribute_value,
- sumSimpleState(1) AS attribute_count
- FROM posthog_test.logs34
- GROUP BY
- team_id,
- time_bucket,
- original_expiry_time_bucket,
- service_name,
- resource_fingerprint,
- resource_attributes
- )
-
- '''
-# ---
# name: test_create_table_query[logs34_to_volume_buckets]
'''