: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
docs(clickhouse): define what "defined once" counts in the HCL migration rule (#78267)
Paweł Szczurfb04b5295581
diff --git a/posthog/clickhouse/hcl/duplicates-baseline.txt b/posthog/clickhouse/hcl/duplicates-baseline.txtindex c2fa359309f9..e28c27f7400b 100644--- a/posthog/clickhouse/hcl/duplicates-baseline.txt+++ b/posthog/clickhouse/hcl/duplicates-baseline.txt@@ -1,81 +1,15 @@-# Objects currently declared in >=2 composed layers (database.name), sorted.+# Objects still declared in >=2 composed layers (database.name), sorted.# The locate -duplicates guard in check.sh fails on any duplicate NOT listed here.-# This list only shrinks: as Phase 2 dedups a role into coshared/extend layers,-# remove its objects. Must reach empty by Phase 4, after which the file is dropped.-posthog.ai_events+# This list only shrinks. Every remaining entry has a named blocker:+# - kafka_logs34_avro_mv, kafka_logs_avro_billing_metrics_mv,+# kafka_trace_spans_avro_mv: materialized views whose query differs per env;+# hclexp has no override = true and no patch form for MVs yet (chschema #169).+# - events, raw_sessions_v3, channel_definition: events-family replicas whose+# env copies carry mat_ columns; they resolve when the cloud env overlays+# move to posthog-cloud-infra (Phase 2), not by a restructure here.posthog.channel_definition-posthog.channel_definition_dict-posthog.cohortpeople-posthog.conversion_goal_attributed_preaggregated-posthog.custom_metrics-posthog.error_tracking_fingerprint_issue_stateposthog.events-posthog.events_main-posthog.events_recent-posthog.experiment_metric_events_preaggregated-posthog.hog_invocation_results-posthog.hog_invocation_results_data-posthog.ingestion_warnings_v2_distributed-posthog.kafka_hog_invocation_results-posthog.kafka_logs_avro-posthog.kafka_logs_avro_billing_metrics_mv-posthog.kafka_logs_avro_kafka_metrics_mvposthog.kafka_logs34_avro_mv-posthog.kafka_trace_spans_avro+posthog.kafka_logs_avro_billing_metrics_mvposthog.kafka_trace_spans_avro_mv-posthog.log_attributes_distributed-posthog.log_attributes2-posthog.log_attributes3-posthog.logs_billing_metrics-posthog.logs_billing_metrics_distributed-posthog.logs_distributed-posthog.logs_kafka_metrics-posthog.logs_kafka_metrics_distributed-posthog.logs34-posthog.logs34_to_log_attributes-posthog.logs34_to_log_attributes3-posthog.logs34_to_resource_attributes-posthog.logs34_to_resource_attributes3-posthog.marketing_conversions_preaggregated-posthog.marketing_costs_preaggregated-posthog.marketing_touchpoints_preaggregated-posthog.message_assets-posthog.metric_samples-posthog.metric_samples1-posthog.metric_series-posthog.metric_series1-posthog.metrics-posthog.metrics1-posthog.person-posthog.person_distinct_id_overrides-posthog.person_distinct_id2-posthog.person_static_cohort-posthog.property_values_distributed-posthog.query_log_archive-posthog.raw_sessionsposthog.raw_sessions_v3-posthog.session_replay_features-posthog.sessions-posthog.sharded_events_recent-posthog.sharded_ingestion_warnings-posthog.sharded_tophog-posthog.trace_attributes-posthog.trace_attributes_distributed-posthog.trace_span_to_attributes-posthog.trace_span_to_resource_attributes-posthog.trace_span_to_span_attributes-posthog.trace_spans-posthog.trace_spans_distributed-posthog.trace_spans_kafka_metrics-posthog.trace_spans_to_kafka_metrics_mv-posthog.web_bot_definition-posthog.web_bot_definition_dict-posthog.web_bounces_dimensional_preaggregated-posthog.web_goals_preaggregated-posthog.web_pre_aggregated_teams-posthog.web_pre_aggregated_teams_dict-posthog.web_stats_dimensional_preaggregated-posthog.web_stats_frustration_preaggregated-posthog.web_stats_preaggregated-posthog.web_vitals_paths_preaggregated-posthog.writable_events_recentdiff --git a/posthog/clickhouse/hcl/manifest.hcl b/posthog/clickhouse/hcl/manifest.hclindex a578b20ac4a0..9c59a8ba51b1 100644--- a/posthog/clickhouse/hcl/manifest.hcl+++ b/posthog/clickhouse/hcl/manifest.hcl@@ -26,20 +26,20 @@# golden from a host of that role (codegen/README has the extraction).role "ops" {- env "local-multi" { layers = ["roles/shared", "roles/ops/shared", "roles/ops/local"] }- env "dev" { layers = ["roles/shared", "roles/ops/shared", "roles/ops/dev"] }- env "prod-us" { layers = ["roles/shared", "roles/ops/shared", "roles/ops/prod", "roles/ops/prod-us"] }- env "prod-eu" { layers = ["roles/shared", "roles/ops/shared", "roles/ops/prod", "roles/ops/prod-eu"] }+ env "local-multi" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/ops/shared", "roles/ops/local"] }+ env "dev" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/ops/shared", "roles/ops/dev"] }+ env "prod-us" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/ops/shared", "roles/ops/prod", "roles/ops/prod-us"] }+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/tophog", "roles/ops/shared", "roles/ops/prod", "roles/ops/prod-eu"] }}# The local LOGS node runs a partial/newer schema than the cloud logs nodes, so it# composes a self-contained roles/logs/local (extracted from the live node) rather# than the shared cloud layers.role "logs" {- env "local-multi" { layers = ["roles/logs/local"] }- env "dev" { layers = ["roles/shared", "roles/logs/shared", "roles/logs/dev"] }- env "prod-us" { layers = ["roles/shared", "roles/logs/shared", "roles/logs/prod", "roles/logs/prod-us"] }- env "prod-eu" { layers = ["roles/shared", "roles/logs/shared", "roles/logs/prod", "roles/logs/prod-eu"] }+ env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/local"] }+ env "dev" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/logs/base", "roles/logs/shared", "roles/logs/dev"] }+ env "prod-us" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/shared", "roles/logs/prod", "roles/logs/prod-us"] }+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/logs/base", "roles/logs/traces", "roles/logs/shared", "roles/logs/prod", "roles/logs/prod-eu"] }}# AI_EVENTS satellite (LLM analytics). local/hobby run the MSK variant@@ -50,10 +50,10 @@ role "logs" {# env-uniform person / person_distinct_id2 Distributed shims (0240). dev currently# has only the top-level shared objects (per the latest dump).role "ai_events" {- env "local-multi" { layers = ["roles/shared", "roles/ai_events/shared", "roles/ai_events/local"] }+ env "local-multi" { layers = ["roles/shared", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/local"] }env "dev" { layers = ["roles/shared"] }- env "prod-us" { layers = ["roles/shared", "roles/ai_events/shared", "roles/ai_events/prod"] }- env "prod-eu" { layers = ["roles/shared", "roles/ai_events/shared", "roles/ai_events/prod"] }+ env "prod-us" { layers = ["roles/shared", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod"] }+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod"] }}# AUX satellite: auxiliary tables (error tracking, hog invocations, message assets,@@ -62,9 +62,9 @@ role "ai_events" {# kafka_hog_invocation_results); prod carries the WarpStream variant. prod-us adds the# ingestion_warnings tables. prod goldens are dump-baselined (not live-verifiable here).role "aux" {- env "local-multi" { layers = ["roles/shared", "roles/auxiliary/shared", "roles/auxiliary/local"] }- env "prod-us" { layers = ["roles/shared", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-us"] }- env "prod-eu" { layers = ["roles/shared", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-eu"] }+ env "local-multi" { layers = ["roles/shared", "roles/coshared/aux_data", "roles/auxiliary/shared", "roles/auxiliary/local"] }+ env "prod-us" { layers = ["roles/shared", "roles/coshared/aux_data", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-us"] }+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/aux_data", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-eu"] }}# SESSIONS satellite: the local node runs only the shared query_log_archive path@@ -76,8 +76,8 @@ role "aux" {# has writable_events_recent). prod goldens are dump-baselined (not live-verifiable here).role "sessions" {env "local-multi" { layers = ["roles/shared"] }- env "prod-us" { layers = ["roles/shared", "roles/sessions/shared", "roles/sessions/prod-us"] }- env "prod-eu" { layers = ["roles/shared", "roles/sessions/shared", "roles/sessions/prod-eu"] }+ env "prod-us" { layers = ["roles/shared", "roles/coshared/sessions_data", "roles/coshared/events_recent_write", "roles/sessions/shared", "roles/sessions/prod-us"] }+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/sessions_data", "roles/sessions/shared", "roles/sessions/prod-eu"] }}# SESSIONSV3 satellite: US-only node hosting the v3 session tables (events replica,@@ -91,8 +91,8 @@ role "sessionsv3" {# query_log_archive path. Env-specific — prod-eu carries an extra historical_migration# column. Dump-baselined (no local batch-exports node).role "batch_exports" {- env "prod-us" { layers = ["roles/shared", "roles/batch_exports/prod-us"] }- env "prod-eu" { layers = ["roles/shared", "roles/batch_exports/prod-eu"] }+ env "prod-us" { layers = ["roles/shared", "roles/coshared/batch_exports_data", "roles/batch_exports/prod-us"] }+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/batch_exports_data", "roles/batch_exports/prod-eu"] }}# DATA cluster: the main sharded cluster (events family, persons/groups, sessions,@@ -102,7 +102,7 @@ role "batch_exports" {# columns per env that are added out-of-band and churn constantly, so their goldens# live in PostHog/posthog-cloud-infra (clickhouse/hcl/), not the OSS gate.role "data" {- env "local-multi" { layers = ["roles/shared", "roles/data/local"] }+ env "local-multi" { layers = ["roles/shared", "roles/coshared/aux_data", "roles/coshared/sessions_data", "roles/coshared/ai_events_data", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/data/local"] }}# role "endpoints" {diff --git a/posthog/clickhouse/hcl/migration.md b/posthog/clickhouse/hcl/migration.mdindex 11bdb9f8e120..914eab55518b 100644--- a/posthog/clickhouse/hcl/migration.md+++ b/posthog/clickhouse/hcl/migration.md@@ -93,7 +93,29 @@ Envs:- prod-us- prod-eu-Each table shall be defined once, if there's a difference between envs, it shall be extended (prefered) or overriden, whatever is simple.+Each table shall be **defined** once, if there's a difference between envs, it shall be extended (prefered) or overriden, whatever is simple.++"Defined once" counts _declarations_ — plain ones and same-name redeclarations carrying `extend` alike (an `extend` from an abstract is one definition; a second same-name declaration is a second definition even if it also extends). What does **not** count: `patch_*` blocks, and a redeclaration carrying `override = true` (sanctioned whole-replacement — it still copies content, so it stays the last resort). What the rule forbids is the same table declared in two layers, i.e. copied.++`hclexp locate -duplicates` draws exactly this line (verified against the pin: table+`patch_table` → 0, table+`override=true` → 0, table+plain redeclaration → 1, plain+`extend` redeclaration → 1, `extend`+`extend` → 1), so it is the enforcement mechanism, not a heuristic. Both repos gate on it against a `duplicates-baseline.txt` that may only shrink.++The patch vocabulary covers tables fully, so "express it as a patch" is always available for a table content difference. `patch_table` carries `column` and `index` (both with positional `after`), `modify_column` (full replacement column spec — `type` is required), `engine`, `order_by`, `partition_by`, `ttl` and `settings`; `patch_view` and `patch_dictionary` do the same for views and dictionaries. `settings` merge into the target with the patch winning on collision; everything else replaces. Built on demand in PostHog/chschema — #153 (settings merge), #156 (full vocab + `patch_view`/`patch_dictionary`), #159 (positioned column adds), #161 (positioned index adds). Two gaps remain: projections are not patchable (a table with an env-extra projection needs `override = true`), and materialized views have neither `override = true` nor a patch form — an MV whose query differs per env must stay declared per env, parked in the baseline.++`patch_column` (#165) is the `extend` side of the same idea: a child using `extend` can specialize a single _inherited_ column — type, nullability, default kind, CODEC, TTL, comment — while keeping every unspecified field and the inherited column order. A plain `column` block on a child still means _add_, and still collides with an inherited name. This is what lets one codec-free abstract back both a storage table and its Distributed proxy, with only the storage child declaring CODECs:++```hcl+table "sharded_events" {+ extend = "_event_base"++ patch_column "timestamp" {+ codec = "Delta(8), ZSTD(1)"+ }+}+```++Before that, the choice was to hang the CODECs on the abstract — forcing them onto the proxy too — or to stop sharing and repeat the column list.++In this repo the cross-_role_ duplicates have been factored into `roles/coshared/<member-set>/` layers (one layer per set of stacks that co-host the objects), with env deltas as `patch_*` blocks in the env layers. What keeps the baseline non-empty is exactly the two vocabulary gaps above (per-env materialized views) plus the `mat_`-column-bearing events-family replicas, which resolve when the cloud env overlays move to posthog-cloud-infra rather than by any restructure here.The purpose of the extension is to making the schema changes uniform across all envs: think adding a column or table shall be possible in one place and affect all envs.diff --git a/posthog/clickhouse/hcl/roles/ai_events/local/tables.hcl b/posthog/clickhouse/hcl/roles/ai_events/local/tables.hclindex 1771e4d9d442..b01881da5cfb 100644--- a/posthog/clickhouse/hcl/roles/ai_events/local/tables.hcl+++ b/posthog/clickhouse/hcl/roles/ai_events/local/tables.hcl@@ -1,13 +1,4 @@database "posthog" {- table "ai_events" {- extend = "_ai_events_columns"- engine "distributed" {- cluster_name = "ai_events"- remote_database = "posthog"- remote_table = "sharded_ai_events"- sharding_key = "cityHash64(concat(toString(team_id), '-', trace_id, '-', toString(toDate(timestamp))))"- }- }table "kafka_ai_events_json" {column "uuid" {type = "UUID"diff --git a/posthog/clickhouse/hcl/roles/ai_events/prod/patches.hcl b/posthog/clickhouse/hcl/roles/ai_events/prod/patches.hclnew file mode 100644index 000000000000..da8d31e1b066--- /dev/null+++ b/posthog/clickhouse/hcl/roles/ai_events/prod/patches.hcl@@ -0,0 +1,68 @@+# Cloud storage form of ai_events: the WarpStream envs store events in the+# table itself (the local/data stacks read through a Distributed shim onto+# sharded_ai_events).+database "posthog" {+ patch_table "ai_events" {+ order_by = ["team_id", "trace_id", "timestamp"]+ partition_by = "toYYYYMM(drop_date)"+ ttl = "drop_date"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ index "idx_trace_id" {+ expr = "trace_id"+ type = "bloom_filter(0.001)"+ granularity = 1+ }+ index "idx_session_id" {+ expr = "session_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_parent_id" {+ expr = "parent_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_span_id" {+ expr = "span_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_prompt_name" {+ expr = "prompt_name"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_model" {+ expr = "model"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_experiment_id" {+ expr = "experiment_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_event" {+ expr = "event"+ type = "set(20)"+ granularity = 1+ }+ index "idx_is_error" {+ expr = "is_error"+ type = "set(2)"+ granularity = 1+ }+ index "idx_provider" {+ expr = "provider"+ type = "set(50)"+ granularity = 1+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/ai_events/tables/{shard}/posthog.ai_events"+ replica_name = "{replica}"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/ai_events/prod/tables.hcl b/posthog/clickhouse/hcl/roles/ai_events/prod/tables.hclindex d5d47c3eb4d9..342ab6d0a7b7 100644--- a/posthog/clickhouse/hcl/roles/ai_events/prod/tables.hcl+++ b/posthog/clickhouse/hcl/roles/ai_events/prod/tables.hcl@@ -1,11 +1,4 @@database "posthog" {- table "ai_events" {- extend = "_ai_events_data"- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ai_events/tables/{shard}/posthog.ai_events"- replica_name = "{replica}"- }- }table "kafka_ai_events_json_ws" {column "uuid" {type = "UUID"diff --git a/posthog/clickhouse/hcl/roles/ai_events/shared/tables.hcl b/posthog/clickhouse/hcl/roles/ai_events/shared/tables.hclindex c94e1bc66266..521e5ab7faae 100644--- a/posthog/clickhouse/hcl/roles/ai_events/shared/tables.hcl+++ b/posthog/clickhouse/hcl/roles/ai_events/shared/tables.hcl@@ -1,242 +1,4 @@database "posthog" {- table "person" {- column "id" {- type = "UUID"- }- column "created_at" {- type = "DateTime64(3)"- }- column "team_id" {- type = "Int64"- }- column "properties" {- type = "String"- }- column "is_identified" {- type = "Int8"- }- column "is_deleted" {- type = "Int8"- }- column "version" {- type = "UInt64"- }- column "last_seen_at" {- type = "Nullable(DateTime64(3))"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "person"- }- }- table "person_distinct_id2" {- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "UUID"- }- column "is_deleted" {- type = "Int8"- }- column "version" {- type = "Int64"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "person_distinct_id2"- }- }- table "_ai_events_columns" {- abstract = true- column "uuid" {- type = "UUID"- }- column "event" {- type = "LowCardinality(String)"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "UUID"- }- column "properties" {- type = "String"- }- column "retention_days" {- type = "Int16"- default = "30"- }- column "drop_date" {- type = "Date"- materialized = "toDate(timestamp) + toIntervalDay(retention_days)"- }- column "trace_id" {- type = "String"- }- column "session_id" {- type = "Nullable(String)"- }- column "parent_id" {- type = "Nullable(String)"- }- column "span_id" {- type = "Nullable(String)"- }- column "span_type" {- type = "LowCardinality(Nullable(String))"- }- column "generation_id" {- type = "Nullable(String)"- }- column "experiment_id" {- type = "Nullable(String)"- }- column "span_name" {- type = "Nullable(String)"- }- column "trace_name" {- type = "Nullable(String)"- }- column "prompt_name" {- type = "Nullable(String)"- }- column "model" {- type = "LowCardinality(Nullable(String))"- }- column "provider" {- type = "LowCardinality(Nullable(String))"- }- column "framework" {- type = "LowCardinality(Nullable(String))"- }- column "total_tokens" {- type = "Nullable(Int64)"- }- column "input_tokens" {- type = "Nullable(Int64)"- }- column "output_tokens" {- type = "Nullable(Int64)"- }- column "text_input_tokens" {- type = "Nullable(Int64)"- }- column "text_output_tokens" {- type = "Nullable(Int64)"- }- column "image_input_tokens" {- type = "Nullable(Int64)"- }- column "image_output_tokens" {- type = "Nullable(Int64)"- }- column "audio_input_tokens" {- type = "Nullable(Int64)"- }- column "audio_output_tokens" {- type = "Nullable(Int64)"- }- column "video_input_tokens" {- type = "Nullable(Int64)"- }- column "video_output_tokens" {- type = "Nullable(Int64)"- }- column "reasoning_tokens" {- type = "Nullable(Int64)"- }- column "cache_read_input_tokens" {- type = "Nullable(Int64)"- }- column "cache_creation_input_tokens" {- type = "Nullable(Int64)"- }- column "web_search_count" {- type = "Nullable(Int64)"- }- column "input_cost_usd" {- type = "Nullable(Float64)"- }- column "output_cost_usd" {- type = "Nullable(Float64)"- }- column "total_cost_usd" {- type = "Nullable(Float64)"- }- column "request_cost_usd" {- type = "Nullable(Float64)"- }- column "web_search_cost_usd" {- type = "Nullable(Float64)"- }- column "audio_cost_usd" {- type = "Nullable(Float64)"- }- column "image_cost_usd" {- type = "Nullable(Float64)"- }- column "video_cost_usd" {- type = "Nullable(Float64)"- }- column "latency" {- type = "Nullable(Float64)"- }- column "time_to_first_token" {- type = "Nullable(Float64)"- }- column "is_error" {- type = "UInt8"- }- column "error" {- type = "Nullable(String)"- }- column "error_type" {- type = "LowCardinality(Nullable(String))"- }- column "error_normalized" {- type = "Nullable(String)"- }- column "input" {- type = "Nullable(String)"- }- column "output" {- type = "Nullable(String)"- }- column "output_choices" {- type = "Nullable(String)"- }- column "input_state" {- type = "Nullable(String)"- }- column "output_state" {- type = "Nullable(String)"- }- column "tools" {- type = "Nullable(String)"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- }table "_ai_events_data" {abstract = trueextend = "_ai_events_columns"diff --git a/posthog/clickhouse/hcl/roles/auxiliary/local/tables.hcl b/posthog/clickhouse/hcl/roles/auxiliary/local/tables.hclindex b34f9404d675..32db16547b09 100644--- a/posthog/clickhouse/hcl/roles/auxiliary/local/tables.hcl+++ b/posthog/clickhouse/hcl/roles/auxiliary/local/tables.hcl@@ -1,112 +1,4 @@database "posthog" {- table "hog_invocation_results_data" {- order_by = ["team_id", "function_kind", "function_id", "invocation_id"]- partition_by = "toYYYYMMDD(scheduled_at)"- ttl = "toDate(scheduled_at) + toIntervalDay(30)"- settings = {- index_granularity = "1024"- ttl_only_drop_parts = "1"- }- column "team_id" {- type = "Int64"- }- column "function_kind" {- type = "LowCardinality(String)"- }- column "function_id" {- type = "String"- }- column "invocation_id" {- type = "String"- }- column "parent_run_id" {- type = "String"- }- column "status" {- type = "LowCardinality(String)"- }- column "attempts" {- type = "UInt8"- }- column "is_retry" {- type = "UInt8"- }- column "scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "first_scheduled_at" {- type = "DateTime64(6, 'UTC')"- default = "scheduled_at"- }- column "started_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "finished_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "duration_ms" {- type = "Nullable(UInt32)"- }- column "error_kind" {- type = "LowCardinality(String)"- }- column "error_message" {- type = "String"- }- column "event_uuid" {- type = "String"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "String"- }- column "invocation_globals" {- type = "String"- }- column "version" {- type = "UInt64"- }- column "is_deleted" {- type = "UInt8"- default = "0"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- index "status_idx" {- expr = "status"- type = "set(8)"- granularity = 1- }- index "function_idx" {- expr = "function_id"- type = "bloom_filter(0.01)"- granularity = 1- }- index "event_uuid_idx" {- expr = "event_uuid"- type = "bloom_filter(0.01)"- granularity = 1- }- index "is_retry_idx" {- expr = "is_retry"- type = "set(2)"- granularity = 1- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.hog_invocation_results_data"- replica_name = "{replica}-{shard}"- version_column = "version"- }- }table "kafka_error_tracking_fingerprint_issue_state" {column "team_id" {type = "Int64"@@ -148,78 +40,6 @@ database "posthog" {format = "kafka_format = 'JSONEachRow'"}}- table "kafka_hog_invocation_results" {- column "team_id" {- type = "Int64"- }- column "function_kind" {- type = "LowCardinality(String)"- }- column "function_id" {- type = "String"- }- column "invocation_id" {- type = "String"- }- column "parent_run_id" {- type = "String"- }- column "status" {- type = "LowCardinality(String)"- }- column "attempts" {- type = "UInt8"- }- column "is_retry" {- type = "UInt8"- }- column "scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "first_scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "started_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "finished_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "duration_ms" {- type = "Nullable(UInt32)"- }- column "error_kind" {- type = "LowCardinality(String)"- }- column "error_message" {- type = "String"- }- column "event_uuid" {- type = "String"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "String"- }- column "invocation_globals" {- type = "String"- }- column "version" {- type = "UInt64"- }- column "is_deleted" {- type = "UInt8"- }- engine "kafka" {- broker_list = "warpstream_cyclotron"- topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"- group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"- format = "kafka_format = 'JSONEachRow'"- skip_broken_messages = 100- }- }materialized_view "error_tracking_fingerprint_issue_state_mv" {to_table = "posthog.writable_error_tracking_fingerprint_issue_state"query = file("sql/error_tracking_fingerprint_issue_state_mv.sql")diff --git a/posthog/clickhouse/hcl/roles/auxiliary/prod-eu/tables.hcl b/posthog/clickhouse/hcl/roles/auxiliary/prod-eu/tables.hclindex 33d91f1ebdf6..6f73464783b9 100644--- a/posthog/clickhouse/hcl/roles/auxiliary/prod-eu/tables.hcl+++ b/posthog/clickhouse/hcl/roles/auxiliary/prod-eu/tables.hcl@@ -1,74 +1,2 @@database "posthog" {- table "kafka_hog_invocation_results" {- column "team_id" {- type = "Int64"- }- column "function_kind" {- type = "LowCardinality(String)"- }- column "function_id" {- type = "String"- }- column "invocation_id" {- type = "String"- }- column "parent_run_id" {- type = "String"- }- column "status" {- type = "LowCardinality(String)"- }- column "attempts" {- type = "UInt8"- }- column "is_retry" {- type = "UInt8"- }- column "scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "first_scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "started_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "finished_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "duration_ms" {- type = "Nullable(UInt32)"- }- column "error_kind" {- type = "LowCardinality(String)"- }- column "error_message" {- type = "String"- }- column "event_uuid" {- type = "String"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "String"- }- column "invocation_globals" {- type = "String"- }- column "version" {- type = "UInt64"- }- column "is_deleted" {- type = "UInt8"- }- engine "kafka" {- broker_list = "warpstream_cyclotron"- topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"- group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"- format = "kafka_format = 'JSONEachRow'"- skip_broken_messages = 100- }- }}diff --git a/posthog/clickhouse/hcl/roles/auxiliary/prod-us/patches.hcl b/posthog/clickhouse/hcl/roles/auxiliary/prod-us/patches.hclnew file mode 100644index 000000000000..1a443fb644bb--- /dev/null+++ b/posthog/clickhouse/hcl/roles/auxiliary/prod-us/patches.hcl@@ -0,0 +1,16 @@+# prod-us deltas to shared aux objects.+database "posthog" {+ patch_table "kafka_hog_invocation_results" {+ engine "kafka" {+ broker_list = "warpstream_cyclotron"+ topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"+ group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 1+ max_block_size = 100000+ skip_broken_messages = 100+ poll_timeout_ms = 10000+ thread_per_consumer = true+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/auxiliary/prod-us/tables.hcl b/posthog/clickhouse/hcl/roles/auxiliary/prod-us/tables.hclindex bbd5f5aaebf5..5823d8c1d663 100644--- a/posthog/clickhouse/hcl/roles/auxiliary/prod-us/tables.hcl+++ b/posthog/clickhouse/hcl/roles/auxiliary/prod-us/tables.hcl@@ -1,80 +1,4 @@database "posthog" {- table "kafka_hog_invocation_results" {- column "team_id" {- type = "Int64"- }- column "function_kind" {- type = "LowCardinality(String)"- }- column "function_id" {- type = "String"- }- column "invocation_id" {- type = "String"- }- column "parent_run_id" {- type = "String"- }- column "status" {- type = "LowCardinality(String)"- }- column "attempts" {- type = "UInt8"- }- column "is_retry" {- type = "UInt8"- }- column "scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "first_scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "started_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "finished_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "duration_ms" {- type = "Nullable(UInt32)"- }- column "error_kind" {- type = "LowCardinality(String)"- }- column "error_message" {- type = "String"- }- column "event_uuid" {- type = "String"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "String"- }- column "invocation_globals" {- type = "String"- }- column "version" {- type = "UInt64"- }- column "is_deleted" {- type = "UInt8"- }- engine "kafka" {- broker_list = "warpstream_cyclotron"- topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"- group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"- format = "kafka_format = 'JSONEachRow'"- num_consumers = 1- max_block_size = 100000- skip_broken_messages = 100- poll_timeout_ms = 10000- thread_per_consumer = true- }- }table "ingestion_warnings_main" {column "team_id" {type = "Int64"@@ -108,39 +32,4 @@ database "posthog" {sharding_key = "rand()"}}- table "sharded_ingestion_warnings" {- order_by = ["team_id", "toHour(timestamp)", "type", "source", "timestamp"]- partition_by = "toYear(timestamp)"- settings = {- index_granularity = "8192"- }- column "team_id" {- type = "Int64"- }- column "source" {- type = "LowCardinality(String)"- }- column "type" {- type = "String"- }- column "details" {- type = "String"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/reshard/{shard}/posthog.sharded_ingestion_warnings"- replica_name = "{replica}"- }- }}diff --git a/posthog/clickhouse/hcl/roles/auxiliary/prod/patches.hcl b/posthog/clickhouse/hcl/roles/auxiliary/prod/patches.hclnew file mode 100644index 000000000000..26f415466dbf--- /dev/null+++ b/posthog/clickhouse/hcl/roles/auxiliary/prod/patches.hcl@@ -0,0 +1,8 @@+# Both-prods deltas to shared aux objects.+database "posthog" {+ patch_table "hog_invocation_results_data" {+ settings = {+ storage_policy = "s3_tiered"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/auxiliary/prod/tables.hcl b/posthog/clickhouse/hcl/roles/auxiliary/prod/tables.hclindex 94712c258f90..6f73464783b9 100644--- a/posthog/clickhouse/hcl/roles/auxiliary/prod/tables.hcl+++ b/posthog/clickhouse/hcl/roles/auxiliary/prod/tables.hcl@@ -1,111 +1,2 @@database "posthog" {- table "hog_invocation_results_data" {- order_by = ["team_id", "function_kind", "function_id", "invocation_id"]- partition_by = "toYYYYMMDD(scheduled_at)"- ttl = "toDate(scheduled_at) + toIntervalDay(30)"- settings = {- index_granularity = "1024"- storage_policy = "s3_tiered"- ttl_only_drop_parts = "1"- }- column "team_id" {- type = "Int64"- }- column "function_kind" {- type = "LowCardinality(String)"- }- column "function_id" {- type = "String"- }- column "invocation_id" {- type = "String"- }- column "parent_run_id" {- type = "String"- }- column "status" {- type = "LowCardinality(String)"- }- column "attempts" {- type = "UInt8"- }- column "is_retry" {- type = "UInt8"- }- column "scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "first_scheduled_at" {- type = "DateTime64(6, 'UTC')"- default = "scheduled_at"- }- column "started_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "finished_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "duration_ms" {- type = "Nullable(UInt32)"- }- column "error_kind" {- type = "LowCardinality(String)"- }- column "error_message" {- type = "String"- }- column "event_uuid" {- type = "String"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "String"- }- column "invocation_globals" {- type = "String"- }- column "version" {- type = "UInt64"- }- column "is_deleted" {- type = "UInt8"- default = "0"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- index "status_idx" {- expr = "status"- type = "set(8)"- granularity = 1- }- index "function_idx" {- expr = "function_id"- type = "bloom_filter(0.01)"- granularity = 1- }- index "event_uuid_idx" {- expr = "event_uuid"- type = "bloom_filter(0.01)"- granularity = 1- }- index "is_retry_idx" {- expr = "is_retry"- type = "set(2)"- granularity = 1- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.hog_invocation_results_data"- replica_name = "{replica}-{shard}"- version_column = "version"- }- }}diff --git a/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl b/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hclindex ac9ca5a6e120..622aa982abfd 100644--- a/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl+++ b/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl@@ -1,1034 +1,4 @@database "posthog" {- table "_conversion_goal_attributed_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "person_id" {- type = "UUID"- }- column "conversion_timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "conversion_value" {- type = "Float64"- }- column "touchpoint_timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "touchpoint_weight" {- type = "Float64"- }- column "campaign_name" {- type = "String"- }- column "source_name" {- type = "String"- }- column "medium_name" {- type = "String"- }- column "content_name" {- type = "String"- }- column "term_name" {- type = "String"- }- column "referring_domain_name" {- type = "String"- }- column "gclid_name" {- type = "String"- }- column "fbclid_name" {- type = "String"- }- column "gad_source_name" {- type = "String"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "Date"- default = "today() + toIntervalDay(7)"- }- }- table "_experiment_metric_events_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "entity_id" {- type = "String"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "event_uuid" {- type = "UUID"- }- column "session_id" {- type = "String"- }- column "numeric_value" {- type = "Float64"- default = "0"- }- column "steps" {- type = "Array(UInt8)"- default = "[]"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "Date"- default = "today() + toIntervalDay(7)"- }- }- table "_ingestion_warnings_v2_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "source" {- type = "LowCardinality(String)"- }- column "type" {- type = "LowCardinality(String)"- }- column "details" {- type = "String"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "category" {- type = "LowCardinality(String)"- default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"- }- column "severity" {- type = "LowCardinality(String)"- default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"- }- column "pipeline_step" {- type = "LowCardinality(String)"- default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"- }- column "event_uuid" {- type = "Nullable(UUID)"- default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"- }- column "distinct_id" {- type = "Nullable(String)"- default = "nullIf(JSONExtractString(details, 'distinctId'), '')"- }- column "group_key" {- type = "Nullable(String)"- default = "nullIf(JSONExtractString(details, 'groupKey'), '')"- }- column "person_id" {- type = "Nullable(UUID)"- default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- }- table "_marketing_conversions_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "person_id" {- type = "UUID"- }- column "conversion_timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "conversion_math_value" {- type = "Float64"- }- column "session_id" {- type = "String"- }- column "campaign_name" {- type = "String"- }- column "source_name" {- type = "String"- }- column "medium_name" {- type = "String"- }- column "content_name" {- type = "String"- }- column "term_name" {- type = "String"- }- column "referring_domain_name" {- type = "String"- }- column "gclid_name" {- type = "String"- }- column "fbclid_name" {- type = "String"- }- column "gad_source_name" {- type = "String"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "Date"- default = "today() + toIntervalDay(7)"- }- }- table "_marketing_costs_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "source_id" {- type = "String"- }- column "source_name" {- type = "String"- }- column "grain" {- type = "LowCardinality(String)"- }- column "match_key" {- type = "String"- }- column "campaign_id" {- type = "String"- }- column "campaign_name" {- type = "String"- }- column "ad_group_id" {- type = "String"- }- column "ad_group_name" {- type = "String"- }- column "ad_id" {- type = "String"- }- column "ad_name" {- type = "String"- }- column "cost_date" {- type = "Date"- }- column "cost" {- type = "Float64"- }- column "clicks" {- type = "Float64"- }- column "impressions" {- type = "Float64"- }- column "reported_conversions" {- type = "Float64"- }- column "reported_conversion_value" {- type = "Float64"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "Date"- default = "today() + toIntervalDay(7)"- }- }- table "_marketing_touchpoints_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "person_id" {- type = "UUID"- }- column "touchpoint_timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "campaign_name" {- type = "String"- }- column "source_name" {- type = "String"- }- column "medium_name" {- type = "String"- }- column "content_name" {- type = "String"- }- column "term_name" {- type = "String"- }- column "referring_domain_name" {- type = "String"- }- column "gclid_name" {- type = "String"- }- column "fbclid_name" {- type = "String"- }- column "gad_source_name" {- type = "String"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "Date"- default = "today() + toIntervalDay(7)"- }- }- table "_session_replay_features_columns" {- abstract = true- column "session_id" {- type = "String"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "min_first_timestamp" {- type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"- }- column "max_last_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"- }- column "event_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_position_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_sum_x" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_sum_x_squared" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_sum_y" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_sum_y_squared" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_distance_traveled" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_direction_change_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_velocity_sum" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_velocity_sum_of_squares" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_velocity_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "scroll_event_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "total_scroll_magnitude" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "scroll_direction_reversal_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "rapid_scroll_reversal_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "scroll_to_top_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "click_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "keypress_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_activity_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "rage_click_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "dead_click_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "backspace_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "inter_action_gap_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "inter_action_gap_sum_ms" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "inter_action_gap_sum_of_squares_ms" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "max_idle_gap_ms" {- type = "SimpleAggregateFunction(max, Float64)"- }- column "long_idle_gap_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "quick_back_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "page_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "unique_url_count" {- type = "AggregateFunction(uniqCombined(12), String)"- }- column "login_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "signup_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "checkout_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "cart_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "billing_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "settings_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "account_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "error_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "not_found_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "admin_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "dashboard_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "onboarding_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "cancel_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "refund_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_error_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_error_after_click_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_warn_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "network_request_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "network_failed_request_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "network_4xx_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "network_5xx_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "network_request_duration_sum" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "network_request_duration_sum_of_squares" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "network_request_duration_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mutation_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "viewport_resize_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "touch_event_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "max_scroll_y" {- type = "SimpleAggregateFunction(max, Float64)"- }- column "unique_click_target_count" {- type = "AggregateFunction(uniqCombined(12), Int64)"- }- column "unique_form_field_count" {- type = "AggregateFunction(uniqCombined(12), Int64)"- }- column "text_selection_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "selection_copy_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "is_deleted" {- type = "SimpleAggregateFunction(max, UInt8)"- default = "0"- }- }- table "_web_bot_definition_columns" {- abstract = true- column "id" {- type = "UInt64"- }- column "parent_id" {- type = "UInt64"- }- column "regexp" {- type = "String"- }- column "keys" {- type = "Array(String)"- }- column "values" {- type = "Array(String)"- }- }- table "_web_bounces_dimensional_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "period_bucket" {- type = "DateTime"- }- column "host" {- type = "String"- }- column "device_type" {- type = "String"- }- column "entry_pathname" {- type = "String"- }- column "end_pathname" {- type = "String"- }- column "browser" {- type = "String"- }- column "os" {- type = "String"- }- column "viewport_width" {- type = "Int64"- }- column "viewport_height" {- type = "Int64"- }- column "referring_domain" {- type = "String"- }- column "utm_source" {- type = "String"- }- column "utm_medium" {- type = "String"- }- column "utm_campaign" {- type = "String"- }- column "utm_term" {- type = "String"- }- column "utm_content" {- type = "String"- }- column "country_code" {- type = "String"- }- column "city_name" {- type = "String"- }- column "region_code" {- type = "String"- }- column "region_name" {- type = "String"- }- column "has_gclid" {- type = "Bool"- }- column "has_gad_source_paid_search" {- type = "Bool"- }- column "has_fbclid" {- type = "Bool"- }- column "mat_metadata_backend" {- type = "Nullable(String)"- }- column "mat_metadata_loggedIn" {- type = "Nullable(Bool)"- }- column "persons_uniq_state" {- type = "AggregateFunction(uniq, UUID)"- }- column "sessions_uniq_state" {- type = "AggregateFunction(uniq, String)"- }- column "pageviews_count_state" {- type = "AggregateFunction(sum, Int64)"- }- column "bounces_count_state" {- type = "AggregateFunction(sum, Int64)"- }- column "total_session_duration_state" {- type = "AggregateFunction(sum, Int64)"- }- column "total_session_count_state" {- type = "AggregateFunction(sum, Int64)"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"- }- }- table "_web_goals_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "time_window_start" {- type = "DateTime64(6, 'UTC')"- }- column "action_id" {- type = "Int64"- }- column "count_state" {- type = "AggregateFunction(sum, Int64)"- }- column "unique_persons_state" {- type = "AggregateFunction(uniq, UUID)"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"- }- }- table "_web_stats_dimensional_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "period_bucket" {- type = "DateTime"- }- column "host" {- type = "String"- }- column "device_type" {- type = "String"- }- column "pathname" {- type = "String"- }- column "entry_pathname" {- type = "String"- }- column "end_pathname" {- type = "String"- }- column "browser" {- type = "String"- }- column "os" {- type = "String"- }- column "viewport_width" {- type = "Int64"- }- column "viewport_height" {- type = "Int64"- }- column "referring_domain" {- type = "String"- }- column "utm_source" {- type = "String"- }- column "utm_medium" {- type = "String"- }- column "utm_campaign" {- type = "String"- }- column "utm_term" {- type = "String"- }- column "utm_content" {- type = "String"- }- column "country_code" {- type = "String"- }- column "city_name" {- type = "String"- }- column "region_code" {- type = "String"- }- column "region_name" {- type = "String"- }- column "has_gclid" {- type = "Bool"- }- column "has_gad_source_paid_search" {- type = "Bool"- }- column "has_fbclid" {- type = "Bool"- }- column "mat_metadata_backend" {- type = "Nullable(String)"- }- column "mat_metadata_loggedIn" {- type = "Nullable(Bool)"- }- column "persons_uniq_state" {- type = "AggregateFunction(uniq, UUID)"- }- column "sessions_uniq_state" {- type = "AggregateFunction(uniq, String)"- }- column "pageviews_count_state" {- type = "AggregateFunction(sum, Int64)"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"- }- }- table "_web_stats_frustration_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "time_window_start" {- type = "DateTime64(6, 'UTC')"- }- column "breakdown_value" {- type = "String"- }- column "sum_rage_clicks_state" {- type = "AggregateFunction(sum, Int64)"- }- column "sum_dead_clicks_state" {- type = "AggregateFunction(sum, Int64)"- }- column "sum_errors_state" {- type = "AggregateFunction(sum, Int64)"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"- }- }- table "_web_stats_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "time_window_start" {- type = "DateTime64(6, 'UTC')"- }- column "breakdown_by" {- type = "String"- }- column "breakdown_value" {- type = "String"- }- column "uniq_users_state" {- type = "AggregateFunction(uniq, UUID)"- }- column "sum_pageviews_state" {- type = "AggregateFunction(sum, Int64)"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"- }- }- table "_web_vitals_paths_preaggregated_columns" {- abstract = true- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "time_window_start" {- type = "DateTime64(6, 'UTC')"- }- column "path" {- type = "String"- }- column "inp_quantiles_state" {- type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"- }- column "lcp_quantiles_state" {- type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"- }- column "cls_quantiles_state" {- type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"- }- column "fcp_quantiles_state" {- type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"- }- }- table "conversion_goal_attributed_preaggregated" {- extend = "_conversion_goal_attributed_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_conversion_goal_attributed_preaggregated"- sharding_key = "cityHash64(person_id)"- }- }- table "error_tracking_fingerprint_issue_state" {- column "team_id" {- type = "Int64"- }- column "fingerprint" {- type = "String"- }- column "issue_id" {- type = "UUID"- }- column "issue_name" {- type = "Nullable(String)"- }- column "issue_description" {- type = "Nullable(String)"- }- column "issue_status" {- type = "String"- }- column "assigned_user_id" {- type = "Nullable(Int64)"- }- column "assigned_role_id" {- type = "Nullable(UUID)"- }- column "first_seen" {- type = "DateTime64(3, 'UTC')"- }- column "is_deleted" {- type = "Int8"- }- column "version" {- type = "Int64"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "raw_error_tracking_fingerprint_issue_state"- }- }- table "experiment_metric_events_preaggregated" {- extend = "_experiment_metric_events_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_experiment_metric_events_preaggregated"- sharding_key = "cityHash64(entity_id)"- }- }- table "hog_invocation_results" {- column "team_id" {- type = "Int64"- }- column "function_kind" {- type = "LowCardinality(String)"- }- column "function_id" {- type = "String"- }- column "invocation_id" {- type = "String"- }- column "parent_run_id" {- type = "String"- }- column "status" {- type = "LowCardinality(String)"- }- column "attempts" {- type = "UInt8"- }- column "is_retry" {- type = "UInt8"- }- column "scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "first_scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "started_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "finished_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "duration_ms" {- type = "Nullable(UInt32)"- }- column "error_kind" {- type = "LowCardinality(String)"- }- column "error_message" {- type = "String"- }- column "event_uuid" {- type = "String"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "String"- }- column "invocation_globals" {- type = "String"- }- column "version" {- type = "UInt64"- }- column "is_deleted" {- type = "UInt8"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "hog_invocation_results_data"- }- }table "ingestion_warnings_v2" {order_by = ["team_id", "type", "timestamp"]partition_by = "toYYYYMM(timestamp)"@@ -1042,14 +12,6 @@ database "posthog" {replica_name = "{replica}-{shard}"}}- table "ingestion_warnings_v2_distributed" {- extend = "_ingestion_warnings_v2_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "ingestion_warnings_v2"- }- }table "kafka_ingestion_warnings_v2" {column "team_id" {type = "Int64"@@ -1125,125 +87,34 @@ database "posthog" {engine "kafka" {broker_list = "warpstream_cyclotron"topic_list = "kafka_topic_list = 'clickhouse_message_assets'"- group_name = "kafka_group_name = 'clickhouse_message_assets'"- format = "kafka_format = 'JSONEachRow'"- skip_broken_messages = 100- }- }- table "kafka_property_values" {- column "team_id" {- type = "Int64"- }- column "property_type" {- type = "LowCardinality(String)"- }- column "property_key" {- type = "String"- }- column "property_value" {- type = "String"- }- column "property_count" {- type = "UInt64"- }- engine "kafka" {- broker_list = "warpstream_ingestion"- topic_list = "kafka_topic_list = 'clickhouse_property_values'"- group_name = "kafka_group_name = 'clickhouse_property_values'"- format = "kafka_format = 'JSONEachRow'"- num_consumers = 8- thread_per_consumer = true- }- }- table "marketing_conversions_preaggregated" {- extend = "_marketing_conversions_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_marketing_conversions_preaggregated"- sharding_key = "cityHash64(person_id)"- }- }- table "marketing_costs_preaggregated" {- extend = "_marketing_costs_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_marketing_costs_preaggregated"- sharding_key = "cityHash64(source_name, campaign_id)"- }- }- table "marketing_touchpoints_preaggregated" {- extend = "_marketing_touchpoints_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_marketing_touchpoints_preaggregated"- sharding_key = "cityHash64(person_id)"- }- }- table "message_assets" {- column "team_id" {- type = "Int64"- }- column "function_kind" {- type = "LowCardinality(String)"- }- column "function_id" {- type = "String"- }- column "parent_run_id" {- type = "String"- }- column "invocation_id" {- type = "String"- }- column "action_id" {- type = "String"- }- column "kind" {- type = "LowCardinality(String)"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "String"- }- column "recipient" {- type = "String"- }- column "subject" {- type = "String"- }- column "status" {- type = "LowCardinality(String)"- }- column "sent_at" {- type = "DateTime64(6, 'UTC')"+ group_name = "kafka_group_name = 'clickhouse_message_assets'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100}- column "version" {- type = "UInt64"+ }+ table "kafka_property_values" {+ column "team_id" {+ type = "Int64"}- column "is_deleted" {- type = "UInt8"+ column "property_type" {+ type = "LowCardinality(String)"}- column "html" {+ column "property_key" {type = "String"}- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"+ column "property_value" {+ type = "String"}- column "_partition" {+ column "property_count" {type = "UInt64"}- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "message_assets_data"+ engine "kafka" {+ broker_list = "warpstream_ingestion"+ topic_list = "kafka_topic_list = 'clickhouse_property_values'"+ group_name = "kafka_group_name = 'clickhouse_property_values'"+ format = "kafka_format = 'JSONEachRow'"+ num_consumers = 8+ thread_per_consumer = true}}table "message_assets_data" {@@ -1375,33 +246,6 @@ database "posthog" {replica_name = "{replica}-{shard}"}}- table "property_values_distributed" {- column "team_id" {- type = "Int64"- codec = "DoubleDelta, ZSTD(1)"- }- column "property_type" {- type = "LowCardinality(String)"- }- column "property_key" {- type = "LowCardinality(String)"- }- column "property_value" {- type = "String"- }- column "property_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "last_seen" {- type = "SimpleAggregateFunction(max, DateTime)"- default = "now()"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "property_values"- }- }table "raw_error_tracking_fingerprint_issue_state" {order_by = ["team_id", "fingerprint"]settings = {@@ -1460,15 +304,6 @@ database "posthog" {version_column = "version"}}- table "session_replay_features" {- extend = "_session_replay_features_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_session_replay_features"- sharding_key = "sipHash64(session_id)"- }- }table "sharded_conversion_goal_attributed_preaggregated" {order_by = ["team_id", "job_id", "person_id", "conversion_timestamp", "touchpoint_timestamp"]partition_by = "toYYYYMMDD(expires_at)"@@ -1825,69 +660,6 @@ database "posthog" {version_column = "computed_at"}}- table "web_bot_definition" {- extend = "_web_bot_definition_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_bot_definition"- sharding_key = "sipHash64(id)"- }- }- table "web_bounces_dimensional_preaggregated" {- extend = "_web_bounces_dimensional_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_bounces_dimensional_preaggregated"- sharding_key = "sipHash64(job_id)"- }- }- table "web_goals_preaggregated" {- extend = "_web_goals_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_goals_preaggregated"- sharding_key = "sipHash64(job_id)"- }- }- table "web_stats_dimensional_preaggregated" {- extend = "_web_stats_dimensional_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_stats_dimensional_preaggregated"- sharding_key = "sipHash64(job_id)"- }- }- table "web_stats_frustration_preaggregated" {- extend = "_web_stats_frustration_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_stats_frustration_preaggregated"- sharding_key = "sipHash64(job_id)"- }- }- table "web_stats_preaggregated" {- extend = "_web_stats_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_stats_preaggregated"- sharding_key = "sipHash64(job_id)"- }- }- table "web_vitals_paths_preaggregated" {- extend = "_web_vitals_paths_preaggregated_columns"- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_vitals_paths_preaggregated"- sharding_key = "sipHash64(job_id)"- }- }table "writable_error_tracking_fingerprint_issue_state" {column "team_id" {type = "Int64"@@ -2128,33 +900,186 @@ database "posthog" {type = "DateTime"}}- dictionary "web_bot_definition_dict" {- primary_key = ["regexp"]- lifetime {- min = 3000- max = 3600++ table "hog_invocation_results_data" {+ order_by = ["team_id", "function_kind", "function_id", "invocation_id"]+ partition_by = "toYYYYMMDD(scheduled_at)"+ ttl = "toDate(scheduled_at) + toIntervalDay(30)"+ settings = {+ index_granularity = "1024"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "attempts" {+ type = "UInt8"+ }+ column "is_retry" {+ type = "UInt8"+ }+ column "scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "first_scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ default = "scheduled_at"+ }+ column "started_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "finished_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "duration_ms" {+ type = "Nullable(UInt32)"+ }+ column "error_kind" {+ type = "LowCardinality(String)"+ }+ column "error_message" {+ type = "String"+ }+ column "event_uuid" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "invocation_globals" {+ type = "String"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ default = "0"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ index "status_idx" {+ expr = "status"+ type = "set(8)"+ granularity = 1+ }+ index "function_idx" {+ expr = "function_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "event_uuid_idx" {+ expr = "event_uuid"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "is_retry_idx" {+ expr = "is_retry"+ type = "set(2)"+ granularity = 1+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.hog_invocation_results_data"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ table "kafka_hog_invocation_results" {+ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "attempts" {+ type = "UInt8"+ }+ column "is_retry" {+ type = "UInt8"}- attribute "regexp" {+ column "scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "first_scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "started_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "finished_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "duration_ms" {+ type = "Nullable(UInt32)"+ }+ column "error_kind" {+ type = "LowCardinality(String)"+ }+ column "error_message" {type = "String"}- attribute "name" {+ column "event_uuid" {type = "String"}- attribute "category" {+ column "distinct_id" {type = "String"}- attribute "traffic_type" {+ column "person_id" {type = "String"}- attribute "operator" {+ column "invocation_globals" {type = "String"}- source "clickhouse" {- user = "default"- db = "posthog"- table = "web_bot_definition"+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"}- layout "regexp_tree" {+ engine "kafka" {+ broker_list = "warpstream_cyclotron"+ topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"+ group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"+ format = "kafka_format = 'JSONEachRow'"+ skip_broken_messages = 100}}}diff --git a/posthog/clickhouse/hcl/roles/batch_exports/prod-eu/patches.hcl b/posthog/clickhouse/hcl/roles/batch_exports/prod-eu/patches.hclnew file mode 100644index 000000000000..be8bd952f318--- /dev/null+++ b/posthog/clickhouse/hcl/roles/batch_exports/prod-eu/patches.hcl@@ -0,0 +1,10 @@+# prod-eu deltas to coshared base objects.+database "posthog" {+ patch_table "sharded_events_recent" {+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/batch_exports/{shard}/posthog.sharded_events_recent"+ replica_name = "{replica}"+ version_column = "_timestamp"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/batch_exports/prod-eu/tables.hcl b/posthog/clickhouse/hcl/roles/batch_exports/prod-eu/tables.hclindex c7e5e1060354..6f73464783b9 100644--- a/posthog/clickhouse/hcl/roles/batch_exports/prod-eu/tables.hcl+++ b/posthog/clickhouse/hcl/roles/batch_exports/prod-eu/tables.hcl@@ -1,102 +1,2 @@database "posthog" {- table "sharded_events_recent" {- order_by = ["team_id", "toStartOfHour(inserted_at)", "event", "cityHash64(distinct_id)", "cityHash64(uuid)"]- partition_by = "toStartOfDay(inserted_at)"- ttl = "toDateTime(inserted_at) + toIntervalDay(7)"- settings = {- index_granularity = "8192"- ttl_only_drop_parts = "1"- }- column "uuid" {- type = "UUID"- }- column "event" {- type = "String"- }- column "properties" {- type = "String"- codec = "ZSTD(3)"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "elements_chain" {- type = "String"- }- column "created_at" {- type = "DateTime64(6, 'UTC')"- }- column "person_id" {- type = "UUID"- }- column "person_created_at" {- type = "DateTime64(3)"- }- column "person_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group0_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group1_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group2_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group3_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group4_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group0_created_at" {- type = "DateTime64(3)"- }- column "group1_created_at" {- type = "DateTime64(3)"- }- column "group2_created_at" {- type = "DateTime64(3)"- }- column "group3_created_at" {- type = "DateTime64(3)"- }- column "group4_created_at" {- type = "DateTime64(3)"- }- column "person_mode" {- type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"- }- column "historical_migration" {- type = "Bool"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "inserted_at" {- type = "DateTime64(6, 'UTC')"- default = "now64()"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/batch_exports/{shard}/posthog.sharded_events_recent"- replica_name = "{replica}"- version_column = "_timestamp"- }- }}diff --git a/posthog/clickhouse/hcl/roles/batch_exports/prod-us/tables.hcl b/posthog/clickhouse/hcl/roles/batch_exports/prod-us/tables.hclindex d2d92bcbcbcd..e868c71b67d5 100644--- a/posthog/clickhouse/hcl/roles/batch_exports/prod-us/tables.hcl+++ b/posthog/clickhouse/hcl/roles/batch_exports/prod-us/tables.hcl@@ -1,5 +1,6 @@database "posthog" {table "sharded_events_recent" {+ override = trueorder_by = ["team_id", "toStartOfHour(inserted_at)", "event", "cityHash64(distinct_id)", "cityHash64(uuid)"]partition_by = "toStartOfDay(inserted_at)"ttl = "toDateTime(inserted_at) + toIntervalDay(7)"diff --git a/posthog/clickhouse/hcl/roles/coshared/ai_events_data/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/ai_events_data/tables.hclnew file mode 100644index 000000000000..744251b298dc--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/ai_events_data/tables.hcl@@ -0,0 +1,256 @@+# The person / person_distinct_id2 Distributed shims (migration 0240), hosted by+# the ai_events satellite and the local data node. The data node's storage forms+# (kafka meta columns, minmax indexes, ReplacingMergeTree engines) are patch_table+# blocks in roles/data/local.+database "posthog" {+ table "person" {+ column "id" {+ type = "UUID"+ }+ column "created_at" {+ type = "DateTime64(3)"+ }+ column "team_id" {+ type = "Int64"+ }+ column "properties" {+ type = "String"+ }+ column "is_identified" {+ type = "Int8"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ column "last_seen_at" {+ type = "Nullable(DateTime64(3))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "person"+ }+ }++ table "person_distinct_id2" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "person_distinct_id2"+ }+ }++ table "_ai_events_columns" {+ abstract = true+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "LowCardinality(String)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "properties" {+ type = "String"+ }+ column "retention_days" {+ type = "Int16"+ default = "30"+ }+ column "drop_date" {+ type = "Date"+ materialized = "toDate(timestamp) + toIntervalDay(retention_days)"+ }+ column "trace_id" {+ type = "String"+ }+ column "session_id" {+ type = "Nullable(String)"+ }+ column "parent_id" {+ type = "Nullable(String)"+ }+ column "span_id" {+ type = "Nullable(String)"+ }+ column "span_type" {+ type = "LowCardinality(Nullable(String))"+ }+ column "generation_id" {+ type = "Nullable(String)"+ }+ column "experiment_id" {+ type = "Nullable(String)"+ }+ column "span_name" {+ type = "Nullable(String)"+ }+ column "trace_name" {+ type = "Nullable(String)"+ }+ column "prompt_name" {+ type = "Nullable(String)"+ }+ column "model" {+ type = "LowCardinality(Nullable(String))"+ }+ column "provider" {+ type = "LowCardinality(Nullable(String))"+ }+ column "framework" {+ type = "LowCardinality(Nullable(String))"+ }+ column "total_tokens" {+ type = "Nullable(Int64)"+ }+ column "input_tokens" {+ type = "Nullable(Int64)"+ }+ column "output_tokens" {+ type = "Nullable(Int64)"+ }+ column "text_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "text_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "image_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "image_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "audio_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "audio_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "video_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "video_output_tokens" {+ type = "Nullable(Int64)"+ }+ column "reasoning_tokens" {+ type = "Nullable(Int64)"+ }+ column "cache_read_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "cache_creation_input_tokens" {+ type = "Nullable(Int64)"+ }+ column "web_search_count" {+ type = "Nullable(Int64)"+ }+ column "input_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "output_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "total_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "request_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "web_search_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "audio_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "image_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "video_cost_usd" {+ type = "Nullable(Float64)"+ }+ column "latency" {+ type = "Nullable(Float64)"+ }+ column "time_to_first_token" {+ type = "Nullable(Float64)"+ }+ column "is_error" {+ type = "UInt8"+ }+ column "error" {+ type = "Nullable(String)"+ }+ column "error_type" {+ type = "LowCardinality(Nullable(String))"+ }+ column "error_normalized" {+ type = "Nullable(String)"+ }+ column "input" {+ type = "Nullable(String)"+ }+ column "output" {+ type = "Nullable(String)"+ }+ column "output_choices" {+ type = "Nullable(String)"+ }+ column "input_state" {+ type = "Nullable(String)"+ }+ column "output_state" {+ type = "Nullable(String)"+ }+ column "tools" {+ type = "Nullable(String)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }++ table "ai_events" {+ extend = "_ai_events_columns"+ engine "distributed" {+ cluster_name = "ai_events"+ remote_database = "posthog"+ remote_table = "sharded_ai_events"+ sharding_key = "cityHash64(concat(toString(team_id), '-', trace_id, '-', toString(toDate(timestamp))))"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/aux_data/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/aux_data/tables.hclnew file mode 100644index 000000000000..a141415081cf--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/aux_data/tables.hcl@@ -0,0 +1,1262 @@+# Distributed proxies onto the aux cluster (and their column abstracts), co-hosted+# by the aux role (all envs) and the local data node. One declaration; both stacks+# compose this layer. The sharded_* storage tables stay in roles/auxiliary/shared.+database "posthog" {+ table "_conversion_goal_attributed_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "conversion_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "conversion_value" {+ type = "Float64"+ }+ column "touchpoint_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "touchpoint_weight" {+ type = "Float64"+ }+ column "campaign_name" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "medium_name" {+ type = "String"+ }+ column "content_name" {+ type = "String"+ }+ column "term_name" {+ type = "String"+ }+ column "referring_domain_name" {+ type = "String"+ }+ column "gclid_name" {+ type = "String"+ }+ column "fbclid_name" {+ type = "String"+ }+ column "gad_source_name" {+ type = "String"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ }+ table "_experiment_metric_events_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "entity_id" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "event_uuid" {+ type = "UUID"+ }+ column "session_id" {+ type = "String"+ }+ column "numeric_value" {+ type = "Float64"+ default = "0"+ }+ column "steps" {+ type = "Array(UInt8)"+ default = "[]"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ }+ table "_ingestion_warnings_v2_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "category" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"+ }+ column "severity" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"+ }+ column "pipeline_step" {+ type = "LowCardinality(String)"+ default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"+ }+ column "event_uuid" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"+ }+ column "distinct_id" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'distinctId'), '')"+ }+ column "group_key" {+ type = "Nullable(String)"+ default = "nullIf(JSONExtractString(details, 'groupKey'), '')"+ }+ column "person_id" {+ type = "Nullable(UUID)"+ default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ }+ table "_marketing_conversions_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "conversion_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "conversion_math_value" {+ type = "Float64"+ }+ column "session_id" {+ type = "String"+ }+ column "campaign_name" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "medium_name" {+ type = "String"+ }+ column "content_name" {+ type = "String"+ }+ column "term_name" {+ type = "String"+ }+ column "referring_domain_name" {+ type = "String"+ }+ column "gclid_name" {+ type = "String"+ }+ column "fbclid_name" {+ type = "String"+ }+ column "gad_source_name" {+ type = "String"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ }+ table "_marketing_costs_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "source_id" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "grain" {+ type = "LowCardinality(String)"+ }+ column "match_key" {+ type = "String"+ }+ column "campaign_id" {+ type = "String"+ }+ column "campaign_name" {+ type = "String"+ }+ column "ad_group_id" {+ type = "String"+ }+ column "ad_group_name" {+ type = "String"+ }+ column "ad_id" {+ type = "String"+ }+ column "ad_name" {+ type = "String"+ }+ column "cost_date" {+ type = "Date"+ }+ column "cost" {+ type = "Float64"+ }+ column "clicks" {+ type = "Float64"+ }+ column "impressions" {+ type = "Float64"+ }+ column "reported_conversions" {+ type = "Float64"+ }+ column "reported_conversion_value" {+ type = "Float64"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ }+ table "_marketing_touchpoints_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "touchpoint_timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "campaign_name" {+ type = "String"+ }+ column "source_name" {+ type = "String"+ }+ column "medium_name" {+ type = "String"+ }+ column "content_name" {+ type = "String"+ }+ column "term_name" {+ type = "String"+ }+ column "referring_domain_name" {+ type = "String"+ }+ column "gclid_name" {+ type = "String"+ }+ column "fbclid_name" {+ type = "String"+ }+ column "gad_source_name" {+ type = "String"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "Date"+ default = "today() + toIntervalDay(7)"+ }+ }+ table "_session_replay_features_columns" {+ abstract = true+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "min_first_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_last_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_position_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_sum_x" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_x_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_sum_y_squared" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_distance_traveled" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_direction_change_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_velocity_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "mouse_velocity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "total_scroll_magnitude" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "scroll_direction_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rapid_scroll_reversal_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "scroll_to_top_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "rage_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dead_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "backspace_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "inter_action_gap_sum_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "inter_action_gap_sum_of_squares_ms" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "max_idle_gap_ms" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "long_idle_gap_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "quick_back_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "page_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "unique_url_count" {+ type = "AggregateFunction(uniqCombined(12), String)"+ }+ column "login_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "signup_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "checkout_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cart_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "billing_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "settings_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "account_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "error_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "not_found_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "admin_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "dashboard_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "onboarding_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "cancel_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "refund_path_visit_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_error_after_click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_failed_request_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_4xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_5xx_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "network_request_duration_sum" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_sum_of_squares" {+ type = "SimpleAggregateFunction(sum, Float64)"+ }+ column "network_request_duration_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "mutation_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "viewport_resize_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "touch_event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "max_scroll_y" {+ type = "SimpleAggregateFunction(max, Float64)"+ }+ column "unique_click_target_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "unique_form_field_count" {+ type = "AggregateFunction(uniqCombined(12), Int64)"+ }+ column "text_selection_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "selection_copy_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"+ }+ }+ table "_web_bot_definition_columns" {+ abstract = true+ column "id" {+ type = "UInt64"+ }+ column "parent_id" {+ type = "UInt64"+ }+ column "regexp" {+ type = "String"+ }+ column "keys" {+ type = "Array(String)"+ }+ column "values" {+ type = "Array(String)"+ }+ }+ table "_web_bounces_dimensional_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "period_bucket" {+ type = "DateTime"+ }+ column "host" {+ type = "String"+ }+ column "device_type" {+ type = "String"+ }+ column "entry_pathname" {+ type = "String"+ }+ column "end_pathname" {+ type = "String"+ }+ column "browser" {+ type = "String"+ }+ column "os" {+ type = "String"+ }+ column "viewport_width" {+ type = "Int64"+ }+ column "viewport_height" {+ type = "Int64"+ }+ column "referring_domain" {+ type = "String"+ }+ column "utm_source" {+ type = "String"+ }+ column "utm_medium" {+ type = "String"+ }+ column "utm_campaign" {+ type = "String"+ }+ column "utm_term" {+ type = "String"+ }+ column "utm_content" {+ type = "String"+ }+ column "country_code" {+ type = "String"+ }+ column "city_name" {+ type = "String"+ }+ column "region_code" {+ type = "String"+ }+ column "region_name" {+ type = "String"+ }+ column "has_gclid" {+ type = "Bool"+ }+ column "has_gad_source_paid_search" {+ type = "Bool"+ }+ column "has_fbclid" {+ type = "Bool"+ }+ column "mat_metadata_backend" {+ type = "Nullable(String)"+ }+ column "mat_metadata_loggedIn" {+ type = "Nullable(Bool)"+ }+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "bounces_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "total_session_duration_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "total_session_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ }+ table "_web_goals_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "action_id" {+ type = "Int64"+ }+ column "count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "unique_persons_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ }+ table "_web_stats_dimensional_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "period_bucket" {+ type = "DateTime"+ }+ column "host" {+ type = "String"+ }+ column "device_type" {+ type = "String"+ }+ column "pathname" {+ type = "String"+ }+ column "entry_pathname" {+ type = "String"+ }+ column "end_pathname" {+ type = "String"+ }+ column "browser" {+ type = "String"+ }+ column "os" {+ type = "String"+ }+ column "viewport_width" {+ type = "Int64"+ }+ column "viewport_height" {+ type = "Int64"+ }+ column "referring_domain" {+ type = "String"+ }+ column "utm_source" {+ type = "String"+ }+ column "utm_medium" {+ type = "String"+ }+ column "utm_campaign" {+ type = "String"+ }+ column "utm_term" {+ type = "String"+ }+ column "utm_content" {+ type = "String"+ }+ column "country_code" {+ type = "String"+ }+ column "city_name" {+ type = "String"+ }+ column "region_code" {+ type = "String"+ }+ column "region_name" {+ type = "String"+ }+ column "has_gclid" {+ type = "Bool"+ }+ column "has_gad_source_paid_search" {+ type = "Bool"+ }+ column "has_fbclid" {+ type = "Bool"+ }+ column "mat_metadata_backend" {+ type = "Nullable(String)"+ }+ column "mat_metadata_loggedIn" {+ type = "Nullable(Bool)"+ }+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"+ }+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ }+ table "_web_stats_frustration_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "breakdown_value" {+ type = "String"+ }+ column "sum_rage_clicks_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "sum_dead_clicks_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "sum_errors_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ }+ table "_web_stats_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "breakdown_by" {+ type = "String"+ }+ column "breakdown_value" {+ type = "String"+ }+ column "uniq_users_state" {+ type = "AggregateFunction(uniq, UUID)"+ }+ column "sum_pageviews_state" {+ type = "AggregateFunction(sum, Int64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ }+ table "_web_vitals_paths_preaggregated_columns" {+ abstract = true+ column "team_id" {+ type = "Int64"+ }+ column "job_id" {+ type = "UUID"+ }+ column "time_window_start" {+ type = "DateTime64(6, 'UTC')"+ }+ column "path" {+ type = "String"+ }+ column "inp_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "lcp_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "cls_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "fcp_quantiles_state" {+ type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"+ }+ column "computed_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"+ }+ column "expires_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now() + toIntervalDay(7)"+ }+ }+ table "conversion_goal_attributed_preaggregated" {+ extend = "_conversion_goal_attributed_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_conversion_goal_attributed_preaggregated"+ sharding_key = "cityHash64(person_id)"+ }+ }+ table "error_tracking_fingerprint_issue_state" {+ column "team_id" {+ type = "Int64"+ }+ column "fingerprint" {+ type = "String"+ }+ column "issue_id" {+ type = "UUID"+ }+ column "issue_name" {+ type = "Nullable(String)"+ }+ column "issue_description" {+ type = "Nullable(String)"+ }+ column "issue_status" {+ type = "String"+ }+ column "assigned_user_id" {+ type = "Nullable(Int64)"+ }+ column "assigned_role_id" {+ type = "Nullable(UUID)"+ }+ column "first_seen" {+ type = "DateTime64(3, 'UTC')"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "raw_error_tracking_fingerprint_issue_state"+ }+ }+ table "experiment_metric_events_preaggregated" {+ extend = "_experiment_metric_events_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_experiment_metric_events_preaggregated"+ sharding_key = "cityHash64(entity_id)"+ }+ }+ table "hog_invocation_results" {+ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "attempts" {+ type = "UInt8"+ }+ column "is_retry" {+ type = "UInt8"+ }+ column "scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "first_scheduled_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "started_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "finished_at" {+ type = "Nullable(DateTime64(6, 'UTC'))"+ }+ column "duration_ms" {+ type = "Nullable(UInt32)"+ }+ column "error_kind" {+ type = "LowCardinality(String)"+ }+ column "error_message" {+ type = "String"+ }+ column "event_uuid" {+ type = "String"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "invocation_globals" {+ type = "String"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "hog_invocation_results_data"+ }+ }+ table "ingestion_warnings_v2_distributed" {+ extend = "_ingestion_warnings_v2_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "ingestion_warnings_v2"+ }+ }+ table "marketing_conversions_preaggregated" {+ extend = "_marketing_conversions_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_marketing_conversions_preaggregated"+ sharding_key = "cityHash64(person_id)"+ }+ }+ table "marketing_costs_preaggregated" {+ extend = "_marketing_costs_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_marketing_costs_preaggregated"+ sharding_key = "cityHash64(source_name, campaign_id)"+ }+ }+ table "marketing_touchpoints_preaggregated" {+ extend = "_marketing_touchpoints_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_marketing_touchpoints_preaggregated"+ sharding_key = "cityHash64(person_id)"+ }+ }+ table "message_assets" {+ column "team_id" {+ type = "Int64"+ }+ column "function_kind" {+ type = "LowCardinality(String)"+ }+ column "function_id" {+ type = "String"+ }+ column "parent_run_id" {+ type = "String"+ }+ column "invocation_id" {+ type = "String"+ }+ column "action_id" {+ type = "String"+ }+ column "kind" {+ type = "LowCardinality(String)"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "String"+ }+ column "recipient" {+ type = "String"+ }+ column "subject" {+ type = "String"+ }+ column "status" {+ type = "LowCardinality(String)"+ }+ column "sent_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "version" {+ type = "UInt64"+ }+ column "is_deleted" {+ type = "UInt8"+ }+ column "html" {+ type = "String"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "message_assets_data"+ }+ }+ table "property_values_distributed" {+ column "team_id" {+ type = "Int64"+ codec = "DoubleDelta, ZSTD(1)"+ }+ column "property_type" {+ type = "LowCardinality(String)"+ }+ column "property_key" {+ type = "LowCardinality(String)"+ }+ column "property_value" {+ type = "String"+ }+ column "property_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "last_seen" {+ type = "SimpleAggregateFunction(max, DateTime)"+ default = "now()"+ }+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "property_values"+ }+ }+ table "session_replay_features" {+ extend = "_session_replay_features_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_session_replay_features"+ sharding_key = "sipHash64(session_id)"+ }+ }+ table "web_bot_definition" {+ extend = "_web_bot_definition_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_bot_definition"+ sharding_key = "sipHash64(id)"+ }+ }+ table "web_bounces_dimensional_preaggregated" {+ extend = "_web_bounces_dimensional_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_bounces_dimensional_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }+ table "web_goals_preaggregated" {+ extend = "_web_goals_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_goals_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }+ table "web_stats_dimensional_preaggregated" {+ extend = "_web_stats_dimensional_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_stats_dimensional_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }+ table "web_stats_frustration_preaggregated" {+ extend = "_web_stats_frustration_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_stats_frustration_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }+ table "web_stats_preaggregated" {+ extend = "_web_stats_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_stats_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }+ table "web_vitals_paths_preaggregated" {+ extend = "_web_vitals_paths_preaggregated_columns"+ engine "distributed" {+ cluster_name = "aux"+ remote_database = "posthog"+ remote_table = "sharded_web_vitals_paths_preaggregated"+ sharding_key = "sipHash64(job_id)"+ }+ }+ dictionary "web_bot_definition_dict" {+ primary_key = ["regexp"]+ lifetime {+ min = 3000+ max = 3600+ }+ attribute "regexp" {+ type = "String"+ }+ attribute "name" {+ type = "String"+ }+ attribute "category" {+ type = "String"+ }+ attribute "traffic_type" {+ type = "String"+ }+ attribute "operator" {+ type = "String"+ }+ source "clickhouse" {+ user = "default"+ db = "posthog"+ table = "web_bot_definition"+ }+ layout "regexp_tree" {+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/batch_exports_data/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/batch_exports_data/tables.hclnew file mode 100644index 000000000000..dfb594c9f5a8--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/batch_exports_data/tables.hcl@@ -0,0 +1,106 @@+# The sharded_events_recent store (the recent-events table batch export workers+# read), hosted by both prod batch_exports envs and the local data node. Base is+# the local form; prod-eu patches its replication path, prod-us overrides (it+# drops the property codecs, which patches cannot express).+database "posthog" {+ table "sharded_events_recent" {+ order_by = ["team_id", "toStartOfHour(inserted_at)", "event", "cityHash64(distinct_id)", "cityHash64(uuid)"]+ partition_by = "toStartOfDay(inserted_at)"+ ttl = "toDateTime(inserted_at) + toIntervalDay(7)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now64()"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_events_recent"+ replica_name = "{replica}"+ version_column = "_timestamp"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/logs/shared/sql/custom_metrics.sql b/posthog/clickhouse/hcl/roles/coshared/custom_metrics/sql/custom_metrics.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/shared/sql/custom_metrics.sqlrename to posthog/clickhouse/hcl/roles/coshared/custom_metrics/sql/custom_metrics.sqldiff --git a/posthog/clickhouse/hcl/roles/coshared/custom_metrics/views.hcl b/posthog/clickhouse/hcl/roles/coshared/custom_metrics/views.hclnew file mode 100644index 000000000000..4294ded10a1c--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/custom_metrics/views.hcl@@ -0,0 +1,8 @@+# The custom_metrics aggregator view, identical on the roles that host it (ops all+# envs + cloud logs). The invariant custom_metrics_* sub-views it reads live in+# roles/shared/custom_metrics.hcl; the local logs node does not run the aggregator.+database "posthog" {+ view "custom_metrics" {+ query = file("sql/custom_metrics.sql")+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/events_recent/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/events_recent/tables.hclnew file mode 100644index 000000000000..7d09fc35df5a--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/events_recent/tables.hcl@@ -0,0 +1,88 @@+# The events_recent Distributed reader, hosted by prod-us OPS and the local+# data node. Base is the OPS form; the data node's codecs, historical_migration+# column and primary-replica cluster are patches in roles/data/local.+database "posthog" {+ table "events_recent" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "distributed" {+ cluster_name = "batch_exports"+ remote_database = "posthog"+ remote_table = "sharded_events_recent"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/events_recent_write/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/events_recent_write/tables.hclnew file mode 100644index 000000000000..3a9c1b101844--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/events_recent_write/tables.hcl@@ -0,0 +1,94 @@+# The writable_events_recent Distributed writer, identical on prod-us sessions+# and the local data node.+database "posthog" {+ table "writable_events_recent" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "historical_migration" {+ type = "Bool"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_writable"+ remote_database = "posthog"+ remote_table = "sharded_events_recent"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/ingestion_warnings_store/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/ingestion_warnings_store/tables.hclnew file mode 100644index 000000000000..3b12b7d1b4c9--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/ingestion_warnings_store/tables.hcl@@ -0,0 +1,40 @@+# The sharded_ingestion_warnings store, hosted by prod-us AUX and the local+# data node. Base is the AUX form; the local node's partitioning, details codec+# and replication path are patches in roles/data/local.+database "posthog" {+ table "sharded_ingestion_warnings" {+ order_by = ["team_id", "toHour(timestamp)", "type", "source", "timestamp"]+ partition_by = "toYear(timestamp)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int64"+ }+ column "source" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "String"+ }+ column "details" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/reshard/{shard}/posthog.sharded_ingestion_warnings"+ replica_name = "{replica}"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/sessions_data/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/sessions_data/tables.hclnew file mode 100644index 000000000000..3f38f471f2e3--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/sessions_data/tables.hcl@@ -0,0 +1,437 @@+# Objects co-hosted by the sessions satellite (both prods) and the local data+# node. Bases are the minimal forms; the data node's storage attributes are+# patch_table blocks in roles/data/local, and the satellite's own storage copies+# of sessions/raw_sessions are override declarations in roles/sessions/shared+# (they carry sample_by, which patches cannot express).+database "posthog" {+ table "cohortpeople" {+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "sign" {+ type = "Int8"+ }+ column "version" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "cohortpeople"+ sharding_key = "rand()"+ }+ }++ table "person_distinct_id_overrides" {+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "person_id" {+ type = "UUID"+ }+ column "is_deleted" {+ type = "Int8"+ }+ column "version" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_partition" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_distinct_id_overrides"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ table "person_static_cohort" {+ column "id" {+ type = "UUID"+ }+ column "person_id" {+ type = "UUID"+ }+ column "cohort_id" {+ type = "Int64"+ }+ column "team_id" {+ type = "Int64"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "person_static_cohort"+ sharding_key = "rand()"+ }+ }++ table "web_pre_aggregated_teams" {+ column "team_id" {+ type = "UInt64"+ }+ column "enabled_by" {+ type = "String"+ default = "'system'"+ }+ column "version" {+ type = "UInt32"+ default = "toUnixTimestamp(now())"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "web_pre_aggregated_teams"+ }+ }++ dictionary "channel_definition_dict" {+ primary_key = ["domain", "kind"]+ lifetime {+ min = 3000+ max = 3600+ }+ attribute "domain" {+ type = "String"+ }+ attribute "kind" {+ type = "String"+ }+ attribute "domain_type" {+ type = "Nullable(String)"+ }+ attribute "type_if_paid" {+ type = "Nullable(String)"+ }+ attribute "type_if_organic" {+ type = "Nullable(String)"+ }+ source "clickhouse" {+ user = "dict_reader"+ table = "channel_definition"+ }+ layout "complex_key_hashed" {+ }+ }++ dictionary "web_pre_aggregated_teams_dict" {+ primary_key = ["team_id"]+ lifetime {+ min = 3000+ max = 3600+ }+ attribute "team_id" {+ type = "UInt64"+ }+ source "clickhouse" {+ user = "dict_reader"+ query = "SELECT team_id FROM `web_pre_aggregated_teams` FINAL WHERE version > 0"+ }+ layout "hashed" {+ }+ }++ table "sessions" {+ column "session_id" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "SimpleAggregateFunction(any, String)"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "exit_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "event_count_map" {+ type = "SimpleAggregateFunction(sumMap, Map(String, Int64))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_sessions"+ sharding_key = "sipHash64(session_id)"+ }+ }++ table "raw_sessions" {+ column "team_id" {+ type = "Int64"+ }+ column "session_id_v7" {+ type = "UInt128"+ }+ column "distinct_id" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "min_timestamp" {+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "max_inserted_at" {+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"+ }+ column "urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ }+ column "entry_url" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "end_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "last_external_click_url" {+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_browser_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_os_version" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_device_type" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_width" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_viewport_height" {+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_country_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_geoip_time_zone" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_referring_domain" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_campaign" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_medium" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_term" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_utm_content" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gad_source" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gclsrc" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_dclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_gbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_wbraid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_fbclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_msclkid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_twclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_li_fat_id" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_mc_cid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_igshid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_ttclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial__kx" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "initial_irclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ }+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "pageview_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "autocapture_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "screen_count" {+ type = "SimpleAggregateFunction(sum, Int64)"+ }+ column "screen_uniq" {+ type = "AggregateFunction(uniq, Nullable(UUID))"+ }+ column "maybe_has_session_replay" {+ type = "SimpleAggregateFunction(max, Bool)"+ }+ column "page_screen_autocapture_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ }+ column "vitals_lcp" {+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_raw_sessions"+ sharding_key = "cityHash64(session_id_v7)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/coshared/tophog/tables.hcl b/posthog/clickhouse/hcl/roles/coshared/tophog/tables.hclnew file mode 100644index 000000000000..692cdd1e4324--- /dev/null+++ b/posthog/clickhouse/hcl/roles/coshared/tophog/tables.hcl@@ -0,0 +1,47 @@+# The sharded_tophog store, hosted by both prod OPS envs and the local data+# node. The base is the local form; each prod env patches only its replication+# path (prod-us writes to the tophog_new path).+database "posthog" {+ table "sharded_tophog" {+ order_by = ["pipeline", "lane", "metric", "timestamp", "key"]+ partition_by = "toYYYYMMDD(timestamp)"+ ttl = "toDate(timestamp) + toIntervalDay(30)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "metric" {+ type = "LowCardinality(String)"+ }+ column "type" {+ type = "LowCardinality(String)"+ default = "'sum'"+ }+ column "key" {+ type = "Map(LowCardinality(String), String)"+ }+ column "value" {+ type = "Float64"+ }+ column "count" {+ type = "UInt64"+ default = "0"+ }+ column "pipeline" {+ type = "LowCardinality(String)"+ }+ column "lane" {+ type = "LowCardinality(String)"+ }+ column "labels" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.tophog"+ replica_name = "{replica}"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/data/local/patches.hcl b/posthog/clickhouse/hcl/roles/data/local/patches.hclnew file mode 100644index 000000000000..fbfe6664881b--- /dev/null+++ b/posthog/clickhouse/hcl/roles/data/local/patches.hcl@@ -0,0 +1,182 @@+# Local data-node deltas to the coshared sessions/ai_events bases: the storage+# attributes of the tables this node owns (the satellites read them through+# Distributed proxies or keep their own replicas).+database "posthog" {+ patch_table "cohortpeople" {+ order_by = ["team_id", "cohort_id", "person_id", "version"]+ settings = {+ index_granularity = "8192"+ }+ engine "replicated_collapsing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.cohortpeople"+ replica_name = "{replica}-{shard}"+ sign_column = "sign"+ }+ }++ patch_table "person_distinct_id_overrides" {+ order_by = ["team_id", "distinct_id"]+ settings = {+ index_granularity = "512"+ }+ index "kafka_timestamp_minmax_person_distinct_id_overrides" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.person_distinct_id_overrides"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ patch_table "person_static_cohort" {+ order_by = ["team_id", "cohort_id", "person_id", "id"]+ settings = {+ index_granularity = "8192"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.person_static_cohort"+ replica_name = "{replica}-{shard}"+ version_column = "_timestamp"+ }+ }++ patch_table "web_pre_aggregated_teams" {+ order_by = ["team_id"]+ settings = {+ index_granularity = "8192"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.web_analytics_team_selection"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ patch_table "person" {+ order_by = ["team_id", "id"]+ settings = {+ index_granularity = "8192"+ }+ column "_timestamp" {+ type = "DateTime"+ after = "last_seen_at"+ }+ column "_offset" {+ type = "UInt64"+ after = "_timestamp"+ }+ index "kafka_timestamp_minmax_person" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.person"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ patch_table "person_distinct_id2" {+ order_by = ["team_id", "distinct_id"]+ settings = {+ index_granularity = "512"+ }+ column "_timestamp" {+ type = "DateTime"+ after = "version"+ }+ column "_offset" {+ type = "UInt64"+ after = "_timestamp"+ }+ column "_partition" {+ type = "UInt64"+ after = "_offset"+ }+ index "kafka_timestamp_minmax_person_distinct_id2" {+ expr = "_timestamp"+ type = "minmax"+ granularity = 3+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.person_distinct_id2"+ replica_name = "{replica}-{shard}"+ version_column = "version"+ }+ }++ patch_dictionary "channel_definition_dict" {+ source "clickhouse" {+ user = "default"+ table = "channel_definition"+ }+ }++ patch_dictionary "web_pre_aggregated_teams_dict" {+ source "clickhouse" {+ user = "default"+ query = "SELECT team_id FROM `posthog`.`web_pre_aggregated_teams` FINAL WHERE version > 0"+ }+ }++ patch_table "events_recent" {+ modify_column "properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ modify_column "person_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ modify_column "group0_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ modify_column "group1_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ modify_column "group2_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ modify_column "group3_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ modify_column "group4_properties" {+ type = "String"+ codec = "ZSTD(3)"+ }+ column "historical_migration" {+ type = "Bool"+ after = "person_mode"+ }+ modify_column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now64()"+ }+ engine "distributed" {+ cluster_name = "posthog_primary_replica"+ remote_database = "posthog"+ remote_table = "sharded_events_recent"+ sharding_key = "sipHash64(distinct_id)"+ }+ }++ patch_table "sharded_ingestion_warnings" {+ partition_by = "toYYYYMMDD(timestamp)"+ modify_column "details" {+ type = "String"+ codec = "ZSTD(3)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_ingestion_warnings"+ replica_name = "{replica}"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/data/local/tables.hcl b/posthog/clickhouse/hcl/roles/data/local/tables.hclindex c9506b2a909d..3e269544370b 100644--- a/posthog/clickhouse/hcl/roles/data/local/tables.hcl+++ b/posthog/clickhouse/hcl/roles/data/local/tables.hcl@@ -136,196 +136,6 @@ database "posthog" {is_deleted_column = "is_deleted"}}- table "ai_events" {- column "uuid" {- type = "UUID"- }- column "event" {- type = "LowCardinality(String)"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "UUID"- }- column "properties" {- type = "String"- }- column "retention_days" {- type = "Int16"- default = "30"- }- column "drop_date" {- type = "Date"- materialized = "toDate(timestamp) + toIntervalDay(retention_days)"- }- column "trace_id" {- type = "String"- }- column "session_id" {- type = "Nullable(String)"- }- column "parent_id" {- type = "Nullable(String)"- }- column "span_id" {- type = "Nullable(String)"- }- column "span_type" {- type = "LowCardinality(Nullable(String))"- }- column "generation_id" {- type = "Nullable(String)"- }- column "experiment_id" {- type = "Nullable(String)"- }- column "span_name" {- type = "Nullable(String)"- }- column "trace_name" {- type = "Nullable(String)"- }- column "prompt_name" {- type = "Nullable(String)"- }- column "model" {- type = "LowCardinality(Nullable(String))"- }- column "provider" {- type = "LowCardinality(Nullable(String))"- }- column "framework" {- type = "LowCardinality(Nullable(String))"- }- column "total_tokens" {- type = "Nullable(Int64)"- }- column "input_tokens" {- type = "Nullable(Int64)"- }- column "output_tokens" {- type = "Nullable(Int64)"- }- column "text_input_tokens" {- type = "Nullable(Int64)"- }- column "text_output_tokens" {- type = "Nullable(Int64)"- }- column "image_input_tokens" {- type = "Nullable(Int64)"- }- column "image_output_tokens" {- type = "Nullable(Int64)"- }- column "audio_input_tokens" {- type = "Nullable(Int64)"- }- column "audio_output_tokens" {- type = "Nullable(Int64)"- }- column "video_input_tokens" {- type = "Nullable(Int64)"- }- column "video_output_tokens" {- type = "Nullable(Int64)"- }- column "reasoning_tokens" {- type = "Nullable(Int64)"- }- column "cache_read_input_tokens" {- type = "Nullable(Int64)"- }- column "cache_creation_input_tokens" {- type = "Nullable(Int64)"- }- column "web_search_count" {- type = "Nullable(Int64)"- }- column "input_cost_usd" {- type = "Nullable(Float64)"- }- column "output_cost_usd" {- type = "Nullable(Float64)"- }- column "total_cost_usd" {- type = "Nullable(Float64)"- }- column "request_cost_usd" {- type = "Nullable(Float64)"- }- column "web_search_cost_usd" {- type = "Nullable(Float64)"- }- column "audio_cost_usd" {- type = "Nullable(Float64)"- }- column "image_cost_usd" {- type = "Nullable(Float64)"- }- column "video_cost_usd" {- type = "Nullable(Float64)"- }- column "latency" {- type = "Nullable(Float64)"- }- column "time_to_first_token" {- type = "Nullable(Float64)"- }- column "is_error" {- type = "UInt8"- }- column "error" {- type = "Nullable(String)"- }- column "error_type" {- type = "LowCardinality(Nullable(String))"- }- column "error_normalized" {- type = "Nullable(String)"- }- column "input" {- type = "Nullable(String)"- }- column "output" {- type = "Nullable(String)"- }- column "output_choices" {- type = "Nullable(String)"- }- column "input_state" {- type = "Nullable(String)"- }- column "output_state" {- type = "Nullable(String)"- }- column "tools" {- type = "Nullable(String)"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "ai_events"- remote_database = "posthog"- remote_table = "sharded_ai_events"- sharding_key = "cityHash64(concat(toString(team_id), '-', trace_id, '-', toString(toDate(timestamp))))"- }- }table "app_metrics" {column "team_id" {type = "Int64"@@ -470,96 +280,6 @@ database "posthog" {version_column = "last_updated"}}- table "cohortpeople" {- order_by = ["team_id", "cohort_id", "person_id", "version"]- settings = {- index_granularity = "8192"- }- column "person_id" {- type = "UUID"- }- column "cohort_id" {- type = "Int64"- }- column "team_id" {- type = "Int64"- }- column "sign" {- type = "Int8"- }- column "version" {- type = "UInt64"- }- engine "replicated_collapsing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.cohortpeople"- replica_name = "{replica}-{shard}"- sign_column = "sign"- }- }- table "conversion_goal_attributed_preaggregated" {- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "person_id" {- type = "UUID"- }- column "conversion_timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "conversion_value" {- type = "Float64"- }- column "touchpoint_timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "touchpoint_weight" {- type = "Float64"- }- column "campaign_name" {- type = "String"- }- column "source_name" {- type = "String"- }- column "medium_name" {- type = "String"- }- column "content_name" {- type = "String"- }- column "term_name" {- type = "String"- }- column "referring_domain_name" {- type = "String"- }- column "gclid_name" {- type = "String"- }- column "fbclid_name" {- type = "String"- }- column "gad_source_name" {- type = "String"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "Date"- default = "today() + toIntervalDay(7)"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_conversion_goal_attributed_preaggregated"- sharding_key = "cityHash64(person_id)"- }- }table "distinct_id_usage" {column "team_id" {type = "Int64"@@ -1056,55 +776,6 @@ database "posthog" {replica_name = "{replica}-{shard}"}}- table "error_tracking_fingerprint_issue_state" {- column "team_id" {- type = "Int64"- }- column "fingerprint" {- type = "String"- }- column "issue_id" {- type = "UUID"- }- column "issue_name" {- type = "Nullable(String)"- }- column "issue_description" {- type = "Nullable(String)"- }- column "issue_status" {- type = "String"- }- column "assigned_user_id" {- type = "Nullable(Int64)"- }- column "assigned_role_id" {- type = "Nullable(UUID)"- }- column "first_seen" {- type = "DateTime64(3, 'UTC')"- }- column "is_deleted" {- type = "Int8"- }- column "version" {- type = "Int64"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "raw_error_tracking_fingerprint_issue_state"- }- }table "error_tracking_issue_fingerprint_overrides" {order_by = ["team_id", "fingerprint"]settings = {@@ -2289,144 +1960,50 @@ database "posthog" {version_column = "_timestamp"}}- table "events_recent" {- column "uuid" {- type = "UUID"+ table "exchange_rate" {+ order_by = ["date", "currency"]+ settings = {+ index_granularity = "8192"}- column "event" {+ column "currency" {type = "String"}- column "properties" {- type = "String"- codec = "ZSTD(3)"+ column "date" {+ type = "Date"}- column "timestamp" {- type = "DateTime64(6, 'UTC')"+ column "rate" {+ type = "Decimal(18, 10)"+ }+ column "version" {+ type = "UInt32"+ default = "toUnixTimestamp(now())"+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.exchange_rate"+ replica_name = "{replica}-{shard}"+ version_column = "version"}+ }+ table "experiment_exposures_preaggregated" {column "team_id" {type = "Int64"}- column "distinct_id" {+ column "job_id" {+ type = "UUID"+ }+ column "entity_id" {type = "String"}- column "elements_chain" {+ column "variant" {type = "String"}- column "created_at" {+ column "first_exposure_time" {type = "DateTime64(6, 'UTC')"}- column "person_id" {- type = "UUID"- }- column "person_created_at" {- type = "DateTime64(3)"- }- column "person_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group0_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group1_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group2_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group3_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group4_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group0_created_at" {- type = "DateTime64(3)"- }- column "group1_created_at" {- type = "DateTime64(3)"- }- column "group2_created_at" {- type = "DateTime64(3)"- }- column "group3_created_at" {- type = "DateTime64(3)"- }- column "group4_created_at" {- type = "DateTime64(3)"- }- column "person_mode" {- type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"- }- column "historical_migration" {- type = "Bool"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "inserted_at" {- type = "DateTime64(6, 'UTC')"- default = "now64()"- }- engine "distributed" {- cluster_name = "posthog_primary_replica"- remote_database = "posthog"- remote_table = "sharded_events_recent"- sharding_key = "sipHash64(distinct_id)"- }- }- table "exchange_rate" {- order_by = ["date", "currency"]- settings = {- index_granularity = "8192"- }- column "currency" {- type = "String"- }- column "date" {- type = "Date"- }- column "rate" {- type = "Decimal(18, 10)"- }- column "version" {- type = "UInt32"- default = "toUnixTimestamp(now())"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.exchange_rate"- replica_name = "{replica}-{shard}"- version_column = "version"- }- }- table "experiment_exposures_preaggregated" {- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "entity_id" {- type = "String"- }- column "variant" {- type = "String"- }- column "first_exposure_time" {- type = "DateTime64(6, 'UTC')"- }- column "last_exposure_time" {- type = "DateTime64(6, 'UTC')"- }- column "exposure_event_uuid" {+ column "last_exposure_time" {+ type = "DateTime64(6, 'UTC')"+ }+ column "exposure_event_uuid" {type = "UUID"}column "exposure_session_id" {@@ -2450,48 +2027,6 @@ database "posthog" {sharding_key = "cityHash64(entity_id)"}}- table "experiment_metric_events_preaggregated" {- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "entity_id" {- type = "String"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "event_uuid" {- type = "UUID"- }- column "session_id" {- type = "String"- }- column "numeric_value" {- type = "Float64"- default = "0"- }- column "steps" {- type = "Array(UInt8)"- default = "[]"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "Date"- default = "today() + toIntervalDay(7)"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_experiment_metric_events_preaggregated"- sharding_key = "cityHash64(entity_id)"- }- }table "flag_evaluations" {extend = "_flag_evaluations_columns"engine "distributed" {@@ -2594,85 +2129,6 @@ database "posthog" {sharding_key = "cityHash64(concat(toString(team_id), '-', session_id, '-', toString(toDate(timestamp))))"}}- table "hog_invocation_results" {- column "team_id" {- type = "Int64"- }- column "function_kind" {- type = "LowCardinality(String)"- }- column "function_id" {- type = "String"- }- column "invocation_id" {- type = "String"- }- column "parent_run_id" {- type = "String"- }- column "status" {- type = "LowCardinality(String)"- }- column "attempts" {- type = "UInt8"- }- column "is_retry" {- type = "UInt8"- }- column "scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "first_scheduled_at" {- type = "DateTime64(6, 'UTC')"- }- column "started_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "finished_at" {- type = "Nullable(DateTime64(6, 'UTC'))"- }- column "duration_ms" {- type = "Nullable(UInt32)"- }- column "error_kind" {- type = "LowCardinality(String)"- }- column "error_message" {- type = "String"- }- column "event_uuid" {- type = "String"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "String"- }- column "invocation_globals" {- type = "String"- }- column "version" {- type = "UInt64"- }- column "is_deleted" {- type = "UInt8"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "hog_invocation_results_data"- }- }table "ingestion_warnings" {column "team_id" {type = "Int64"@@ -2706,65 +2162,6 @@ database "posthog" {sharding_key = "rand()"}}- table "ingestion_warnings_v2_distributed" {- column "team_id" {- type = "Int64"- }- column "source" {- type = "LowCardinality(String)"- }- column "type" {- type = "LowCardinality(String)"- }- column "details" {- type = "String"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "category" {- type = "LowCardinality(String)"- default = "coalesce(nullIf(JSONExtractString(details, 'category'), ''), 'unknown')"- }- column "severity" {- type = "LowCardinality(String)"- default = "coalesce(nullIf(JSONExtractString(details, 'severity'), ''), 'warning')"- }- column "pipeline_step" {- type = "LowCardinality(String)"- default = "coalesce(nullIf(JSONExtractString(details, 'pipelineStep'), ''), 'unknown')"- }- column "event_uuid" {- type = "Nullable(UUID)"- default = "toUUIDOrNull(JSONExtractString(details, 'eventUuid'))"- }- column "distinct_id" {- type = "Nullable(String)"- default = "nullIf(JSONExtractString(details, 'distinctId'), '')"- }- column "group_key" {- type = "Nullable(String)"- default = "nullIf(JSONExtractString(details, 'groupKey'), '')"- }- column "person_id" {- type = "Nullable(UUID)"- default = "toUUIDOrNull(JSONExtractString(details, 'personId'))"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "ingestion_warnings_v2"- }- }table "kafka_events_json" {column "uuid" {type = "UUID"@@ -3136,256 +2533,6 @@ database "posthog" {sharding_key = "rand()"}}- table "marketing_conversions_preaggregated" {- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "person_id" {- type = "UUID"- }- column "conversion_timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "conversion_math_value" {- type = "Float64"- }- column "session_id" {- type = "String"- }- column "campaign_name" {- type = "String"- }- column "source_name" {- type = "String"- }- column "medium_name" {- type = "String"- }- column "content_name" {- type = "String"- }- column "term_name" {- type = "String"- }- column "referring_domain_name" {- type = "String"- }- column "gclid_name" {- type = "String"- }- column "fbclid_name" {- type = "String"- }- column "gad_source_name" {- type = "String"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "Date"- default = "today() + toIntervalDay(7)"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_marketing_conversions_preaggregated"- sharding_key = "cityHash64(person_id)"- }- }- table "marketing_costs_preaggregated" {- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "source_id" {- type = "String"- }- column "source_name" {- type = "String"- }- column "grain" {- type = "LowCardinality(String)"- }- column "match_key" {- type = "String"- }- column "campaign_id" {- type = "String"- }- column "campaign_name" {- type = "String"- }- column "ad_group_id" {- type = "String"- }- column "ad_group_name" {- type = "String"- }- column "ad_id" {- type = "String"- }- column "ad_name" {- type = "String"- }- column "cost_date" {- type = "Date"- }- column "cost" {- type = "Float64"- }- column "clicks" {- type = "Float64"- }- column "impressions" {- type = "Float64"- }- column "reported_conversions" {- type = "Float64"- }- column "reported_conversion_value" {- type = "Float64"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "Date"- default = "today() + toIntervalDay(7)"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_marketing_costs_preaggregated"- sharding_key = "cityHash64(source_name, campaign_id)"- }- }- table "marketing_touchpoints_preaggregated" {- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "person_id" {- type = "UUID"- }- column "touchpoint_timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "campaign_name" {- type = "String"- }- column "source_name" {- type = "String"- }- column "medium_name" {- type = "String"- }- column "content_name" {- type = "String"- }- column "term_name" {- type = "String"- }- column "referring_domain_name" {- type = "String"- }- column "gclid_name" {- type = "String"- }- column "fbclid_name" {- type = "String"- }- column "gad_source_name" {- type = "String"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "Date"- default = "today() + toIntervalDay(7)"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_marketing_touchpoints_preaggregated"- sharding_key = "cityHash64(person_id)"- }- }- table "message_assets" {- column "team_id" {- type = "Int64"- }- column "function_kind" {- type = "LowCardinality(String)"- }- column "function_id" {- type = "String"- }- column "parent_run_id" {- type = "String"- }- column "invocation_id" {- type = "String"- }- column "action_id" {- type = "String"- }- column "kind" {- type = "LowCardinality(String)"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "String"- }- column "recipient" {- type = "String"- }- column "subject" {- type = "String"- }- column "status" {- type = "LowCardinality(String)"- }- column "sent_at" {- type = "DateTime64(6, 'UTC')"- }- column "version" {- type = "UInt64"- }- column "is_deleted" {- type = "UInt8"- }- column "html" {- type = "String"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "message_assets_data"- }- }table "partitioned_sharded_posthog_document_embeddings" {order_by = ["team_id", "toDate(timestamp)", "product", "document_type", "model_name", "rendering", "cityHash64(document_id)"]partition_by = "toMonday(timestamp)"@@ -3607,52 +2754,6 @@ database "posthog" {sharding_key = "sipHash64(session_id)"}}- table "person" {- order_by = ["team_id", "id"]- settings = {- index_granularity = "8192"- }- column "id" {- type = "UUID"- }- column "created_at" {- type = "DateTime64(3)"- }- column "team_id" {- type = "Int64"- }- column "properties" {- type = "String"- }- column "is_identified" {- type = "Int8"- }- column "is_deleted" {- type = "Int8"- }- column "version" {- type = "UInt64"- }- column "last_seen_at" {- type = "Nullable(DateTime64(3))"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- index "kafka_timestamp_minmax_person" {- expr = "_timestamp"- type = "minmax"- granularity = 3- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.person"- replica_name = "{replica}-{shard}"- version_column = "version"- }- }table "person_distinct_id" {order_by = ["team_id", "distinct_id", "person_id"]settings = {@@ -3688,110 +2789,30 @@ database "posthog" {sign_column = "_sign"}}- table "person_distinct_id2" {- order_by = ["team_id", "distinct_id"]+ table "person_overrides" {+ order_by = ["team_id", "old_person_id"]+ partition_by = "toYYYYMM(oldest_event)"settings = {- index_granularity = "512"+ index_granularity = "8192"}column "team_id" {- type = "Int64"+ type = "Int32"}- column "distinct_id" {- type = "String"+ column "old_person_id" {+ type = "UUID"}- column "person_id" {+ column "override_person_id" {type = "UUID"}- column "is_deleted" {- type = "Int8"+ column "merged_at" {+ type = "DateTime64(6, 'UTC')"}- column "version" {- type = "Int64"+ column "oldest_event" {+ type = "DateTime64(6, 'UTC')"}- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- index "kafka_timestamp_minmax_person_distinct_id2" {- expr = "_timestamp"- type = "minmax"- granularity = 3- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.person_distinct_id2"- replica_name = "{replica}-{shard}"- version_column = "version"- }- }- table "person_distinct_id_overrides" {- order_by = ["team_id", "distinct_id"]- settings = {- index_granularity = "512"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "UUID"- }- column "is_deleted" {- type = "Int8"- }- column "version" {- type = "Int64"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- index "kafka_timestamp_minmax_person_distinct_id_overrides" {- expr = "_timestamp"- type = "minmax"- granularity = 3- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.person_distinct_id_overrides"- replica_name = "{replica}-{shard}"- version_column = "version"- }- }- table "person_overrides" {- order_by = ["team_id", "old_person_id"]- partition_by = "toYYYYMM(oldest_event)"- settings = {- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "old_person_id" {- type = "UUID"- }- column "override_person_id" {- type = "UUID"- }- column "merged_at" {- type = "DateTime64(6, 'UTC')"- }- column "oldest_event" {- type = "DateTime64(6, 'UTC')"- }- column "created_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ default = "now()"}column "version" {type = "Int32"@@ -3802,35 +2823,6 @@ database "posthog" {version_column = "version"}}- table "person_static_cohort" {- order_by = ["team_id", "cohort_id", "person_id", "id"]- settings = {- index_granularity = "8192"- }- column "id" {- type = "UUID"- }- column "person_id" {- type = "UUID"- }- column "cohort_id" {- type = "Int64"- }- column "team_id" {- type = "Int64"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.person_static_cohort"- replica_name = "{replica}-{shard}"- version_column = "_timestamp"- }- }table "pg_embeddings" {order_by = ["team_id", "domain", "id"]settings = {@@ -4052,33 +3044,6 @@ database "posthog" {version_column = "version"}}- table "property_values_distributed" {- column "team_id" {- type = "Int64"- codec = "DoubleDelta, ZSTD(1)"- }- column "property_type" {- type = "LowCardinality(String)"- }- column "property_key" {- type = "LowCardinality(String)"- }- column "property_value" {- type = "String"- }- column "property_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "last_seen" {- type = "SimpleAggregateFunction(max, DateTime)"- default = "now()"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "property_values"- }- }table "query_log_archive_v2" {order_by = ["team_id", "event_date", "event_time", "query_id"]partition_by = "toYYYYMM(event_date)"@@ -4367,16 +3332,23 @@ database "posthog" {replica_name = "{replica}-{shard}"}}- table "raw_sessions" {+ table "raw_sessions_v3" {column "team_id" {type = "Int64"}column "session_id_v7" {type = "UInt128"}+ column "session_timestamp" {+ type = "DateTime64(3)"+ materialized = "fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80)))"+ }column "distinct_id" {type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"}+ column "distinct_ids" {+ type = "AggregateFunction(groupUniqArray, String)"+ }column "min_timestamp" {type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"}@@ -4387,286 +3359,106 @@ database "posthog" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}column "urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"+ type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"}column "entry_url" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}column "end_url" {- type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"}column "last_external_click_url" {- type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_browser" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "browser" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_browser_version" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "browser_version" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_os" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "os" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_os_version" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "os_version" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_device_type" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "device_type" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_viewport_width" {- type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ column "viewport_width" {+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"}- column "initial_viewport_height" {- type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"+ column "viewport_height" {+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"}- column "initial_geoip_country_code" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "geoip_country_code" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_geoip_subdivision_1_code" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "geoip_subdivision_1_code" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_geoip_subdivision_1_name" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "geoip_subdivision_1_name" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_geoip_subdivision_city_name" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "geoip_subdivision_city_name" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_geoip_time_zone" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "geoip_time_zone" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_referring_domain" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_referring_domain" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_utm_source" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_utm_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_utm_campaign" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_utm_campaign" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_utm_medium" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_utm_medium" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_utm_term" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_utm_term" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_utm_content" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_utm_content" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_gclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_gclid" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_gad_source" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_gad_source" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_gclsrc" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_fbclid" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_dclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_has_gclid" {+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"}- column "initial_gbraid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_has_fbclid" {+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"}- column "initial_wbraid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_ad_ids_map" {+ type = "AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC'))"}- column "initial_fbclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_ad_ids_set" {+ type = "AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC'))"}- column "initial_msclkid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "entry_channel_type_properties" {+ type = "AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC'))"}- column "initial_twclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "pageview_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"}- column "initial_li_fat_id" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "autocapture_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"}- column "initial_mc_cid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "screen_uniq" {+ type = "AggregateFunction(uniqExact, Nullable(UUID))"}- column "initial_igshid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_ttclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_epik" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_qclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_sccid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial__kx" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_irclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "pageview_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "pageview_uniq" {- type = "AggregateFunction(uniq, Nullable(UUID))"- }- column "autocapture_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "autocapture_uniq" {- type = "AggregateFunction(uniq, Nullable(UUID))"- }- column "screen_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "screen_uniq" {- type = "AggregateFunction(uniq, Nullable(UUID))"- }- column "maybe_has_session_replay" {- type = "SimpleAggregateFunction(max, Bool)"- }- column "page_screen_autocapture_uniq_up_to" {- type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"- }- column "vitals_lcp" {- type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_raw_sessions"- sharding_key = "cityHash64(session_id_v7)"- }- }- table "raw_sessions_v3" {- column "team_id" {- type = "Int64"- }- column "session_id_v7" {- type = "UInt128"- }- column "session_timestamp" {- type = "DateTime64(3)"- materialized = "fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80)))"- }- column "distinct_id" {- type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"- }- column "distinct_ids" {- type = "AggregateFunction(groupUniqArray, String)"- }- column "min_timestamp" {- type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"- }- column "max_inserted_at" {- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"- }- column "urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"- }- column "entry_url" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "end_url" {- type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"- }- column "last_external_click_url" {- type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"- }- column "browser" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "browser_version" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "os" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "os_version" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "device_type" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "viewport_width" {- type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"- }- column "viewport_height" {- type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"- }- column "geoip_country_code" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "geoip_subdivision_1_code" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "geoip_subdivision_1_name" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "geoip_subdivision_city_name" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "geoip_time_zone" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "entry_referring_domain" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "entry_utm_source" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "entry_utm_campaign" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "entry_utm_medium" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "entry_utm_term" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "entry_utm_content" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "entry_gclid" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "entry_gad_source" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "entry_fbclid" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "entry_has_gclid" {- type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"- }- column "entry_has_fbclid" {- type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"- }- column "entry_ad_ids_map" {- type = "AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC'))"- }- column "entry_ad_ids_set" {- type = "AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC'))"- }- column "entry_channel_type_properties" {- type = "AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC'))"- }- column "pageview_uniq" {- type = "AggregateFunction(uniqExact, Nullable(UUID))"- }- column "autocapture_uniq" {- type = "AggregateFunction(uniqExact, Nullable(UUID))"- }- column "screen_uniq" {- type = "AggregateFunction(uniqExact, Nullable(UUID))"- }- column "page_screen_uniq_up_to" {- type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"+ column "page_screen_uniq_up_to" {+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"}column "has_autocapture" {type = "SimpleAggregateFunction(max, Bool)"@@ -4689,351 +3481,41 @@ database "posthog" {column "has_replay_events" {type = "SimpleAggregateFunction(max, Bool)"}- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_raw_sessions_v3"- sharding_key = "cityHash64(session_id_v7)"- }- }- table "session_replay_embeddings" {- column "session_id" {- type = "String"- }- column "team_id" {- type = "Int64"- }- column "embeddings" {- type = "Array(Float32)"- }- column "generation_timestamp" {- type = "DateTime64(6, 'UTC')"- default = "now('UTC')"- }- column "source_type" {- type = "LowCardinality(String)"- }- column "input" {- type = "String"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_session_replay_embeddings"- sharding_key = "sipHash64(session_id)"- }- }- table "session_replay_events" {- column "session_id" {- type = "String"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "min_first_timestamp" {- type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"- }- column "max_last_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"- }- column "block_first_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_last_timestamps" {- type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"- }- column "block_urls" {- type = "SimpleAggregateFunction(groupArrayArray, Array(String))"- }- column "first_url" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "all_urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }- column "click_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "keypress_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_activity_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "active_milliseconds" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_log_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_warn_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_error_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "size" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "message_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "event_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "snapshot_source" {- type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"- }- column "snapshot_library" {- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"- }- column "_timestamp" {- type = "SimpleAggregateFunction(max, DateTime)"- }- column "is_deleted" {- type = "SimpleAggregateFunction(max, UInt8)"- default = "0"- }- column "ai_tags_fixed" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }- column "ai_tags_freeform" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }- column "ai_highlighted" {- type = "SimpleAggregateFunction(max, UInt8)"- default = "0"- }- column "surfacing_score" {- type = "SimpleAggregateFunction(max, Nullable(Float32))"- }- column "retention_period_days" {- type = "SimpleAggregateFunction(max, Nullable(Int64))"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_session_replay_events"- sharding_key = "sipHash64(distinct_id)"- }- }- table "session_replay_features" {- column "session_id" {- type = "String"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "min_first_timestamp" {- type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"- }- column "max_last_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"- }- column "event_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_position_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_sum_x" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_sum_x_squared" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_sum_y" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_sum_y_squared" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_distance_traveled" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_direction_change_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_velocity_sum" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_velocity_sum_of_squares" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "mouse_velocity_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "scroll_event_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "total_scroll_magnitude" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "scroll_direction_reversal_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "rapid_scroll_reversal_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "scroll_to_top_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "click_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "keypress_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mouse_activity_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "rage_click_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "dead_click_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "backspace_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "inter_action_gap_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "inter_action_gap_sum_ms" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "inter_action_gap_sum_of_squares_ms" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "max_idle_gap_ms" {- type = "SimpleAggregateFunction(max, Float64)"- }- column "long_idle_gap_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "quick_back_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "page_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "unique_url_count" {- type = "AggregateFunction(uniqCombined(12), String)"- }- column "login_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "signup_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "checkout_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "cart_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "billing_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "settings_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "account_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "error_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "not_found_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "admin_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "dashboard_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "onboarding_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "cancel_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "refund_path_visit_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_error_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_error_after_click_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "console_warn_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "network_request_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "network_failed_request_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "network_4xx_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "network_5xx_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "network_request_duration_sum" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "network_request_duration_sum_of_squares" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "network_request_duration_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "mutation_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "viewport_resize_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "touch_event_count" {- type = "SimpleAggregateFunction(sum, Int64)"+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_raw_sessions_v3"+ sharding_key = "cityHash64(session_id_v7)"}- column "max_scroll_y" {- type = "SimpleAggregateFunction(max, Float64)"+ }+ table "session_replay_embeddings" {+ column "session_id" {+ type = "String"}- column "unique_click_target_count" {- type = "AggregateFunction(uniqCombined(12), Int64)"+ column "team_id" {+ type = "Int64"}- column "unique_form_field_count" {- type = "AggregateFunction(uniqCombined(12), Int64)"+ column "embeddings" {+ type = "Array(Float32)"}- column "text_selection_count" {- type = "SimpleAggregateFunction(sum, Int64)"+ column "generation_timestamp" {+ type = "DateTime64(6, 'UTC')"+ default = "now('UTC')"}- column "selection_copy_count" {- type = "SimpleAggregateFunction(sum, Int64)"+ column "source_type" {+ type = "LowCardinality(String)"}- column "is_deleted" {- type = "SimpleAggregateFunction(max, UInt8)"- default = "0"+ column "input" {+ type = "String"}engine "distributed" {- cluster_name = "aux"+ cluster_name = "posthog"remote_database = "posthog"- remote_table = "sharded_session_replay_features"+ remote_table = "sharded_session_replay_embeddings"sharding_key = "sipHash64(session_id)"}}- table "sessions" {+ table "session_replay_events" {column "session_id" {type = "String"}@@ -5041,103 +3523,93 @@ database "posthog" {type = "Int64"}column "distinct_id" {- type = "SimpleAggregateFunction(any, String)"+ type = "String"}- column "min_timestamp" {+ column "min_first_timestamp" {type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"}- column "max_timestamp" {+ column "max_last_timestamp" {type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"}- column "urls" {- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"- }- column "entry_url" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "exit_url" {- type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"- }- column "initial_referring_domain" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_utm_source" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "block_first_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"}- column "initial_utm_campaign" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "block_last_timestamps" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(DateTime64(6, 'UTC')))"}- column "initial_utm_medium" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "block_urls" {+ type = "SimpleAggregateFunction(groupArrayArray, Array(String))"}- column "initial_utm_term" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "first_url" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_utm_content" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "all_urls" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"}- column "initial_gclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "click_count" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "initial_gad_source" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "keypress_count" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "initial_gclsrc" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "mouse_activity_count" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "initial_dclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "active_milliseconds" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "initial_gbraid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "console_log_count" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "initial_wbraid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "console_warn_count" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "initial_fbclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "console_error_count" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "initial_msclkid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "size" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "initial_twclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "message_count" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "initial_li_fat_id" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "event_count" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "initial_mc_cid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "snapshot_source" {+ type = "AggregateFunction(argMin, LowCardinality(Nullable(String)), DateTime64(6, 'UTC'))"}- column "initial_igshid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "snapshot_library" {+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"}- column "initial_ttclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime)"}- column "initial_epik" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "is_deleted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"}- column "initial_qclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "ai_tags_fixed" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"}- column "initial_sccid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"+ column "ai_tags_freeform" {+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"}- column "event_count_map" {- type = "SimpleAggregateFunction(sumMap, Map(String, Int64))"+ column "ai_highlighted" {+ type = "SimpleAggregateFunction(max, UInt8)"+ default = "0"}- column "pageview_count" {- type = "SimpleAggregateFunction(sum, Int64)"+ column "surfacing_score" {+ type = "SimpleAggregateFunction(max, Nullable(Float32))"}- column "autocapture_count" {- type = "SimpleAggregateFunction(sum, Int64)"+ column "retention_period_days" {+ type = "SimpleAggregateFunction(max, Nullable(Int64))"}engine "distributed" {cluster_name = "posthog"remote_database = "posthog"- remote_table = "sharded_sessions"- sharding_key = "sipHash64(session_id)"+ remote_table = "sharded_session_replay_events"+ sharding_key = "sipHash64(distinct_id)"}}table "sharded_app_metrics" {@@ -5625,128 +4097,28 @@ database "posthog" {type = "minmax"granularity = 1}- index "bloom_filter_$ai_prompt_name" {- expr = "`mat_$ai_prompt_name`"- type = "bloom_filter"- granularity = 1- }- index "minmax_$ai_prompt_name" {- expr = "`mat_$ai_prompt_name`"- type = "minmax"- granularity = 1- }- index "bloom_filter_$ai_experiment_id" {- expr = "`mat_$ai_experiment_id`"- type = "bloom_filter"- granularity = 1- }- index "minmax_$ai_experiment_id" {- expr = "`mat_$ai_experiment_id`"- type = "minmax"- granularity = 1- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/{shard}/posthog.events"- replica_name = "{replica}"- version_column = "_timestamp"- }- }- table "sharded_events_recent" {- order_by = ["team_id", "toStartOfHour(inserted_at)", "event", "cityHash64(distinct_id)", "cityHash64(uuid)"]- partition_by = "toStartOfDay(inserted_at)"- ttl = "toDateTime(inserted_at) + toIntervalDay(7)"- settings = {- index_granularity = "8192"- ttl_only_drop_parts = "1"- }- column "uuid" {- type = "UUID"- }- column "event" {- type = "String"- }- column "properties" {- type = "String"- codec = "ZSTD(3)"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "elements_chain" {- type = "String"- }- column "created_at" {- type = "DateTime64(6, 'UTC')"- }- column "person_id" {- type = "UUID"- }- column "person_created_at" {- type = "DateTime64(3)"- }- column "person_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group0_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group1_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group2_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group3_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group4_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group0_created_at" {- type = "DateTime64(3)"- }- column "group1_created_at" {- type = "DateTime64(3)"- }- column "group2_created_at" {- type = "DateTime64(3)"- }- column "group3_created_at" {- type = "DateTime64(3)"- }- column "group4_created_at" {- type = "DateTime64(3)"- }- column "person_mode" {- type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"- }- column "historical_migration" {- type = "Bool"- }- column "_timestamp" {- type = "DateTime"+ index "bloom_filter_$ai_prompt_name" {+ expr = "`mat_$ai_prompt_name`"+ type = "bloom_filter"+ granularity = 1}- column "_offset" {- type = "UInt64"+ index "minmax_$ai_prompt_name" {+ expr = "`mat_$ai_prompt_name`"+ type = "minmax"+ granularity = 1}- column "inserted_at" {- type = "DateTime64(6, 'UTC')"- default = "now64()"+ index "bloom_filter_$ai_experiment_id" {+ expr = "`mat_$ai_experiment_id`"+ type = "bloom_filter"+ granularity = 1+ }+ index "minmax_$ai_experiment_id" {+ expr = "`mat_$ai_experiment_id`"+ type = "minmax"+ granularity = 1}engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_events_recent"+ zoo_path = "/clickhouse/tables/{shard}/posthog.events"replica_name = "{replica}"version_column = "_timestamp"}@@ -5891,42 +4263,6 @@ database "posthog" {replica_name = "{replica}"}}- table "sharded_ingestion_warnings" {- order_by = ["team_id", "toHour(timestamp)", "type", "source", "timestamp"]- partition_by = "toYYYYMMDD(timestamp)"- settings = {- index_granularity = "8192"- }- column "team_id" {- type = "Int64"- }- column "source" {- type = "LowCardinality(String)"- }- column "type" {- type = "String"- }- column "details" {- type = "String"- codec = "ZSTD(3)"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/{shard}/posthog.sharded_ingestion_warnings"- replica_name = "{replica}"- }- }table "sharded_log_entries" {order_by = ["team_id", "log_source", "log_source_id", "instance_id", "timestamp"]partition_by = "toYYYYMMDD(timestamp)"@@ -7305,306 +5641,95 @@ database "posthog" {type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"}column "initial_ttclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_epik" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_qclid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "initial_sccid" {- type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"- }- column "event_count_map" {- type = "SimpleAggregateFunction(sumMap, Map(String, Int64))"- }- column "pageview_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- column "autocapture_count" {- type = "SimpleAggregateFunction(sum, Int64)"- }- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/{shard}/posthog.sessions"- replica_name = "{replica}"- }- }- table "sharded_tophog" {- order_by = ["pipeline", "lane", "metric", "timestamp", "key"]- partition_by = "toYYYYMMDD(timestamp)"- ttl = "toDate(timestamp) + toIntervalDay(30)"- settings = {- index_granularity = "8192"- ttl_only_drop_parts = "1"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "metric" {- type = "LowCardinality(String)"- }- column "type" {- type = "LowCardinality(String)"- default = "'sum'"- }- column "key" {- type = "Map(LowCardinality(String), String)"- }- column "value" {- type = "Float64"- }- column "count" {- type = "UInt64"- default = "0"- }- column "pipeline" {- type = "LowCardinality(String)"- }- column "lane" {- type = "LowCardinality(String)"- }- column "labels" {- type = "Map(LowCardinality(String), String)"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/{shard}/posthog.tophog"- replica_name = "{replica}"- }- }- table "tophog" {- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "metric" {- type = "LowCardinality(String)"- }- column "type" {- type = "LowCardinality(String)"- default = "'sum'"- }- column "key" {- type = "Map(LowCardinality(String), String)"- }- column "value" {- type = "Float64"- }- column "count" {- type = "UInt64"- default = "0"- }- column "pipeline" {- type = "LowCardinality(String)"- }- column "lane" {- type = "LowCardinality(String)"- }- column "labels" {- type = "Map(LowCardinality(String), String)"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_tophog"- sharding_key = "cityHash64(toString(key))"- }- }- table "usage_report_events_preagg" {- column "date" {- type = "Date"- }- column "team_id" {- type = "Int64"- }- column "person_mode" {- type = "LowCardinality(String)"- }- column "lib" {- type = "LowCardinality(String)"- }- column "event" {- type = "String"- }- column "distinct_events_unique" {- type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"- }- column "event_count" {- type = "AggregateFunction(sum, UInt64)"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_usage_report_events_preagg"- sharding_key = "sipHash64(date)"- }- }- table "web_bot_definition" {- column "id" {- type = "UInt64"- }- column "parent_id" {- type = "UInt64"- }- column "regexp" {- type = "String"- }- column "keys" {- type = "Array(String)"- }- column "values" {- type = "Array(String)"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_bot_definition"- sharding_key = "sipHash64(id)"- }- }- table "web_bounces_dimensional_preaggregated" {- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "period_bucket" {- type = "DateTime"- }- column "host" {- type = "String"- }- column "device_type" {- type = "String"- }- column "entry_pathname" {- type = "String"- }- column "end_pathname" {- type = "String"- }- column "browser" {- type = "String"- }- column "os" {- type = "String"- }- column "viewport_width" {- type = "Int64"- }- column "viewport_height" {- type = "Int64"- }- column "referring_domain" {- type = "String"- }- column "utm_source" {- type = "String"- }- column "utm_medium" {- type = "String"- }- column "utm_campaign" {- type = "String"- }- column "utm_term" {- type = "String"- }- column "utm_content" {- type = "String"- }- column "country_code" {- type = "String"+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"}- column "city_name" {- type = "String"+ column "initial_epik" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"}- column "region_code" {- type = "String"+ column "initial_qclid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"}- column "region_name" {- type = "String"+ column "initial_sccid" {+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"}- column "has_gclid" {- type = "Bool"+ column "event_count_map" {+ type = "SimpleAggregateFunction(sumMap, Map(String, Int64))"}- column "has_gad_source_paid_search" {- type = "Bool"+ column "pageview_count" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "has_fbclid" {- type = "Bool"+ column "autocapture_count" {+ type = "SimpleAggregateFunction(sum, Int64)"}- column "mat_metadata_backend" {- type = "Nullable(String)"+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/{shard}/posthog.sessions"+ replica_name = "{replica}"}- column "mat_metadata_loggedIn" {- type = "Nullable(Bool)"+ }+ table "tophog" {+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"}- column "persons_uniq_state" {- type = "AggregateFunction(uniq, UUID)"+ column "metric" {+ type = "LowCardinality(String)"}- column "sessions_uniq_state" {- type = "AggregateFunction(uniq, String)"+ column "type" {+ type = "LowCardinality(String)"+ default = "'sum'"}- column "pageviews_count_state" {- type = "AggregateFunction(sum, Int64)"+ column "key" {+ type = "Map(LowCardinality(String), String)"}- column "bounces_count_state" {- type = "AggregateFunction(sum, Int64)"+ column "value" {+ type = "Float64"}- column "total_session_duration_state" {- type = "AggregateFunction(sum, Int64)"+ column "count" {+ type = "UInt64"+ default = "0"}- column "total_session_count_state" {- type = "AggregateFunction(sum, Int64)"+ column "pipeline" {+ type = "LowCardinality(String)"}- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"+ column "lane" {+ type = "LowCardinality(String)"}- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"+ column "labels" {+ type = "Map(LowCardinality(String), String)"}engine "distributed" {- cluster_name = "aux"+ cluster_name = "posthog"remote_database = "posthog"- remote_table = "sharded_web_bounces_dimensional_preaggregated"- sharding_key = "sipHash64(job_id)"+ remote_table = "sharded_tophog"+ sharding_key = "cityHash64(toString(key))"}}- table "web_goals_preaggregated" {+ table "usage_report_events_preagg" {+ column "date" {+ type = "Date"+ }column "team_id" {type = "Int64"}- column "job_id" {- type = "UUID"- }- column "time_window_start" {- type = "DateTime64(6, 'UTC')"- }- column "action_id" {- type = "Int64"+ column "person_mode" {+ type = "LowCardinality(String)"}- column "count_state" {- type = "AggregateFunction(sum, Int64)"+ column "lib" {+ type = "LowCardinality(String)"}- column "unique_persons_state" {- type = "AggregateFunction(uniq, UUID)"+ column "event" {+ type = "String"}- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"+ column "distinct_events_unique" {+ type = "AggregateFunction(uniqExact, Tuple(UInt64, UInt64, UInt64))"}- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"+ column "event_count" {+ type = "AggregateFunction(sum, UInt64)"}engine "distributed" {cluster_name = "aux"remote_database = "posthog"- remote_table = "sharded_web_goals_preaggregated"- sharding_key = "sipHash64(job_id)"+ remote_table = "sharded_usage_report_events_preagg"+ sharding_key = "sipHash64(date)"}}table "web_overview_preaggregated" {@@ -8013,207 +6138,42 @@ database "posthog" {column "country_code" {type = "String"}- column "city_name" {- type = "String"- }- column "region_code" {- type = "String"- }- column "region_name" {- type = "String"- }- column "has_gclid" {- type = "Bool"- }- column "has_gad_source_paid_search" {- type = "Bool"- }- column "has_fbclid" {- type = "Bool"- }- column "mat_metadata_loggedIn" {- type = "Bool"- }- column "mat_metadata_backend" {- type = "String"- }- column "persons_uniq_state" {- type = "AggregateFunction(uniq, UUID)"- }- column "sessions_uniq_state" {- type = "AggregateFunction(uniq, String)"- }- column "pageviews_count_state" {- type = "AggregateFunction(sum, UInt64)"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.web_pre_aggregated_stats_staging"- replica_name = "{replica}-{shard}"- }- }- table "web_pre_aggregated_teams" {- order_by = ["team_id"]- settings = {- index_granularity = "8192"- }- column "team_id" {- type = "UInt64"- }- column "enabled_by" {- type = "String"- default = "'system'"- }- column "version" {- type = "UInt32"- default = "toUnixTimestamp(now())"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.web_analytics_team_selection"- replica_name = "{replica}-{shard}"- version_column = "version"- }- }- table "web_stats_dimensional_preaggregated" {- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "period_bucket" {- type = "DateTime"- }- column "host" {- type = "String"- }- column "device_type" {- type = "String"- }- column "pathname" {- type = "String"- }- column "entry_pathname" {- type = "String"- }- column "end_pathname" {- type = "String"- }- column "browser" {- type = "String"- }- column "os" {- type = "String"- }- column "viewport_width" {- type = "Int64"- }- column "viewport_height" {- type = "Int64"- }- column "referring_domain" {- type = "String"- }- column "utm_source" {- type = "String"- }- column "utm_medium" {- type = "String"- }- column "utm_campaign" {- type = "String"- }- column "utm_term" {- type = "String"- }- column "utm_content" {- type = "String"- }- column "country_code" {- type = "String"- }- column "city_name" {- type = "String"- }- column "region_code" {- type = "String"- }- column "region_name" {- type = "String"- }- column "has_gclid" {- type = "Bool"- }- column "has_gad_source_paid_search" {- type = "Bool"- }- column "has_fbclid" {- type = "Bool"- }- column "mat_metadata_backend" {- type = "Nullable(String)"- }- column "mat_metadata_loggedIn" {- type = "Nullable(Bool)"- }- column "persons_uniq_state" {- type = "AggregateFunction(uniq, UUID)"- }- column "sessions_uniq_state" {- type = "AggregateFunction(uniq, String)"- }- column "pageviews_count_state" {- type = "AggregateFunction(sum, Int64)"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"+ column "city_name" {+ type = "String"}- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_stats_dimensional_preaggregated"- sharding_key = "sipHash64(job_id)"+ column "region_code" {+ type = "String"}- }- table "web_stats_frustration_preaggregated" {- column "team_id" {- type = "Int64"+ column "region_name" {+ type = "String"}- column "job_id" {- type = "UUID"+ column "has_gclid" {+ type = "Bool"}- column "time_window_start" {- type = "DateTime64(6, 'UTC')"+ column "has_gad_source_paid_search" {+ type = "Bool"}- column "breakdown_value" {- type = "String"+ column "has_fbclid" {+ type = "Bool"}- column "sum_rage_clicks_state" {- type = "AggregateFunction(sum, Int64)"+ column "mat_metadata_loggedIn" {+ type = "Bool"}- column "sum_dead_clicks_state" {- type = "AggregateFunction(sum, Int64)"+ column "mat_metadata_backend" {+ type = "String"}- column "sum_errors_state" {- type = "AggregateFunction(sum, Int64)"+ column "persons_uniq_state" {+ type = "AggregateFunction(uniq, UUID)"}- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"+ column "sessions_uniq_state" {+ type = "AggregateFunction(uniq, String)"}- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"+ column "pageviews_count_state" {+ type = "AggregateFunction(sum, UInt64)"}- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_stats_frustration_preaggregated"- sharding_key = "sipHash64(job_id)"+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.web_pre_aggregated_stats_staging"+ replica_name = "{replica}-{shard}"}}table "web_stats_paths_preaggregated" {@@ -8290,83 +6250,6 @@ database "posthog" {sharding_key = "sipHash64(breakdown_value)"}}- table "web_stats_preaggregated" {- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "time_window_start" {- type = "DateTime64(6, 'UTC')"- }- column "breakdown_by" {- type = "String"- }- column "breakdown_value" {- type = "String"- }- column "uniq_users_state" {- type = "AggregateFunction(uniq, UUID)"- }- column "sum_pageviews_state" {- type = "AggregateFunction(sum, Int64)"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_stats_preaggregated"- sharding_key = "sipHash64(job_id)"- }- }- table "web_vitals_paths_preaggregated" {- column "team_id" {- type = "Int64"- }- column "job_id" {- type = "UUID"- }- column "time_window_start" {- type = "DateTime64(6, 'UTC')"- }- column "path" {- type = "String"- }- column "inp_quantiles_state" {- type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"- }- column "lcp_quantiles_state" {- type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"- }- column "cls_quantiles_state" {- type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"- }- column "fcp_quantiles_state" {- type = "AggregateFunction(quantiles(0.75, 0.9, 0.99), Float64)"- }- column "computed_at" {- type = "DateTime64(6, 'UTC')"- default = "now()"- }- column "expires_at" {- type = "DateTime64(6, 'UTC')"- default = "now() + toIntervalDay(7)"- }- engine "distributed" {- cluster_name = "aux"- remote_database = "posthog"- remote_table = "sharded_web_vitals_paths_preaggregated"- sharding_key = "sipHash64(job_id)"- }- }table "writable_events" {column "uuid" {type = "UUID"@@ -8490,96 +6373,6 @@ database "posthog" {sharding_key = "sipHash64(distinct_id)"}}- table "writable_events_recent" {- column "uuid" {- type = "UUID"- }- column "event" {- type = "String"- }- column "properties" {- type = "String"- codec = "ZSTD(3)"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "elements_chain" {- type = "String"- }- column "created_at" {- type = "DateTime64(6, 'UTC')"- }- column "person_id" {- type = "UUID"- }- column "person_created_at" {- type = "DateTime64(3)"- }- column "person_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group0_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group1_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group2_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group3_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group4_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group0_created_at" {- type = "DateTime64(3)"- }- column "group1_created_at" {- type = "DateTime64(3)"- }- column "group2_created_at" {- type = "DateTime64(3)"- }- column "group3_created_at" {- type = "DateTime64(3)"- }- column "group4_created_at" {- type = "DateTime64(3)"- }- column "person_mode" {- type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"- }- column "historical_migration" {- type = "Bool"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog_writable"- remote_database = "posthog"- remote_table = "sharded_events_recent"- sharding_key = "sipHash64(distinct_id)"- }- }table "writable_log_entries" {column "team_id" {type = "UInt64"@@ -10582,34 +8375,6 @@ GROUP BYSQL}- dictionary "channel_definition_dict" {- primary_key = ["domain", "kind"]- lifetime {- min = 3000- max = 3600- }- attribute "domain" {- type = "String"- }- attribute "kind" {- type = "String"- }- attribute "domain_type" {- type = "Nullable(String)"- }- attribute "type_if_paid" {- type = "Nullable(String)"- }- attribute "type_if_organic" {- type = "Nullable(String)"- }- source "clickhouse" {- user = "default"- table = "channel_definition"- }- layout "complex_key_hashed" {- }- }dictionary "exchange_rate_dict" {primary_key = ["currency"]lifetime {@@ -10685,49 +8450,4 @@ SQLpreallocate = 1}}- dictionary "web_bot_definition_dict" {- primary_key = ["regexp"]- lifetime {- min = 3000- max = 3600- }- attribute "regexp" {- type = "String"- }- attribute "name" {- type = "String"- }- attribute "category" {- type = "String"- }- attribute "traffic_type" {- type = "String"- }- attribute "operator" {- type = "String"- }- source "clickhouse" {- user = "default"- db = "posthog"- table = "web_bot_definition"- }- layout "regexp_tree" {- }- }- dictionary "web_pre_aggregated_teams_dict" {- primary_key = ["team_id"]- lifetime {- min = 3000- max = 3600- }- attribute "team_id" {- type = "UInt64"- }- source "clickhouse" {- user = "default"- query = "SELECT team_id FROM `posthog`.`web_pre_aggregated_teams` FINAL WHERE version > 0"- }- layout "hashed" {- }- }}diff --git a/posthog/clickhouse/hcl/roles/logs/shared/sql/kafka_logs_avro_kafka_metrics_mv.sql b/posthog/clickhouse/hcl/roles/logs/base/sql/kafka_logs_avro_kafka_metrics_mv.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/shared/sql/kafka_logs_avro_kafka_metrics_mv.sqlrename to posthog/clickhouse/hcl/roles/logs/base/sql/kafka_logs_avro_kafka_metrics_mv.sqldiff --git a/posthog/clickhouse/hcl/roles/logs/shared/sql/logs34_to_log_attributes.sql b/posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_log_attributes.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/shared/sql/logs34_to_log_attributes.sqlrename to posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_log_attributes.sqldiff --git a/posthog/clickhouse/hcl/roles/logs/shared/sql/logs34_to_log_attributes3.sql b/posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_log_attributes3.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/shared/sql/logs34_to_log_attributes3.sqlrename to posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_log_attributes3.sqldiff --git a/posthog/clickhouse/hcl/roles/logs/shared/sql/logs34_to_resource_attributes.sql b/posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_resource_attributes.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/shared/sql/logs34_to_resource_attributes.sqlrename to posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_resource_attributes.sqldiff --git a/posthog/clickhouse/hcl/roles/logs/shared/sql/logs34_to_resource_attributes3.sql b/posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_resource_attributes3.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/shared/sql/logs34_to_resource_attributes3.sqlrename to posthog/clickhouse/hcl/roles/logs/base/sql/logs34_to_resource_attributes3.sqldiff --git a/posthog/clickhouse/hcl/roles/logs/base/tables.hcl b/posthog/clickhouse/hcl/roles/logs/base/tables.hclnew file mode 100644index 000000000000..92c706d82822--- /dev/null+++ b/posthog/clickhouse/hcl/roles/logs/base/tables.hcl@@ -0,0 +1,1000 @@+# Objects common to the local logs node and every cloud logs env — the base the+# whole role composes. Env deltas (the logs cluster vs the local single-shard+# cluster, per-shard zk paths, prod settings) are patch_table blocks in the env+# layers, never second definitions.++database "posthog" {++ materialized_view "kafka_logs_avro_kafka_metrics_mv" {+ to_table = "posthog.logs_kafka_metrics"+ query = file("sql/kafka_logs_avro_kafka_metrics_mv.sql")+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "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 "log_attributes3" {+ order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value", "severity_text"]+ partition_by = "toDate(original_expiry_time_bucket)"+ ttl = "original_expiry_time_bucket"+ settings = {+ deduplicate_merge_projection_mode = "drop"+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ codec = "ZSTD(5)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ default = "'log'"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime"+ default = "now()"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ }+ index "idx_attribute_key" {+ expr = "attribute_key"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attribute_value" {+ expr = "attribute_value"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attribute_key_n3" {+ expr = "attribute_key"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ index "idx_attribute_value_n3" {+ expr = "attribute_value"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.log_attributes3"+ replica_name = "{replica}-{shard}"+ }+ }++ 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")++ 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 "severity_text" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ 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")++ 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 "severity_text" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ }++ table "metric_samples1" {+ order_by = ["team_id", "metric_name", "series_fingerprint", "timestamp"]+ partition_by = "toDate(timestamp)"+ ttl = "toDateTime(timestamp) + toIntervalDay(30)"+ settings = {+ index_granularity = "8192"+ ttl_only_drop_parts = "1"+ }+ column "team_id" {+ type = "Int32"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "series_fingerprint" {+ type = "UInt64"+ codec = "DoubleDelta"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ column "value" {+ type = "Float64"+ codec = "Gorilla(8)"+ }+ column "count" {+ type = "UInt64"+ default = "1"+ }+ column "histogram_bounds" {+ type = "Array(Float64)"+ }+ column "histogram_counts" {+ type = "Array(UInt64)"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ index "idx_trace_id_bf" {+ expr = "trace_id"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.metric_samples1"+ replica_name = "{replica}-{shard}"+ }+ }++ table "metric_series1" {+ order_by = ["team_id", "metric_name", "series_fingerprint"]+ ttl = "toDateTime(last_seen) + toIntervalDay(90)"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "series_fingerprint" {+ type = "UInt64"+ codec = "DoubleDelta"+ }+ column "metric_type" {+ type = "LowCardinality(String)"+ }+ column "unit" {+ type = "LowCardinality(String)"+ }+ column "aggregation_temporality" {+ type = "LowCardinality(String)"+ }+ column "is_monotonic" {+ type = "Bool"+ default = "false"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "last_seen" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ index "idx_service_set" {+ expr = "service_name"+ type = "set(1000)"+ granularity = 1+ }+ index "idx_attr_keys" {+ expr = "mapKeys(attributes)"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attr_values" {+ expr = "mapValues(attributes)"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ engine "replicated_replacing_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.metric_series1"+ replica_name = "{replica}-{shard}"+ version_column = "last_seen"+ }+ }++ table "log_attributes2" {+ order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]+ partition_by = "toDate(original_expiry_time_bucket)"+ ttl = "original_expiry_time_bucket"+ settings = {+ deduplicate_merge_projection_mode = "drop"+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ codec = "ZSTD(5)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ default = "'log'"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime"+ default = "now()"+ }+ index "idx_attribute_key" {+ expr = "attribute_key"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attribute_value" {+ expr = "attribute_value"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attribute_key_n3" {+ expr = "attribute_key"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ index "idx_attribute_value_n3" {+ expr = "attribute_value"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 1+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.log_attributes2"+ replica_name = "{replica}-{shard}"+ }+ }++ table "log_attributes_distributed" {+ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ codec = "ZSTD(5)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ default = "'log'"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime"+ default = "now()"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "log_attributes3"+ }+ }++ table "logs_billing_metrics" {+ order_by = ["team_id", "time_bucket", "service_name"]+ partition_by = "toYYYYMM(time_bucket)"+ settings = {+ deduplicate_merge_projection_mode = "rebuild"+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "bytes_uncompressed" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "bytes_compressed" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "record_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.logs_billing_metrics"+ replica_name = "{replica}-{shard}"+ }+ }++ table "logs_billing_metrics_distributed" {+ column "team_id" {+ type = "Int32"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "bytes_uncompressed" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "bytes_compressed" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ column "record_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "logs_billing_metrics"+ }+ }++ table "logs_distributed" {+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfDay(timestamp)"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }+ column "uuid" {+ type = "String"+ }+ column "team_id" {+ type = "Int32"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"+ }+ column "body" {+ type = "String"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ }+ column "severity_number" {+ type = "Int32"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "event_name" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "level" {+ type = "String"+ alias = "severity_text"+ }+ column "mat_body_ipv4_matches" {+ type = "Array(String)"+ alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"+ }+ column "time_minute" {+ type = "DateTime"+ alias = "toStartOfMinute(timestamp)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ }+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ }+ column "_record_count" {+ type = "UInt64"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "logs34"+ }+ }++ table "logs_kafka_metrics" {+ order_by = ["_topic", "_partition"]+ settings = {+ index_granularity = "8192"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "max_offset" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ column "max_observed_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_created_at" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_lag" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.logs_kafka_metrics"+ replica_name = "{replica}-{shard}"+ }+ }++ table "logs_kafka_metrics_distributed" {+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "max_offset" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ column "max_observed_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_created_at" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_lag" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "logs_kafka_metrics"+ }+ }++ table "metric_samples" {+ column "team_id" {+ type = "Int32"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "series_fingerprint" {+ type = "UInt64"+ codec = "DoubleDelta"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ column "value" {+ type = "Float64"+ codec = "Gorilla(8)"+ }+ column "count" {+ type = "UInt64"+ default = "1"+ }+ column "histogram_bounds" {+ type = "Array(Float64)"+ }+ column "histogram_counts" {+ type = "Array(UInt64)"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "metric_samples1"+ }+ }++ table "metric_series" {+ column "team_id" {+ type = "Int32"+ }+ column "metric_name" {+ type = "LowCardinality(String)"+ }+ column "series_fingerprint" {+ type = "UInt64"+ codec = "DoubleDelta"+ }+ column "metric_type" {+ type = "LowCardinality(String)"+ }+ column "unit" {+ type = "LowCardinality(String)"+ }+ column "aggregation_temporality" {+ type = "LowCardinality(String)"+ }+ column "is_monotonic" {+ type = "Bool"+ default = "false"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "last_seen" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "metric_series1"+ }+ }++ table "kafka_logs_avro" {+ column "uuid" {+ type = "String"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "body" {+ type = "String"+ }+ column "severity_text" {+ type = "String"+ }+ column "severity_number" {+ type = "Int32"+ }+ column "service_name" {+ type = "String"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "event_name" {+ type = "String"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ engine "kafka" {+ broker_list = "warpstream_logs"+ topic_list = "kafka_topic_list = 'clickhouse_logs'"+ group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"+ format = "kafka_format = 'Avro'"+ num_consumers = 8+ skip_broken_messages = 100+ poll_timeout_ms = 3000+ poll_max_batch_size = 1000+ thread_per_consumer = true+ }+ }++ table "logs34" {+ order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "severity_text", "timestamp"]+ partition_by = "toDate(original_expiry_timestamp)"+ ttl = "original_expiry_timestamp"+ settings = {+ add_minmax_index_for_numeric_columns = "1"+ allow_experimental_reverse_key = "1"+ index_granularity = "8192"+ index_granularity_bytes = "104857600"+ map_serialization_version = "with_buckets"+ ttl_only_drop_parts = "1"+ }+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfDay(timestamp)"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }+ column "uuid" {+ type = "String"+ }+ column "team_id" {+ type = "Int32"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "trace_flags" {+ type = "Int32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ codec = "DoubleDelta"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"+ }+ column "body" {+ type = "String"+ }+ column "severity_text" {+ type = "LowCardinality(String)"+ }+ column "severity_number" {+ type = "Int32"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "event_name" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "level" {+ type = "String"+ alias = "severity_text"+ }+ column "mat_body_ipv4_matches" {+ type = "Array(String)"+ alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"+ }+ column "time_minute" {+ type = "DateTime"+ alias = "toStartOfMinute(timestamp)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ }+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ }+ column "_record_count" {+ type = "UInt64"+ }+ index "idx_severity_text_set" {+ expr = "severity_text"+ type = "set(10)"+ granularity = 1+ }+ index "idx_attributes_str_keys" {+ expr = "mapKeys(attributes_map_str)"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_attributes_str_values" {+ expr = "mapValues(attributes_map_str)"+ type = "bloom_filter(0.001)"+ granularity = 1+ }+ index "idx_mat_body_ipv4_matches" {+ expr = "mat_body_ipv4_matches"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_body_ngram3" {+ expr = "lower(body)"+ type = "ngrambf_v1(3, 25000, 2, 0)"+ granularity = 1+ }+ index "idx_uuid_bloom" {+ expr = "uuid"+ type = "bloom_filter(0.01)"+ granularity = 1+ }+ index "idx_observed_minmax" {+ expr = "observed_timestamp"+ type = "minmax"+ granularity = 1+ }+ index "idx_timestamp_minmax" {+ expr = "timestamp"+ type = "minmax"+ granularity = 1+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/logs/{shard}/posthog.logs34"+ replica_name = "{replica}"+ }+ }++}diff --git a/posthog/clickhouse/hcl/roles/logs/dev/tables.hcl b/posthog/clickhouse/hcl/roles/logs/dev/tables.hclindex 6e57ac62447c..d1390b9d4087 100644--- a/posthog/clickhouse/hcl/roles/logs/dev/tables.hcl+++ b/posthog/clickhouse/hcl/roles/logs/dev/tables.hcl@@ -1,5 +1,6 @@# LOGS dev overlay — env-specific / differing logs objects.database "posthog" {+materialized_view "kafka_logs34_avro_mv" {to_table = "posthog.logs34"query = file("sql/kafka_logs34_avro_mv.sql")@@ -70,61 +71,7 @@ database "posthog" {type = "Nullable(Int64)"}}- table "kafka_logs_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "body" {- type = "String"- }- column "severity_text" {- type = "String"- }- column "severity_number" {- type = "Int32"- }- column "service_name" {- type = "String"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "instrumentation_scope" {- type = "String"- }- column "event_name" {- type = "String"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- }- engine "kafka" {- broker_list = "warpstream_logs"- topic_list = "kafka_topic_list = 'clickhouse_logs'"- group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"- format = "kafka_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_logs_avro_billing_metrics_mv" {to_table = "posthog.logs_billing_metrics"query = file("sql/kafka_logs_avro_billing_metrics_mv.sql")@@ -147,379 +94,4 @@ database "posthog" {type = "SimpleAggregateFunction(sum, UInt64)"}}- table "logs34" {- order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "severity_text", "timestamp"]- partition_by = "toDate(original_expiry_timestamp)"- ttl = "original_expiry_timestamp"- settings = {- add_minmax_index_for_numeric_columns = "1"- allow_experimental_reverse_key = "1"- index_granularity = "8192"- index_granularity_bytes = "104857600"- map_serialization_version = "with_buckets"- ttl_only_drop_parts = "1"- }- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "body" {- type = "String"- }- column "severity_text" {- type = "LowCardinality(String)"- }- column "severity_number" {- type = "Int32"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "event_name" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "level" {- type = "String"- alias = "severity_text"- }- column "mat_body_ipv4_matches" {- type = "Array(String)"- alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"- }- column "time_minute" {- type = "DateTime"- alias = "toStartOfMinute(timestamp)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"- }- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "_offset" {- type = "UInt64"- }- column "_bytes_uncompressed" {- type = "UInt64"- }- column "_bytes_compressed" {- type = "UInt64"- }- column "_record_count" {- type = "UInt64"- }- index "idx_severity_text_set" {- expr = "severity_text"- type = "set(10)"- granularity = 1- }- index "idx_attributes_str_keys" {- expr = "mapKeys(attributes_map_str)"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attributes_str_values" {- expr = "mapValues(attributes_map_str)"- type = "bloom_filter(0.001)"- granularity = 1- }- index "idx_mat_body_ipv4_matches" {- expr = "mat_body_ipv4_matches"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_body_ngram3" {- expr = "lower(body)"- type = "ngrambf_v1(3, 25000, 2, 0)"- granularity = 1- }- index "idx_uuid_bloom" {- expr = "uuid"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_observed_minmax" {- expr = "observed_timestamp"- type = "minmax"- granularity = 1- }- index "idx_timestamp_minmax" {- expr = "timestamp"- type = "minmax"- granularity = 1- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.logs34"- replica_name = "{replica}"- }- }- table "metrics" {- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "metric_type" {- type = "LowCardinality(String)"- }- column "value" {- type = "Float64"- }- column "count" {- type = "UInt64"- default = "1"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(UInt64)"- }- column "unit" {- type = "LowCardinality(String)"- }- column "aggregation_temporality" {- type = "LowCardinality(String)"- }- column "is_monotonic" {- type = "Bool"- default = "false"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- }- column "time_minute" {- type = "DateTime"- alias = "toStartOfMinute(timestamp)"- }- column "attributes" {- type = "Map(String, String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "metrics1"- }- }- table "metrics1" {- order_by = ["team_id", "time_bucket", "service_name", "metric_name", "resource_fingerprint", "timestamp"]- partition_by = "toDate(timestamp)"- settings = {- index_granularity = "8192"- index_granularity_bytes = "104857600"- ttl_only_drop_parts = "1"- }- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "metric_type" {- type = "LowCardinality(String)"- }- column "value" {- type = "Float64"- }- column "count" {- type = "UInt64"- default = "1"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(UInt64)"- }- column "unit" {- type = "LowCardinality(String)"- }- column "aggregation_temporality" {- type = "LowCardinality(String)"- }- column "is_monotonic" {- type = "Bool"- default = "false"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- }- column "time_minute" {- type = "DateTime"- alias = "toStartOfMinute(timestamp)"- }- column "attributes" {- type = "Map(String, String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- index "idx_metric_name_set" {- expr = "metric_name"- type = "set(100)"- granularity = 1- }- index "idx_metric_type_set" {- expr = "metric_type"- type = "set(10)"- granularity = 1- }- index "idx_attributes_str_keys" {- expr = "mapKeys(attributes_map_str)"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attributes_str_values" {- expr = "mapValues(attributes_map_str)"- type = "bloom_filter(0.001)"- granularity = 1- }- index "idx_observed_minmax" {- expr = "observed_timestamp"- type = "minmax"- granularity = 1- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.metrics1"- replica_name = "{replica}"- }- }}diff --git a/posthog/clickhouse/hcl/roles/logs/local/patches.hcl b/posthog/clickhouse/hcl/roles/logs/local/patches.hclnew file mode 100644index 000000000000..e8d8fd08d6c4--- /dev/null+++ b/posthog/clickhouse/hcl/roles/logs/local/patches.hcl@@ -0,0 +1,35 @@+# Local-node deltas to the trace-spans suite: the single-shard local cluster in+# place of the logs cluster, and the kafka meta columns on the distributed reader.+database "posthog" {+ patch_table "trace_spans_distributed" {+ column "_partition" {+ type = "UInt32"+ after = "links"+ }+ column "_topic" {+ type = "String"+ after = "_partition"+ }+ column "_offset" {+ type = "UInt64"+ after = "_topic"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ after = "_offset"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ after = "_bytes_uncompressed"+ }+ column "_record_count" {+ type = "UInt64"+ after = "_bytes_compressed"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "trace_spans"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/logs/local/tables.hcl b/posthog/clickhouse/hcl/roles/logs/local/tables.hclindex 7e3fb1f838ae..03329e7bc311 100644--- a/posthog/clickhouse/hcl/roles/logs/local/tables.hcl+++ b/posthog/clickhouse/hcl/roles/logs/local/tables.hcl@@ -1,59 +1,4 @@database "posthog" {- table "kafka_logs_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "body" {- type = "String"- }- column "severity_text" {- type = "String"- }- column "severity_number" {- type = "Int32"- }- column "service_name" {- type = "String"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "instrumentation_scope" {- type = "String"- }- column "event_name" {- type = "String"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- }- engine "kafka" {- broker_list = "warpstream_logs"- topic_list = "kafka_topic_list = 'clickhouse_logs'"- group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"- format = "kafka_format = 'Avro'"- num_consumers = 8- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }table "log_attributes" {order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]partition_by = "toDate(original_expiry_time_bucket)"@@ -122,178 +67,6 @@ database "posthog" {replica_name = "{replica}-{shard}"}}- table "log_attributes2" {- order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]- partition_by = "toDate(original_expiry_time_bucket)"- ttl = "original_expiry_time_bucket"- settings = {- deduplicate_merge_projection_mode = "drop"- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- codec = "ZSTD(5)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "attribute_type" {- type = "LowCardinality(String)"- default = "'log'"- }- column "original_expiry_time_bucket" {- type = "DateTime"- default = "now()"- }- index "idx_attribute_key" {- expr = "attribute_key"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attribute_value" {- expr = "attribute_value"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attribute_key_n3" {- expr = "attribute_key"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 1- }- index "idx_attribute_value_n3" {- expr = "attribute_value"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 1- }- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.log_attributes2"- replica_name = "{replica}-{shard}"- }- }- table "log_attributes3" {- order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value", "severity_text"]- partition_by = "toDate(original_expiry_time_bucket)"- ttl = "original_expiry_time_bucket"- settings = {- deduplicate_merge_projection_mode = "drop"- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- codec = "ZSTD(5)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "attribute_type" {- type = "LowCardinality(String)"- default = "'log'"- }- column "original_expiry_time_bucket" {- type = "DateTime"- default = "now()"- }- column "severity_text" {- type = "LowCardinality(String)"- }- index "idx_attribute_key" {- expr = "attribute_key"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attribute_value" {- expr = "attribute_value"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attribute_key_n3" {- expr = "attribute_key"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 1- }- index "idx_attribute_value_n3" {- expr = "attribute_value"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 1- }- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.log_attributes3"- replica_name = "{replica}-{shard}"- }- }- table "log_attributes_distributed" {- column "team_id" {- type = "Int32"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- codec = "ZSTD(5)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "attribute_type" {- type = "LowCardinality(String)"- default = "'log'"- }- column "original_expiry_time_bucket" {- type = "DateTime"- default = "now()"- }- column "severity_text" {- type = "LowCardinality(String)"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "log_attributes3"- }- }table "logs" {column "time_bucket" {type = "DateTime"@@ -630,6 +403,7 @@ SQL}}table "logs34" {+ override = trueorder_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "severity_text", "timestamp"]partition_by = "toDate(original_expiry_timestamp)"ttl = "original_expiry_timestamp"@@ -804,113 +578,56 @@ SQLreplica_name = "{replica}-{shard}"}}- table "logs_billing_metrics" {- order_by = ["team_id", "time_bucket", "service_name"]- partition_by = "toYYYYMM(time_bucket)"- settings = {- deduplicate_merge_projection_mode = "rebuild"- index_granularity = "8192"+ materialized_view "kafka_logs34_avro_mv" {+ to_table = "posthog.logs34"+ query = <<SQL+SELECT+ kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes, bytes_uncompressed),+ mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,+ mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,+ toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,+ observed_timestamp+ + toIntervalDay(+ toInt32OrDefault(_headers.value[indexOf(_headers.name, 'retention-days')], toInt32(15))+ ) AS original_expiry_timestamp,+ _partition,+ _topic,+ _offset,+ toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,+ toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) / _record_count AS _bytes_uncompressed,+ toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) / _record_count AS _bytes_compressed+FROM posthog.kafka_logs_avro+SQL++ column "uuid" {+ type = "String"}- column "team_id" {- type = "Int32"+ column "trace_id" {+ type = "String"}- column "time_bucket" {- type = "DateTime64(0)"+ column "span_id" {+ type = "String"}- column "service_name" {- type = "LowCardinality(String)"+ column "trace_flags" {+ type = "Int32"}- column "bytes_uncompressed" {- type = "SimpleAggregateFunction(sum, UInt64)"+ column "timestamp" {+ type = "DateTime64(6)"}- column "bytes_compressed" {- type = "SimpleAggregateFunction(sum, UInt64)"+ column "observed_timestamp" {+ type = "DateTime64(6)"}- column "record_count" {- type = "SimpleAggregateFunction(sum, UInt64)"+ column "body" {+ type = "String"}- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.logs_billing_metrics"- replica_name = "{replica}-{shard}"+ column "severity_text" {+ type = "String"}- }- table "logs_billing_metrics_distributed" {- column "team_id" {+ column "severity_number" {type = "Int32"}- column "time_bucket" {- type = "DateTime64(0)"- }column "service_name" {- type = "LowCardinality(String)"- }- column "bytes_uncompressed" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "bytes_compressed" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "record_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "logs_billing_metrics"- }- }- table "logs_distributed" {- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "body" {- type = "String"- }- column "severity_text" {- type = "LowCardinality(String)"- }- column "severity_number" {- type = "Int32"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"+ type = "String"}column "instrumentation_scope" {type = "String"@@ -919,1718 +636,186 @@ SQLtype = "String"}column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "level" {- type = "String"- alias = "severity_text"- }- column "mat_body_ipv4_matches" {- type = "Array(String)"- alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"- }- column "time_minute" {- type = "DateTime"- alias = "toStartOfMinute(timestamp)"+ type = "Map(String, String)"}- column "attributes" {- type = "Map(LowCardinality(String), String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ column "resource_attributes" {+ type = "Map(String, String)"}- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ column "team_id" {+ type = "Int32"}- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"}column "_partition" {- type = "UInt32"+ type = "UInt64"}column "_topic" {- type = "String"+ type = "LowCardinality(String)"}column "_offset" {type = "UInt64"}- column "_bytes_uncompressed" {- type = "UInt64"- }- column "_bytes_compressed" {- type = "UInt64"- }column "_record_count" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "logs34"- }- }- table "logs_kafka_metrics" {- order_by = ["_topic", "_partition"]- settings = {- index_granularity = "8192"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, UInt64)"- }- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.logs_kafka_metrics"- replica_name = "{replica}-{shard}"- }- }- table "logs_kafka_metrics_distributed" {- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, UInt64)"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "logs_kafka_metrics"- }- }- table "metric_samples" {- column "team_id" {- type = "Int32"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "series_fingerprint" {- type = "UInt64"- codec = "DoubleDelta"- }- column "timestamp" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- column "value" {- type = "Float64"- codec = "Gorilla(8)"- }- column "count" {- type = "UInt64"- default = "1"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(UInt64)"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "metric_samples1"- }- }- table "metric_samples1" {- order_by = ["team_id", "metric_name", "series_fingerprint", "timestamp"]- partition_by = "toDate(timestamp)"- ttl = "toDateTime(timestamp) + toIntervalDay(30)"- settings = {- index_granularity = "8192"- ttl_only_drop_parts = "1"- }- column "team_id" {- type = "Int32"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "series_fingerprint" {- type = "UInt64"- codec = "DoubleDelta"- }- column "timestamp" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- column "value" {- type = "Float64"- codec = "Gorilla(8)"- }- column "count" {- type = "UInt64"- default = "1"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(UInt64)"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- index "idx_trace_id_bf" {- expr = "trace_id"- type = "bloom_filter(0.01)"- granularity = 1- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.metric_samples1"- replica_name = "{replica}-{shard}"- }- }- table "metric_series" {- column "team_id" {- type = "Int32"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "series_fingerprint" {- type = "UInt64"- codec = "DoubleDelta"- }- column "metric_type" {- type = "LowCardinality(String)"- }- column "unit" {- type = "LowCardinality(String)"- }- column "aggregation_temporality" {- type = "LowCardinality(String)"- }- column "is_monotonic" {- type = "Bool"- default = "false"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"+ type = "Int64"}- column "last_seen" {- type = "DateTime64(6)"- codec = "DoubleDelta"+ column "_bytes_uncompressed" {+ type = "Nullable(Int64)"}- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "metric_series1"+ column "_bytes_compressed" {+ type = "Nullable(Int64)"}}- table "metric_series1" {- order_by = ["team_id", "metric_name", "series_fingerprint"]- ttl = "toDateTime(last_seen) + toIntervalDay(90)"- settings = {- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "series_fingerprint" {- type = "UInt64"- codec = "DoubleDelta"- }- column "metric_type" {- type = "LowCardinality(String)"- }- column "unit" {- type = "LowCardinality(String)"- }- column "aggregation_temporality" {- type = "LowCardinality(String)"- }- column "is_monotonic" {- type = "Bool"- default = "false"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- }- column "last_seen" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- index "idx_service_set" {- expr = "service_name"- type = "set(1000)"- granularity = 1- }- index "idx_attr_keys" {- expr = "mapKeys(attributes)"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attr_values" {- expr = "mapValues(attributes)"- type = "bloom_filter(0.01)"- granularity = 1- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.metric_series1"- replica_name = "{replica}-{shard}"- version_column = "last_seen"- }- }- table "query_log_archive" {- column "hostname" {- type = "LowCardinality(String)"- }- column "user" {- type = "LowCardinality(String)"- }- column "query_id" {- type = "String"- }- column "initial_query_id" {- type = "String"- }- column "is_initial_query" {- type = "UInt8"- }- column "type" {- type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"- }- column "event_date" {- type = "Date"- }- column "event_time" {- type = "DateTime"- }- column "event_time_microseconds" {- type = "DateTime64(6)"- }- column "query_start_time" {- type = "DateTime"- }- column "query_start_time_microseconds" {- type = "DateTime64(6)"- }- column "query_duration_ms" {- type = "UInt64"- }- column "read_rows" {- type = "UInt64"- }- column "read_bytes" {- type = "UInt64"- }- column "written_rows" {- type = "UInt64"- }- column "written_bytes" {- type = "UInt64"- }- column "result_rows" {- type = "UInt64"- }- column "result_bytes" {- type = "UInt64"- }- column "memory_usage" {- type = "UInt64"- }- column "peak_threads_usage" {- type = "UInt64"- }- column "current_database" {- type = "LowCardinality(String)"- }- column "query" {- type = "String"- }- column "formatted_query" {- type = "String"- }- column "normalized_query_hash" {- type = "UInt64"- }- column "query_kind" {- type = "LowCardinality(String)"- }- column "exception_code" {- type = "Int32"- }- column "exception" {- type = "String"- }- column "stack_trace" {- type = "String"- }- column "team_id" {- type = "Int64"- }- column "log_comment" {- type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"- }- column "ProfileEvents" {- type = "Map(String, UInt64)"- }- column "exception_name" {- type = "String"- alias = "errorCodeToName(exception_code)"- }- column "ProfileEvents_RealTimeMicroseconds" {- type = "Int64"- alias = "ProfileEvents['RealTimeMicroseconds']"- }- column "ProfileEvents_OSCPUVirtualTimeMicroseconds" {- type = "Int64"- alias = "ProfileEvents['OSCPUVirtualTimeMicroseconds']"- }- column "ProfileEvents_S3Clients" {- type = "Int64"- alias = "ProfileEvents['S3Clients']"- }- column "ProfileEvents_S3DeleteObjects" {- type = "Int64"- alias = "ProfileEvents['S3DeleteObjects']"- }- column "ProfileEvents_S3CopyObject" {- type = "Int64"- alias = "ProfileEvents['S3CopyObject']"- }- column "ProfileEvents_S3ListObjects" {- type = "Int64"- alias = "ProfileEvents['S3ListObjects']"- }- column "ProfileEvents_S3HeadObject" {- type = "Int64"- alias = "ProfileEvents['S3HeadObject']"- }- column "ProfileEvents_S3GetObjectAttributes" {- type = "Int64"- alias = "ProfileEvents['S3GetObjectAttributes']"- }- column "ProfileEvents_S3CreateMultipartUpload" {- type = "Int64"- alias = "ProfileEvents['S3CreateMultipartUpload']"- }- column "ProfileEvents_S3UploadPartCopy" {- type = "Int64"- alias = "ProfileEvents['S3UploadPartCopy']"- }- column "ProfileEvents_S3UploadPart" {- type = "Int64"- alias = "ProfileEvents['S3UploadPart']"- }- column "ProfileEvents_S3AbortMultipartUpload" {- type = "Int64"- alias = "ProfileEvents['S3AbortMultipartUpload']"- }- column "ProfileEvents_S3CompleteMultipartUpload" {- type = "Int64"- alias = "ProfileEvents['S3CompleteMultipartUpload']"- }- column "ProfileEvents_S3PutObject" {- type = "Int64"- alias = "ProfileEvents['S3PutObject']"- }- column "ProfileEvents_S3GetObject" {- type = "Int64"- alias = "ProfileEvents['S3GetObject']"- }- column "ProfileEvents_ReadBufferFromS3Bytes" {- type = "Int64"- alias = "ProfileEvents['ReadBufferFromS3Bytes']"- }- column "ProfileEvents_WriteBufferFromS3Bytes" {- type = "Int64"- alias = "ProfileEvents['WriteBufferFromS3Bytes']"- }- column "lc_workflow" {- type = "LowCardinality(String)"- alias = "log_comment.workflow"- }- column "lc_kind" {- type = "LowCardinality(String)"- alias = "log_comment.kind"- }- column "lc_id" {- type = "String"- alias = "CAST(log_comment.id, 'String')"- }- column "lc_route_id" {- type = "String"- alias = "CAST(log_comment.route_id, 'String')"- }- column "lc_access_method" {- type = "LowCardinality(String)"- alias = "log_comment.access_method"- }- column "lc_api_key_label" {- type = "String"- alias = "CAST(log_comment.api_key_label, 'String')"- }- column "lc_api_key_mask" {- type = "String"- alias = "CAST(log_comment.api_key_mask, 'String')"- }- column "lc_query_type" {- type = "LowCardinality(String)"- alias = "log_comment.query_type"- }- column "lc_product" {- type = "LowCardinality(String)"- alias = "log_comment.product"- }- column "lc_chargeable" {- type = "Bool"- alias = "log_comment.chargeable"- }- column "lc_name" {- type = "String"- alias = "CAST(log_comment.name, 'String')"- }- column "lc_request_name" {- type = "String"- alias = "CAST(log_comment.request_name, 'String')"- }- column "lc_client_query_id" {- type = "String"- alias = "CAST(log_comment.client_query_id, 'String')"- }- column "lc_org_id" {- type = "String"- alias = "CAST(log_comment.org_id, 'String')"- }- column "lc_user_id" {- type = "Int64"- alias = "log_comment.user_id"- }- column "lc_is_impersonated" {- type = "Bool"- alias = "log_comment.is_impersonated"- }- column "lc_session_id" {- type = "String"- alias = "CAST(log_comment.session_id, 'String')"- }- column "lc_dashboard_id" {- type = "Int64"- alias = "log_comment.dashboard_id"- }- column "lc_insight_id" {- type = "Int64"- alias = "log_comment.insight_id"- }- column "lc_cohort_id" {- type = "Int64"- alias = "log_comment.cohort_id"- }- column "lc_batch_export_id" {- type = "String"- alias = "CAST(log_comment.batch_export_id, 'String')"- }- column "lc_experiment_id" {- type = "Int64"- alias = "log_comment.experiment_id"- }- column "lc_experiment_feature_flag_key" {- type = "String"- alias = "CAST(log_comment.experiment_feature_flag_key, 'String')"- }- column "lc_alert_config_id" {- type = "String"- alias = "CAST(log_comment.alert_config_id, 'String')"- }- column "lc_feature" {- type = "LowCardinality(String)"- alias = "log_comment.feature"- }- column "lc_table_id" {- type = "String"- alias = "CAST(log_comment.table_id, 'String')"- }- column "lc_warehouse_query" {- type = "Bool"- alias = "log_comment.warehouse_query"- }- column "lc_person_on_events_mode" {- type = "LowCardinality(String)"- alias = "log_comment.person_on_events_mode"- }- column "lc_service_name" {- type = "String"- alias = "CAST(log_comment.service_name, 'String')"- }- column "lc_workload" {- type = "LowCardinality(String)"- alias = "log_comment.workload"- }- column "lc_query__kind" {- type = "LowCardinality(String)"- alias = "if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind'))"- }- column "lc_query__query" {- type = "String"- alias = "multiIf(NOT is_initial_query, '', JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'query'), JSONExtractString(toString(log_comment), 'query', 'query'))"- }- column "lc_query" {- type = "String"- alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), '')"- }- column "lc_temporal__workflow_namespace" {- type = "String"- alias = "CAST(log_comment.`temporal.workflow_namespace`, 'String')"- }- column "lc_temporal__workflow_type" {- type = "String"- alias = "CAST(log_comment.`temporal.workflow_type`, 'String')"- }- column "lc_temporal__workflow_id" {- type = "String"- alias = "CAST(log_comment.`temporal.workflow_id`, 'String')"- }- column "lc_temporal__workflow_run_id" {- type = "String"- alias = "CAST(log_comment.`temporal.workflow_run_id`, 'String')"- }- column "lc_temporal__activity_type" {- type = "String"- alias = "CAST(log_comment.`temporal.activity_type`, 'String')"- }- column "lc_temporal__activity_id" {- type = "String"- alias = "CAST(log_comment.`temporal.activity_id`, 'String')"- }- column "lc_temporal__attempt" {- type = "Int64"- alias = "log_comment.`temporal.attempt`"- }- column "lc_dagster__job_name" {- type = "String"- alias = "CAST(log_comment.`dagster.job_name`, 'String')"- }- column "lc_dagster__run_id" {- type = "String"- alias = "CAST(log_comment.`dagster.run_id`, 'String')"- }- column "lc_dagster__owner" {- type = "String"- alias = "CAST(log_comment.`dagster.tags.owner`, 'String')"- }- column "lc_modifiers" {- type = "String"- alias = "if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')"- }- engine "distributed" {- cluster_name = "ops"- remote_database = "posthog"- remote_table = "sharded_query_log_archive"- }- }- materialized_view "kafka_logs34_avro_mv" {- to_table = "posthog.logs34"- query = <<SQL-SELECT- kafka_logs_avro.* EXCEPT(created_at, attribute_values, attribute_keys, attributes, attributes_map_str, attributes_map_float, attributes_map_datetime, resource_attributes, bytes_uncompressed),- mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,- mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,- toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,- observed_timestamp- + toIntervalDay(- toInt32OrDefault(_headers.value[indexOf(_headers.name, 'retention-days')], toInt32(15))- ) AS original_expiry_timestamp,- _partition,- _topic,- _offset,- toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,- toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_uncompressed')]) / _record_count AS _bytes_uncompressed,- toInt64OrNull(_headers.value[indexOf(_headers.name, 'bytes_compressed')]) / _record_count AS _bytes_compressed-FROM posthog.kafka_logs_avro-SQL-- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "body" {- type = "String"- }- column "severity_text" {- type = "String"- }- column "severity_number" {- type = "Int32"- }- column "service_name" {- type = "String"- }- column "instrumentation_scope" {- type = "String"- }- column "event_name" {- type = "String"- }- column "attributes_map_str" {- type = "Map(String, String)"- }- column "resource_attributes" {- type = "Map(String, String)"- }- column "team_id" {- type = "Int32"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "_partition" {- type = "UInt64"- }- column "_topic" {- type = "LowCardinality(String)"- }- column "_offset" {- type = "UInt64"- }- column "_record_count" {- type = "Int64"- }- column "_bytes_uncompressed" {- type = "Nullable(Int64)"- }- column "_bytes_compressed" {- type = "Nullable(Int64)"- }- }- materialized_view "kafka_logs_avro_billing_metrics_mv" {- to_table = "posthog.logs_billing_metrics"- query = <<SQL-SELECT- team_id,- time_bucket,- service_name,- sumSimpleState(_bytes_uncompressed) AS bytes_uncompressed,- sumSimpleState(_bytes_compressed) AS bytes_compressed,- sumSimpleState(1) AS record_count-FROM- (- SELECT- team_id,- toStartOfInterval(timestamp, toIntervalMinute(1)) AS time_bucket,- service_name AS service_name,- _bytes_uncompressed,- _bytes_compressed- FROM posthog.logs34- )-GROUP BY- team_id, time_bucket, service_name-SQL-- column "team_id" {- type = "Int32"- }- column "time_bucket" {- type = "DateTime"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "bytes_uncompressed" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "bytes_compressed" {- type = "SimpleAggregateFunction(sum, Float64)"- }- column "record_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- }- materialized_view "kafka_logs_avro_kafka_metrics_mv" {- to_table = "posthog.logs_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.logs34-GROUP BY- _partition, _topic-SQL-- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "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 "logs32_to_log_attributes" {- to_table = "posthog.log_attributes"- 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.logs32- 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 "logs32_to_resource_attributes" {- to_table = "posthog.log_attributes"- 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.logs32- 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_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-SELECT- team_id,- time_bucket,- original_expiry_time_bucket,- service_name,- resource_fingerprint,- attribute_key,- attribute_value,- attribute_type,- severity_text,- 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,- severity_text AS severity_text,- 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, severity_text, 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 "severity_text" {- type = "LowCardinality(String)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- }- 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-SELECT- team_id,- time_bucket,- original_expiry_time_bucket,- service_name,- resource_fingerprint,- attribute_key,- attribute_value,- attribute_type,- severity_text,- 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,- severity_text AS severity_text,- 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, severity_text, 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 "severity_text" {- type = "LowCardinality(String)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- }-- table "trace_spans" {- order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "status_code", "name", "timestamp"]- partition_by = "toDate(original_expiry_timestamp)"- ttl = "original_expiry_timestamp"- settings = {- allow_part_offset_column_in_projections = "1"- index_granularity = "8192"- index_granularity_bytes = "104857600"- map_serialization_version = "with_buckets"- ttl_only_drop_parts = "1"- }- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "parent_span_id" {- type = "String"- }- column "is_root_span" {- type = "Bool"- materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"- }- column "trace_state" {- type = "String"- }- column "name" {- type = "LowCardinality(String)"- }- column "kind" {- type = "Int8"- }- column "flags" {- type = "UInt32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "end_time" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "duration_nano" {- type = "UInt64"- materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"- }- column "status_code" {- type = "Int16"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"- }- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"- }- column "dropped_attributes_count" {- type = "UInt32"- }- column "dropped_events_count" {- type = "UInt32"- }- column "dropped_links_count" {- type = "UInt32"- }- column "events" {- type = "Array(String)"- }- column "links" {- type = "Array(String)"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "_offset" {- type = "UInt64"- }- column "_bytes_uncompressed" {- type = "UInt64"- }- column "_bytes_compressed" {- type = "UInt64"- }- column "_record_count" {- type = "UInt64"- }- index "idx_name" {- expr = "name"- type = "ngrambf_v1(4, 5000, 2, 0)"- granularity = 16- }- index "idx_kind" {- expr = "kind"- type = "minmax"- granularity = 4- }- index "idx_duration" {- expr = "duration_nano"- type = "minmax"- granularity = 1- }- index "idx_status_code" {- expr = "status_code"- type = "minmax"- granularity = 1- }- index "idx_timestamp_minmax" {- expr = "timestamp"- type = "minmax"- granularity = 1- }- index "idx_observed_minmax" {- expr = "observed_timestamp"- type = "minmax"- granularity = 1- }- index "idx_attributes_str_keys" {- expr = "mapKeys(attributes_map_str)"- type = "bloom_filter(0.01)"- granularity = 16- }- index "idx_attributes_str_values" {- expr = "mapValues(attributes_map_str)"- type = "bloom_filter(0.001)"- granularity = 16- }- index "idx_trace_bloom_part" {- expr = "trace_id"- type = "bloom_filter(0.00001)"- granularity = 99999- }- index "idx_span_id_bloom_part" {- expr = "span_id"- type = "bloom_filter(0.00001)"- granularity = 99999- }- projection "projection_aggregate_counts" {- query = <<SQL+ materialized_view "kafka_logs_avro_billing_metrics_mv" {+ to_table = "posthog.logs_billing_metrics"+ query = <<SQLSELECTteam_id,time_bucket,- toStartOfMinute(timestamp),service_name,- resource_fingerprint,- is_root_span,- count() AS event_count+ sumSimpleState(_bytes_uncompressed) AS bytes_uncompressed,+ sumSimpleState(_bytes_compressed) AS bytes_compressed,+ sumSimpleState(1) AS record_count+FROM+ (+ SELECT+ team_id,+ toStartOfInterval(timestamp, toIntervalMinute(1)) AS time_bucket,+ service_name AS service_name,+ _bytes_uncompressed,+ _bytes_compressed+ FROM posthog.logs34+ )GROUP BY- team_id, time_bucket, toStartOfMinute(timestamp), service_name, resource_fingerprint, is_root_span-SQL-- }- projection "projection_index_span_id" {- query = <<SQL-SELECT _part_offset-ORDER BY span_id-SQL-- }- projection "projection_index_trace_id" {- query = <<SQL-SELECT _part_offset-ORDER BY trace_id+ team_id, time_bucket, service_nameSQL+ column "team_id" {+ type = "Int32"}- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.trace_spans"- replica_name = "{replica}-{shard}"- }- }- table "trace_attributes" {- order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]- partition_by = "toDate(original_expiry_time_bucket)"- ttl = "original_expiry_time_bucket"- settings = {- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- }- column "attribute_type" {- type = "LowCardinality(String)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- index "idx_attribute_key" {- expr = "attribute_key"- type = "bloom_filter(0.01)"- granularity = 4- }- index "idx_attribute_value" {- expr = "attribute_value"- type = "bloom_filter(0.01)"- granularity = 4- }- index "idx_attribute_key_n3" {- expr = "attribute_key"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 4- }- index "idx_attribute_value_n3" {- expr = "attribute_value"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 4- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.trace_attributes"- replica_name = "{replica}-{shard}"- }- }- table "trace_attributes2" {- order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]- partition_by = "toDate(original_expiry_time_bucket)"- ttl = "original_expiry_time_bucket"- settings = {- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- }- column "attribute_type" {- type = "LowCardinality(String)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- index "idx_attribute_key" {- expr = "attribute_key"- type = "bloom_filter(0.01)"- granularity = 4- }- index "idx_attribute_value" {- expr = "attribute_value"- type = "bloom_filter(0.01)"- granularity = 4- }- index "idx_attribute_key_n3" {- expr = "attribute_key"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 4- }- index "idx_attribute_value_n3" {- expr = "attribute_value"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 4- }- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.trace_attributes2"- replica_name = "{replica}-{shard}"- }- }- table "trace_spans_kafka_metrics" {- order_by = ["_topic", "_partition"]- settings = {- index_granularity = "8192"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, UInt64)"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.trace_spans_kafka_metrics"- replica_name = "{replica}-{shard}"- }- }- table "trace_spans_distributed" {- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "parent_span_id" {- type = "String"- }- column "is_root_span" {- type = "Bool"- materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"- }- column "trace_state" {- type = "String"- }- column "name" {- type = "LowCardinality(String)"- }- column "kind" {- type = "Int8"- }- column "flags" {- type = "UInt32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "end_time" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "duration_nano" {- type = "UInt64"- materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"- }- column "status_code" {- type = "Int16"+ column "time_bucket" {+ type = "DateTime"}column "service_name" {type = "LowCardinality(String)"}- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"- }- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"- }- column "dropped_attributes_count" {- type = "UInt32"+ column "bytes_uncompressed" {+ type = "SimpleAggregateFunction(sum, Float64)"}- column "dropped_events_count" {- type = "UInt32"+ column "bytes_compressed" {+ type = "SimpleAggregateFunction(sum, Float64)"}- column "dropped_links_count" {- type = "UInt32"+ column "record_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"}- column "events" {- type = "Array(String)"+ }+ materialized_view "logs32_to_log_attributes" {+ to_table = "posthog.log_attributes"+ 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.logs32+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, attributes+ )+SQL++ column "team_id" {+ type = "Int32"}- column "links" {- type = "Array(String)"+ column "time_bucket" {+ type = "DateTime64(0)"}- column "_partition" {- type = "UInt32"+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"}- column "_topic" {- type = "String"+ column "service_name" {+ type = "LowCardinality(String)"}- column "_offset" {+ column "resource_fingerprint" {type = "UInt64"}- column "_bytes_uncompressed" {- type = "UInt64"+ column "attribute_key" {+ type = "LowCardinality(String)"}- column "_bytes_compressed" {- type = "UInt64"+ column "attribute_value" {+ type = "String"}- column "_record_count" {- type = "UInt64"+ column "attribute_type" {+ type = "LowCardinality(String)"}- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "trace_spans"+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"}}- table "trace_attributes_distributed" {+ materialized_view "logs32_to_resource_attributes" {+ to_table = "posthog.log_attributes"+ 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.logs32+ GROUP BY+ team_id, time_bucket, original_expiry_time_bucket, service_name, resource_fingerprint, resource_attributes+ )+SQL+column "team_id" {type = "Int32"}- column "original_expiry_time_bucket" {+ column "time_bucket" {type = "DateTime64(0)"}- column "time_bucket" {+ column "original_expiry_time_bucket" {type = "DateTime64(0)"}column "service_name" {type = "LowCardinality(String)"}column "resource_fingerprint" {- type = "UInt64"- default = "0"+ type = "UInt64"}column "attribute_key" {type = "LowCardinality(String)"@@ -2644,16 +829,33 @@ SQLcolumn "attribute_count" {type = "SimpleAggregateFunction(sum, UInt64)"}- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "trace_attributes"- }}- table "kafka_trace_spans_avro" {++ table "trace_spans" {+ override = true+ order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "status_code", "name", "timestamp"]+ partition_by = "toDate(original_expiry_timestamp)"+ ttl = "original_expiry_timestamp"+ settings = {+ allow_part_offset_column_in_projections = "1"+ index_granularity = "8192"+ index_granularity_bytes = "104857600"+ map_serialization_version = "with_buckets"+ ttl_only_drop_parts = "1"+ }+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }column "uuid" {type = "String"}+ column "team_id" {+ type = "Int32"+ }column "trace_id" {type = "String"}@@ -2663,17 +865,21 @@ SQLcolumn "parent_span_id" {type = "String"}+ column "is_root_span" {+ type = "Bool"+ materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"+ }column "trace_state" {type = "String"}column "name" {- type = "String"+ type = "LowCardinality(String)"}column "kind" {- type = "Int32"+ type = "Int8"}column "flags" {- type = "Int32"+ type = "UInt32"}column "timestamp" {type = "DateTime64(6)"@@ -2684,196 +890,169 @@ SQLcolumn "observed_timestamp" {type = "DateTime64(6)"}- column "service_name" {- type = "String"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- }- column "dropped_attributes_count" {- type = "Int32"- }- column "events" {- type = "Array(String)"- }- column "dropped_events_count" {- type = "Int32"- }- column "links" {- type = "Array(String)"- }- column "dropped_links_count" {- type = "Int32"- }- column "status_code" {- type = "Int32"- }- engine "kafka" {- broker_list = "warpstream_traces"- topic_list = "kafka_topic_list = 'clickhouse_traces'"- group_name = "kafka_group_name = 'clickhouse-traces-avro'"- format = "kafka_format = 'Avro'"- num_consumers = 8- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }- materialized_view "trace_span_to_attributes" {- to_table = "posthog.trace_attributes"- query = <<SQL-SELECT- team_id,- original_expiry_time_bucket,- time_bucket,- service_name,- resource_fingerprint,- attribute_key,- attribute_value,- 'span_attribute' AS attribute_type,- attribute_count-FROM- (- SELECT- team_id AS team_id,- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,- service_name AS service_name,- resource_fingerprint,- arrayJoin(mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes)) AS attribute,- attribute.1 AS attribute_key,- attribute.2 AS attribute_value,- sumSimpleState(1) AS attribute_count- FROM posthog.trace_spans- GROUP BY- team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute- )-SQL-- column "team_id" {- type = "Int32"+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"}- column "original_expiry_time_bucket" {- type = "DateTime64(0)"+ column "duration_nano" {+ type = "UInt64"+ materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"}- column "time_bucket" {- type = "DateTime64(0)"+ column "status_code" {+ type = "Int16"}column "service_name" {type = "LowCardinality(String)"}- column "resource_fingerprint" {- type = "UInt64"+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"}- column "attribute_key" {- type = "LowCardinality(String)"+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"}- column "attribute_value" {+ column "instrumentation_scope" {type = "String"}- column "attribute_type" {- type = "LowCardinality(String)"+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"}- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"}- }- materialized_view "trace_span_to_resource_attributes" {- to_table = "posthog.trace_attributes"- query = <<SQL-SELECT- team_id,- original_expiry_time_bucket,- time_bucket,- service_name,- resource_fingerprint,- attribute_key,- attribute_value,- 'span_resource_attribute' AS attribute_type,- attribute_count-FROM- (- SELECT- team_id AS team_id,- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,- service_name AS service_name,- resource_fingerprint,- arrayJoin(resource_attributes) AS attribute,- attribute.1 AS attribute_key,- attribute.2 AS attribute_value,- sumSimpleState(1) AS attribute_count- FROM posthog.trace_spans- GROUP BY- team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute- )-SQL-- column "team_id" {- type = "Int32"+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"}- column "original_expiry_time_bucket" {- type = "DateTime64(0)"+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"}- column "time_bucket" {- type = "DateTime64(0)"+ column "dropped_attributes_count" {+ type = "UInt32"}- column "service_name" {- type = "LowCardinality(String)"+ column "dropped_events_count" {+ type = "UInt32"}- column "resource_fingerprint" {- type = "UInt64"+ column "dropped_links_count" {+ type = "UInt32"}- column "attribute_key" {- type = "LowCardinality(String)"+ column "events" {+ type = "Array(String)"}- column "attribute_value" {+ column "links" {+ type = "Array(String)"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {type = "String"}- column "attribute_type" {- type = "LowCardinality(String)"+ column "_offset" {+ type = "UInt64"}- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"+ column "_bytes_uncompressed" {+ type = "UInt64"}- }- materialized_view "trace_span_to_span_attributes" {- to_table = "posthog.trace_attributes"- query = <<SQL+ column "_bytes_compressed" {+ type = "UInt64"+ }+ column "_record_count" {+ type = "UInt64"+ }+ index "idx_name" {+ expr = "name"+ type = "ngrambf_v1(4, 5000, 2, 0)"+ granularity = 16+ }+ index "idx_kind" {+ expr = "kind"+ type = "minmax"+ granularity = 4+ }+ index "idx_duration" {+ expr = "duration_nano"+ type = "minmax"+ granularity = 1+ }+ index "idx_status_code" {+ expr = "status_code"+ type = "minmax"+ granularity = 1+ }+ index "idx_timestamp_minmax" {+ expr = "timestamp"+ type = "minmax"+ granularity = 1+ }+ index "idx_observed_minmax" {+ expr = "observed_timestamp"+ type = "minmax"+ granularity = 1+ }+ index "idx_attributes_str_keys" {+ expr = "mapKeys(attributes_map_str)"+ type = "bloom_filter(0.01)"+ granularity = 16+ }+ index "idx_attributes_str_values" {+ expr = "mapValues(attributes_map_str)"+ type = "bloom_filter(0.001)"+ granularity = 16+ }+ index "idx_trace_bloom_part" {+ expr = "trace_id"+ type = "bloom_filter(0.00001)"+ granularity = 99999+ }+ index "idx_span_id_bloom_part" {+ expr = "span_id"+ type = "bloom_filter(0.00001)"+ granularity = 99999+ }+ projection "projection_aggregate_counts" {+ query = <<SQLSELECTteam_id,- original_expiry_time_bucket,time_bucket,+ toStartOfMinute(timestamp),service_name,resource_fingerprint,- attribute_key,- attribute_value,- 'span' AS attribute_type,- attribute_count-FROM- (- SELECT- team_id AS team_id,- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,- service_name AS service_name,- resource_fingerprint,- 'name' AS attribute_key,- name AS attribute_value,- sumSimpleState(1) AS attribute_count- FROM posthog.trace_spans- GROUP BY- team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, name- )+ is_root_span,+ count() AS event_count+GROUP BY+ team_id, time_bucket, toStartOfMinute(timestamp), service_name, resource_fingerprint, is_root_span+SQL++ }+ projection "projection_index_span_id" {+ query = <<SQL+SELECT _part_offset+ORDER BY span_id+SQL++ }+ projection "projection_index_trace_id" {+ query = <<SQL+SELECT _part_offset+ORDER BY trace_idSQL+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.trace_spans"+ replica_name = "{replica}-{shard}"+ }+ }+ table "trace_attributes2" {+ order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]+ partition_by = "toDate(original_expiry_time_bucket)"+ ttl = "original_expiry_time_bucket"+ settings = {+ index_granularity = "8192"+ }column "team_id" {type = "Int32"}@@ -2887,7 +1066,8 @@ SQLtype = "LowCardinality(String)"}column "resource_fingerprint" {- type = "UInt64"+ type = "UInt64"+ default = "0"}column "attribute_key" {type = "LowCardinality(String)"@@ -2901,6 +1081,30 @@ SQLcolumn "attribute_count" {type = "SimpleAggregateFunction(sum, UInt64)"}+ index "idx_attribute_key" {+ expr = "attribute_key"+ type = "bloom_filter(0.01)"+ granularity = 4+ }+ index "idx_attribute_value" {+ expr = "attribute_value"+ type = "bloom_filter(0.01)"+ granularity = 4+ }+ index "idx_attribute_key_n3" {+ expr = "attribute_key"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 4+ }+ index "idx_attribute_value_n3" {+ expr = "attribute_value"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 4+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.trace_attributes2"+ replica_name = "{replica}-{shard}"+ }}materialized_view "trace_span_to_attributes2" {to_table = "posthog.trace_attributes2"@@ -3175,42 +1379,4 @@ SQLtype = "DateTime64(6)"}}- materialized_view "trace_spans_to_kafka_metrics_mv" {- to_table = "posthog.trace_spans_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.trace_spans-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))"- }- }}diff --git a/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hcl b/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hclnew file mode 100644index 000000000000..aa6b7a7ede3d--- /dev/null+++ b/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hcl@@ -0,0 +1,59 @@+# prod-eu deltas to base logs objects.+database "posthog" {+ patch_table "kafka_logs_avro" {+ column "bytes_uncompressed" {+ type = "Int64"+ after = "attributes"+ }+ engine "kafka" {+ broker_list = "warpstream_logs"+ topic_list = "kafka_topic_list = 'clickhouse_logs'"+ group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"+ format = "kafka_format = 'Avro'"+ num_consumers = 16+ skip_broken_messages = 100+ poll_timeout_ms = 3000+ poll_max_batch_size = 1000+ thread_per_consumer = true+ }+ }+ patch_table "kafka_trace_spans_avro" {+ engine "kafka" {+ broker_list = "warpstream_traces"+ topic_list = "kafka_topic_list = 'clickhouse_traces'"+ group_name = "kafka_group_name = 'clickhouse-traces-avro'"+ format = "kafka_format = 'Avro'"+ num_consumers = 2+ skip_broken_messages = 100+ poll_timeout_ms = 3000+ poll_max_batch_size = 1000+ thread_per_consumer = true+ }+ }+ patch_table "trace_spans_distributed" {+ column "_partition" {+ type = "UInt32"+ after = "links"+ }+ column "_topic" {+ type = "String"+ after = "_partition"+ }+ column "_offset" {+ type = "UInt64"+ after = "_topic"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ after = "_offset"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ after = "_bytes_uncompressed"+ }+ column "_record_count" {+ type = "UInt64"+ after = "_bytes_compressed"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/logs/prod-eu/tables.hcl b/posthog/clickhouse/hcl/roles/logs/prod-eu/tables.hclindex 06b8c1eb1235..c54f3d4cfc3c 100644--- a/posthog/clickhouse/hcl/roles/logs/prod-eu/tables.hcl+++ b/posthog/clickhouse/hcl/roles/logs/prod-eu/tables.hcl@@ -70,64 +70,6 @@ database "posthog" {type = "Nullable(Int64)"}}- table "kafka_logs_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "body" {- type = "String"- }- column "severity_text" {- type = "String"- }- column "severity_number" {- type = "Int32"- }- column "service_name" {- type = "String"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "instrumentation_scope" {- type = "String"- }- column "event_name" {- type = "String"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- }- column "bytes_uncompressed" {- type = "Int64"- }- engine "kafka" {- broker_list = "warpstream_logs"- topic_list = "kafka_topic_list = 'clickhouse_logs'"- group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"- format = "kafka_format = 'Avro'"- num_consumers = 16- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }materialized_view "kafka_logs_avro_billing_metrics_mv" {to_table = "posthog.logs_billing_metrics"query = file("sql/kafka_logs_avro_billing_metrics_mv.sql")@@ -150,1029 +92,4 @@ database "posthog" {type = "SimpleAggregateFunction(sum, UInt64)"}}- table "kafka_trace_spans_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "parent_span_id" {- type = "String"- }- column "trace_state" {- type = "String"- }- column "name" {- type = "String"- }- column "kind" {- type = "Int32"- }- column "flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "end_time" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "service_name" {- type = "String"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- }- column "dropped_attributes_count" {- type = "Int32"- }- column "events" {- type = "Array(String)"- }- column "dropped_events_count" {- type = "Int32"- }- column "links" {- type = "Array(String)"- }- column "dropped_links_count" {- type = "Int32"- }- column "status_code" {- type = "Int32"- }- engine "kafka" {- broker_list = "warpstream_traces"- topic_list = "kafka_topic_list = 'clickhouse_traces'"- group_name = "kafka_group_name = 'clickhouse-traces-avro'"- format = "kafka_format = 'Avro'"- num_consumers = 2- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }- materialized_view "kafka_trace_spans_avro_mv" {- to_table = "posthog.trace_spans"- query = file("sql/kafka_trace_spans_avro_mv.sql")- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "parent_span_id" {- type = "String"- }- column "trace_state" {- type = "String"- }- column "name" {- type = "String"- }- column "kind" {- type = "Int8"- }- column "flags" {- type = "UInt32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "end_time" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "service_name" {- type = "String"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "dropped_attributes_count" {- type = "UInt32"- }- column "events" {- type = "Array(String)"- }- column "dropped_events_count" {- type = "UInt32"- }- column "links" {- type = "Array(String)"- }- column "dropped_links_count" {- type = "UInt32"- }- column "status_code" {- type = "Int16"- }- column "team_id" {- type = "Int32"- }- }- table "logs34" {- order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "severity_text", "timestamp"]- partition_by = "toDate(original_expiry_timestamp)"- ttl = "original_expiry_timestamp"- settings = {- add_minmax_index_for_numeric_columns = "1"- allow_experimental_reverse_key = "1"- index_granularity = "8192"- index_granularity_bytes = "104857600"- map_serialization_version = "with_buckets"- storage_policy = "s3_tiered"- ttl_only_drop_parts = "1"- }- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "body" {- type = "String"- }- column "severity_text" {- type = "LowCardinality(String)"- }- column "severity_number" {- type = "Int32"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "event_name" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "level" {- type = "String"- alias = "severity_text"- }- column "mat_body_ipv4_matches" {- type = "Array(String)"- alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"- }- column "time_minute" {- type = "DateTime"- alias = "toStartOfMinute(timestamp)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"- }- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "_offset" {- type = "UInt64"- }- column "_bytes_uncompressed" {- type = "UInt64"- }- column "_bytes_compressed" {- type = "UInt64"- }- column "_record_count" {- type = "UInt64"- }- index "idx_severity_text_set" {- expr = "severity_text"- type = "set(10)"- granularity = 1- }- index "idx_attributes_str_keys" {- expr = "mapKeys(attributes_map_str)"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attributes_str_values" {- expr = "mapValues(attributes_map_str)"- type = "bloom_filter(0.001)"- granularity = 1- }- index "idx_mat_body_ipv4_matches" {- expr = "mat_body_ipv4_matches"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_body_ngram3" {- expr = "lower(body)"- type = "ngrambf_v1(3, 25000, 2, 0)"- granularity = 1- }- index "idx_uuid_bloom" {- expr = "uuid"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_observed_minmax" {- expr = "observed_timestamp"- type = "minmax"- granularity = 1- }- index "idx_timestamp_minmax" {- expr = "timestamp"- type = "minmax"- granularity = 1- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.logs34"- replica_name = "{replica}"- }- }- table "metrics" {- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "metric_type" {- type = "LowCardinality(String)"- }- column "value" {- type = "Float64"- codec = "Gorilla(8)"- }- column "count" {- type = "UInt64"- default = "1"- codec = "T64"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(UInt64)"- }- column "unit" {- type = "LowCardinality(String)"- }- column "aggregation_temporality" {- type = "LowCardinality(String)"- }- column "is_monotonic" {- type = "Bool"- default = "false"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- }- column "time_minute" {- type = "DateTime"- alias = "toStartOfMinute(timestamp)"- }- column "attributes" {- type = "Map(String, String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "metrics1"- }- }- table "metrics1" {- order_by = ["team_id", "time_bucket", "service_name", "metric_name", "resource_fingerprint", "timestamp"]- partition_by = "toDate(timestamp)"- settings = {- index_granularity = "8192"- index_granularity_bytes = "104857600"- ttl_only_drop_parts = "1"- }- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "metric_type" {- type = "LowCardinality(String)"- }- column "value" {- type = "Float64"- codec = "Gorilla(8)"- }- column "count" {- type = "UInt64"- default = "1"- codec = "T64"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(UInt64)"- }- column "unit" {- type = "LowCardinality(String)"- }- column "aggregation_temporality" {- type = "LowCardinality(String)"- }- column "is_monotonic" {- type = "Bool"- default = "false"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- }- column "time_minute" {- type = "DateTime"- alias = "toStartOfMinute(timestamp)"- }- column "attributes" {- type = "Map(String, String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- index "idx_metric_name_set" {- expr = "metric_name"- type = "set(100)"- granularity = 1- }- index "idx_metric_type_set" {- expr = "metric_type"- type = "set(10)"- granularity = 1- }- index "idx_attributes_str_keys" {- expr = "mapKeys(attributes_map_str)"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attributes_str_values" {- expr = "mapValues(attributes_map_str)"- type = "bloom_filter(0.001)"- granularity = 1- }- index "idx_observed_minmax" {- expr = "observed_timestamp"- type = "minmax"- granularity = 1- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.metrics1"- replica_name = "{replica}"- }- }- table "trace_attributes" {- order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]- partition_by = "toDate(original_expiry_time_bucket)"- ttl = "original_expiry_time_bucket"- settings = {- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- }- column "attribute_type" {- type = "LowCardinality(String)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- index "idx_attribute_key" {- expr = "attribute_key"- type = "bloom_filter(0.01)"- granularity = 4- }- index "idx_attribute_value" {- expr = "attribute_value"- type = "bloom_filter(0.01)"- granularity = 4- }- index "idx_attribute_key_n3" {- expr = "attribute_key"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 4- }- index "idx_attribute_value_n3" {- expr = "attribute_value"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 4- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.trace_attributes"- replica_name = "{replica}"- }- }- table "trace_attributes_distributed" {- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- }- column "attribute_type" {- type = "LowCardinality(String)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "trace_attributes"- }- }- materialized_view "trace_span_to_attributes" {- to_table = "posthog.trace_attributes"- query = file("sql/trace_span_to_attributes.sql")- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "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 "trace_span_to_resource_attributes" {- to_table = "posthog.trace_attributes"- query = file("sql/trace_span_to_resource_attributes.sql")- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "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 "trace_span_to_span_attributes" {- to_table = "posthog.trace_attributes"- query = file("sql/trace_span_to_span_attributes.sql")- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "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)"- }- }- table "trace_spans" {- order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "status_code", "name", "timestamp"]- partition_by = "toDate(original_expiry_timestamp)"- ttl = "original_expiry_timestamp"- settings = {- allow_part_offset_column_in_projections = "1"- index_granularity = "8192"- index_granularity_bytes = "104857600"- map_serialization_version = "with_buckets"- ttl_only_drop_parts = "1"- }- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "parent_span_id" {- type = "String"- }- column "is_root_span" {- type = "Bool"- materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"- }- column "trace_state" {- type = "String"- }- column "name" {- type = "LowCardinality(String)"- }- column "kind" {- type = "Int8"- }- column "flags" {- type = "UInt32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "end_time" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "duration_nano" {- type = "UInt64"- materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"- }- column "status_code" {- type = "Int16"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"- }- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"- }- column "dropped_attributes_count" {- type = "UInt32"- }- column "dropped_events_count" {- type = "UInt32"- }- column "dropped_links_count" {- type = "UInt32"- }- column "events" {- type = "Array(String)"- }- column "links" {- type = "Array(String)"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "_offset" {- type = "UInt64"- }- column "_bytes_uncompressed" {- type = "UInt64"- }- column "_bytes_compressed" {- type = "UInt64"- }- column "_record_count" {- type = "UInt64"- }- index "idx_name" {- expr = "name"- type = "ngrambf_v1(4, 5000, 2, 0)"- granularity = 16- }- index "idx_kind" {- expr = "kind"- type = "minmax"- granularity = 4- }- index "idx_duration" {- expr = "duration_nano"- type = "minmax"- granularity = 1- }- index "idx_status_code" {- expr = "status_code"- type = "minmax"- granularity = 1- }- index "idx_timestamp_minmax" {- expr = "timestamp"- type = "minmax"- granularity = 1- }- index "idx_observed_minmax" {- expr = "observed_timestamp"- type = "minmax"- granularity = 1- }- index "idx_attributes_str_keys" {- expr = "mapKeys(attributes_map_str)"- type = "bloom_filter(0.01)"- granularity = 16- }- index "idx_attributes_str_values" {- expr = "mapValues(attributes_map_str)"- type = "bloom_filter(0.001)"- granularity = 16- }- index "idx_trace_bloom_part" {- expr = "trace_id"- type = "bloom_filter(0.00001)"- granularity = 99999- }- index "idx_span_id_bloom_part" {- expr = "span_id"- type = "bloom_filter(0.00001)"- granularity = 99999- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.trace_spans"- replica_name = "{replica}"- }- }- table "trace_spans_distributed" {- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "parent_span_id" {- type = "String"- }- column "is_root_span" {- type = "Bool"- materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"- }- column "trace_state" {- type = "String"- }- column "name" {- type = "LowCardinality(String)"- }- column "kind" {- type = "Int8"- }- column "flags" {- type = "UInt32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "end_time" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "duration_nano" {- type = "UInt64"- materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"- }- column "status_code" {- type = "Int16"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"- }- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"- }- column "dropped_attributes_count" {- type = "UInt32"- }- column "dropped_events_count" {- type = "UInt32"- }- column "dropped_links_count" {- type = "UInt32"- }- column "events" {- type = "Array(String)"- }- column "links" {- type = "Array(String)"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "_offset" {- type = "UInt64"- }- column "_bytes_uncompressed" {- type = "UInt64"- }- column "_bytes_compressed" {- type = "UInt64"- }- column "_record_count" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "trace_spans"- }- }}diff --git a/posthog/clickhouse/hcl/roles/logs/prod-us/patches.hcl b/posthog/clickhouse/hcl/roles/logs/prod-us/patches.hclnew file mode 100644index 000000000000..0994bc767a7b--- /dev/null+++ b/posthog/clickhouse/hcl/roles/logs/prod-us/patches.hcl@@ -0,0 +1,28 @@+# prod-us deltas to base logs objects.+database "posthog" {+ patch_table "kafka_logs_avro" {+ engine "kafka" {+ broker_list = "warpstream_logs"+ topic_list = "kafka_topic_list = 'clickhouse_logs'"+ group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"+ format = "kafka_format = 'Avro'"+ num_consumers = 32+ skip_broken_messages = 100+ poll_timeout_ms = 3000+ poll_max_batch_size = 1000+ thread_per_consumer = true+ }+ }+ patch_table "logs34" {+ settings = {+ map_buckets_strategy = "constant"+ max_buckets_in_map = "32"+ }+ }+ patch_table "trace_spans_kafka_metrics" {+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/logs/{shard}/posthog.trace_spans_kafka_metrics"+ replica_name = "{replica}"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/logs/prod-us/sql/kafka_trace_spans_avro_mv.sql b/posthog/clickhouse/hcl/roles/logs/prod-us/sql/kafka_trace_spans_avro_mv.sqldeleted file mode 100644index 0ca8e7ee842d..000000000000--- a/posthog/clickhouse/hcl/roles/logs/prod-us/sql/kafka_trace_spans_avro_mv.sql+++ /dev/null@@ -1,18 +0,0 @@-SELECT- * EXCEPT(attributes, resource_attributes, kind, flags, dropped_attributes_count, dropped_events_count, dropped_links_count, status_code),- toInt8(kind) AS kind,- toUInt32(flags) AS flags,- toUInt32(dropped_attributes_count) AS dropped_attributes_count,- toUInt32(dropped_events_count) AS dropped_events_count,- toUInt32(dropped_links_count) AS dropped_links_count,- toInt16(status_code) AS status_code,- mapSort(mapApply((k, v) -> (concat(k, '__str'), JSONExtractString(v)), attributes)) AS attributes_map_str,- mapSort(mapApply((k, v) -> (k, JSONExtractString(v)), resource_attributes)) AS resource_attributes,- toInt32OrZero(_headers.value[indexOf(_headers.name, 'team_id')]) AS team_id,- _partition,- _topic,- _offset,- toInt64OrDefault(_headers.value[indexOf(_headers.name, 'record_count')], toInt64(1)) AS _record_count,- 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_avrodiff --git a/posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_span_to_attributes.sql b/posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_span_to_attributes.sqldeleted file mode 100644index 6d04bf3d4469..000000000000--- a/posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_span_to_attributes.sql+++ /dev/null@@ -1,26 +0,0 @@-SELECT- team_id,- original_expiry_time_bucket,- time_bucket,- service_name,- resource_fingerprint,- attribute_key,- attribute_value,- 'span_attribute' AS attribute_type,- attribute_count-FROM- (- SELECT- team_id AS team_id,- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,- service_name AS service_name,- resource_fingerprint,- arrayJoin(mapFilter((k, v) -> ((length(k) < 256) AND (length(v) < 256)), attributes)) AS attribute,- attribute.1 AS attribute_key,- attribute.2 AS attribute_value,- sumSimpleState(1) AS attribute_count- FROM posthog.trace_spans- GROUP BY- team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute- )diff --git a/posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_span_to_resource_attributes.sql b/posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_span_to_resource_attributes.sqldeleted file mode 100644index 05cbac84f741..000000000000--- a/posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_span_to_resource_attributes.sql+++ /dev/null@@ -1,26 +0,0 @@-SELECT- team_id,- original_expiry_time_bucket,- time_bucket,- service_name,- resource_fingerprint,- attribute_key,- attribute_value,- 'span_resource_attribute' AS attribute_type,- attribute_count-FROM- (- SELECT- team_id AS team_id,- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,- service_name AS service_name,- resource_fingerprint,- arrayJoin(resource_attributes) AS attribute,- attribute.1 AS attribute_key,- attribute.2 AS attribute_value,- sumSimpleState(1) AS attribute_count- FROM posthog.trace_spans- GROUP BY- team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, attribute- )diff --git a/posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_span_to_span_attributes.sql b/posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_span_to_span_attributes.sqldeleted file mode 100644index 5d1b29750379..000000000000--- a/posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_span_to_span_attributes.sql+++ /dev/null@@ -1,25 +0,0 @@-SELECT- team_id,- original_expiry_time_bucket,- time_bucket,- service_name,- resource_fingerprint,- attribute_key,- attribute_value,- 'span' AS attribute_type,- attribute_count-FROM- (- SELECT- team_id AS team_id,- toStartOfInterval(original_expiry_timestamp, toIntervalMinute(10)) AS original_expiry_time_bucket,- toStartOfInterval(timestamp, toIntervalMinute(10)) AS time_bucket,- service_name AS service_name,- resource_fingerprint,- 'name' AS attribute_key,- name AS attribute_value,- sumSimpleState(1) AS attribute_count- FROM posthog.trace_spans- GROUP BY- team_id, original_expiry_time_bucket, time_bucket, service_name, resource_fingerprint, name- )diff --git a/posthog/clickhouse/hcl/roles/logs/prod-us/tables.hcl b/posthog/clickhouse/hcl/roles/logs/prod-us/tables.hclindex 46cb71f9eae3..5c37f6ecba19 100644--- a/posthog/clickhouse/hcl/roles/logs/prod-us/tables.hcl+++ b/posthog/clickhouse/hcl/roles/logs/prod-us/tables.hcl@@ -70,61 +70,7 @@ database "posthog" {type = "Nullable(Int64)"}}- table "kafka_logs_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "body" {- type = "String"- }- column "severity_text" {- type = "String"- }- column "severity_number" {- type = "Int32"- }- column "service_name" {- type = "String"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "instrumentation_scope" {- type = "String"- }- column "event_name" {- type = "String"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- }- engine "kafka" {- broker_list = "warpstream_logs"- topic_list = "kafka_topic_list = 'clickhouse_logs'"- group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"- format = "kafka_format = 'Avro'"- num_consumers = 32- skip_broken_messages = 100- poll_timeout_ms = 3000- poll_max_batch_size = 1000- thread_per_consumer = true- }- }+materialized_view "kafka_logs_avro_billing_metrics_mv" {to_table = "posthog.logs_billing_metrics"query = file("sql/kafka_logs_avro_billing_metrics_mv.sql")@@ -147,1069 +93,4 @@ database "posthog" {type = "SimpleAggregateFunction(sum, UInt64)"}}- table "kafka_trace_spans_avro" {- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "parent_span_id" {- type = "String"- }- column "trace_state" {- type = "String"- }- column "name" {- type = "String"- }- column "kind" {- type = "Int32"- }- column "flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "end_time" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "service_name" {- type = "String"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- }- column "dropped_attributes_count" {- type = "Int32"- }- column "events" {- type = "Array(String)"- }- column "dropped_events_count" {- type = "Int32"- }- column "links" {- type = "Array(String)"- }- column "dropped_links_count" {- type = "Int32"- }- column "status_code" {- type = "Int32"- }- engine "kafka" {- broker_list = "warpstream_traces"- topic_list = "kafka_topic_list = 'clickhouse_traces'"- group_name = "kafka_group_name = 'clickhouse-traces-avro'"- format = "kafka_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_trace_spans_avro_mv" {- to_table = "posthog.trace_spans"- query = file("sql/kafka_trace_spans_avro_mv.sql")- column "uuid" {- type = "String"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "parent_span_id" {- type = "String"- }- column "trace_state" {- type = "String"- }- column "name" {- type = "String"- }- column "kind" {- type = "Int8"- }- column "flags" {- type = "UInt32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "end_time" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "service_name" {- type = "String"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "dropped_attributes_count" {- type = "UInt32"- }- column "events" {- type = "Array(String)"- }- column "dropped_events_count" {- type = "UInt32"- }- column "links" {- type = "Array(String)"- }- column "dropped_links_count" {- type = "UInt32"- }- column "status_code" {- type = "Int16"- }- column "team_id" {- type = "Int32"- }- }- table "logs34" {- order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "severity_text", "timestamp"]- partition_by = "toDate(original_expiry_timestamp)"- ttl = "original_expiry_timestamp"- settings = {- add_minmax_index_for_numeric_columns = "1"- allow_experimental_reverse_key = "1"- index_granularity = "8192"- index_granularity_bytes = "104857600"- map_buckets_strategy = "constant"- map_serialization_version = "with_buckets"- max_buckets_in_map = "32"- storage_policy = "s3_tiered"- ttl_only_drop_parts = "1"- }- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "body" {- type = "String"- }- column "severity_text" {- type = "LowCardinality(String)"- }- column "severity_number" {- type = "Int32"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "event_name" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "level" {- type = "String"- alias = "severity_text"- }- column "mat_body_ipv4_matches" {- type = "Array(String)"- alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"- }- column "time_minute" {- type = "DateTime"- alias = "toStartOfMinute(timestamp)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"- }- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "_offset" {- type = "UInt64"- }- column "_bytes_uncompressed" {- type = "UInt64"- }- column "_bytes_compressed" {- type = "UInt64"- }- column "_record_count" {- type = "UInt64"- }- index "idx_severity_text_set" {- expr = "severity_text"- type = "set(10)"- granularity = 1- }- index "idx_attributes_str_keys" {- expr = "mapKeys(attributes_map_str)"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attributes_str_values" {- expr = "mapValues(attributes_map_str)"- type = "bloom_filter(0.001)"- granularity = 1- }- index "idx_mat_body_ipv4_matches" {- expr = "mat_body_ipv4_matches"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_body_ngram3" {- expr = "lower(body)"- type = "ngrambf_v1(3, 25000, 2, 0)"- granularity = 1- }- index "idx_uuid_bloom" {- expr = "uuid"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_observed_minmax" {- expr = "observed_timestamp"- type = "minmax"- granularity = 1- }- index "idx_timestamp_minmax" {- expr = "timestamp"- type = "minmax"- granularity = 1- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.logs34"- replica_name = "{replica}"- }- }- table "metrics" {- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "metric_type" {- type = "LowCardinality(String)"- }- column "value" {- type = "Float64"- codec = "Gorilla(8)"- }- column "count" {- type = "UInt64"- default = "1"- codec = "T64"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(UInt64)"- }- column "unit" {- type = "LowCardinality(String)"- }- column "aggregation_temporality" {- type = "LowCardinality(String)"- }- column "is_monotonic" {- type = "Bool"- default = "false"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- }- column "time_minute" {- type = "DateTime"- alias = "toStartOfMinute(timestamp)"- }- column "attributes" {- type = "Map(String, String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "metrics1"- }- }- table "metrics1" {- order_by = ["team_id", "time_bucket", "service_name", "metric_name", "resource_fingerprint", "timestamp"]- partition_by = "toDate(timestamp)"- settings = {- index_granularity = "8192"- index_granularity_bytes = "104857600"- ttl_only_drop_parts = "1"- }- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "metric_type" {- type = "LowCardinality(String)"- }- column "value" {- type = "Float64"- codec = "Gorilla(8)"- }- column "count" {- type = "UInt64"- default = "1"- codec = "T64"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(UInt64)"- }- column "unit" {- type = "LowCardinality(String)"- }- column "aggregation_temporality" {- type = "LowCardinality(String)"- }- column "is_monotonic" {- type = "Bool"- default = "false"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- }- column "time_minute" {- type = "DateTime"- alias = "toStartOfMinute(timestamp)"- }- column "attributes" {- type = "Map(String, String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- index "idx_metric_name_set" {- expr = "metric_name"- type = "set(100)"- granularity = 1- }- index "idx_metric_type_set" {- expr = "metric_type"- type = "set(10)"- granularity = 1- }- index "idx_attributes_str_keys" {- expr = "mapKeys(attributes_map_str)"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attributes_str_values" {- expr = "mapValues(attributes_map_str)"- type = "bloom_filter(0.001)"- granularity = 1- }- index "idx_observed_minmax" {- expr = "observed_timestamp"- type = "minmax"- granularity = 1- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.metrics1"- replica_name = "{replica}"- }- }- table "trace_attributes" {- order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]- partition_by = "toDate(original_expiry_time_bucket)"- ttl = "original_expiry_time_bucket"- settings = {- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- }- column "attribute_type" {- type = "LowCardinality(String)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- index "idx_attribute_key" {- expr = "attribute_key"- type = "bloom_filter(0.01)"- granularity = 4- }- index "idx_attribute_value" {- expr = "attribute_value"- type = "bloom_filter(0.01)"- granularity = 4- }- index "idx_attribute_key_n3" {- expr = "attribute_key"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 4- }- index "idx_attribute_value_n3" {- expr = "attribute_value"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 4- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.trace_attributes"- replica_name = "{replica}"- }- }- table "trace_attributes_distributed" {- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- }- column "attribute_type" {- type = "LowCardinality(String)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "trace_attributes"- }- }- materialized_view "trace_span_to_attributes" {- to_table = "posthog.trace_attributes"- query = file("sql/trace_span_to_attributes.sql")- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "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 "trace_span_to_resource_attributes" {- to_table = "posthog.trace_attributes"- query = file("sql/trace_span_to_resource_attributes.sql")- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "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 "trace_span_to_span_attributes" {- to_table = "posthog.trace_attributes"- query = file("sql/trace_span_to_span_attributes.sql")- column "team_id" {- type = "Int32"- }- column "original_expiry_time_bucket" {- type = "DateTime64(0)"- }- column "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)"- }- }- table "trace_spans" {- order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "status_code", "name", "timestamp"]- partition_by = "toDate(original_expiry_timestamp)"- ttl = "original_expiry_timestamp"- settings = {- allow_part_offset_column_in_projections = "1"- index_granularity = "8192"- index_granularity_bytes = "104857600"- map_serialization_version = "with_buckets"- ttl_only_drop_parts = "1"- }- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "parent_span_id" {- type = "String"- }- column "is_root_span" {- type = "Bool"- materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"- }- column "trace_state" {- type = "String"- }- column "name" {- type = "LowCardinality(String)"- }- column "kind" {- type = "Int8"- }- column "flags" {- type = "UInt32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "end_time" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "duration_nano" {- type = "UInt64"- materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"- }- column "status_code" {- type = "Int16"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"- }- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"- }- column "dropped_attributes_count" {- type = "UInt32"- }- column "dropped_events_count" {- type = "UInt32"- }- column "dropped_links_count" {- type = "UInt32"- }- column "events" {- type = "Array(String)"- }- column "links" {- type = "Array(String)"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "_offset" {- type = "UInt64"- }- column "_bytes_uncompressed" {- type = "UInt64"- }- column "_bytes_compressed" {- type = "UInt64"- }- column "_record_count" {- type = "UInt64"- }- index "idx_name" {- expr = "name"- type = "ngrambf_v1(4, 5000, 2, 0)"- granularity = 16- }- index "idx_kind" {- expr = "kind"- type = "minmax"- granularity = 4- }- index "idx_duration" {- expr = "duration_nano"- type = "minmax"- granularity = 1- }- index "idx_status_code" {- expr = "status_code"- type = "minmax"- granularity = 1- }- index "idx_timestamp_minmax" {- expr = "timestamp"- type = "minmax"- granularity = 1- }- index "idx_observed_minmax" {- expr = "observed_timestamp"- type = "minmax"- granularity = 1- }- index "idx_attributes_str_keys" {- expr = "mapKeys(attributes_map_str)"- type = "bloom_filter(0.01)"- granularity = 16- }- index "idx_attributes_str_values" {- expr = "mapValues(attributes_map_str)"- type = "bloom_filter(0.001)"- granularity = 16- }- index "idx_trace_bloom_part" {- expr = "trace_id"- type = "bloom_filter(0.00001)"- granularity = 99999- }- index "idx_span_id_bloom_part" {- expr = "span_id"- type = "bloom_filter(0.00001)"- granularity = 99999- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.trace_spans"- replica_name = "{replica}"- }- }- table "trace_spans_distributed" {- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "parent_span_id" {- type = "String"- }- column "is_root_span" {- type = "Bool"- materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"- }- column "trace_state" {- type = "String"- }- column "name" {- type = "LowCardinality(String)"- }- column "kind" {- type = "Int8"- }- column "flags" {- type = "UInt32"- }- column "timestamp" {- type = "DateTime64(6)"- }- column "end_time" {- type = "DateTime64(6)"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "duration_nano" {- type = "UInt64"- materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"- }- column "status_code" {- type = "Int16"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "resource_fingerprint" {- type = "UInt64"- materialized = "cityHash64(resource_attributes)"- }- column "instrumentation_scope" {- type = "String"- }- column "attributes_map_str" {- type = "Map(LowCardinality(String), String)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"- }- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"- }- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"- }- column "dropped_attributes_count" {- type = "UInt32"- }- column "dropped_events_count" {- type = "UInt32"- }- column "dropped_links_count" {- type = "UInt32"- }- column "events" {- type = "Array(String)"- }- column "links" {- type = "Array(String)"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "trace_spans"- }- }- table "trace_spans_kafka_metrics" {- order_by = ["_topic", "_partition"]- settings = {- index_granularity = "8192"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, UInt64)"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.trace_spans_kafka_metrics"- replica_name = "{replica}"- }- }- materialized_view "trace_spans_to_kafka_metrics_mv" {- to_table = "posthog.trace_spans_kafka_metrics"- query = file("sql/trace_spans_to_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))"- }- }}diff --git a/posthog/clickhouse/hcl/roles/logs/prod/patches.hcl b/posthog/clickhouse/hcl/roles/logs/prod/patches.hclnew file mode 100644index 000000000000..10308470eff5--- /dev/null+++ b/posthog/clickhouse/hcl/roles/logs/prod/patches.hcl@@ -0,0 +1,43 @@+# Both-prods deltas to base logs objects.+database "posthog" {+ patch_table "logs34" {+ settings = {+ storage_policy = "s3_tiered"+ }+ }+ patch_table "metrics" {+ modify_column "value" {+ type = "Float64"+ codec = "Gorilla(8)"+ }+ modify_column "count" {+ type = "UInt64"+ default = "1"+ codec = "T64"+ }+ }+ patch_table "metrics1" {+ modify_column "value" {+ type = "Float64"+ codec = "Gorilla(8)"+ }+ modify_column "count" {+ type = "UInt64"+ default = "1"+ codec = "T64"+ }+ }+ patch_table "trace_attributes" {+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/logs/{shard}/posthog.trace_attributes"+ replica_name = "{replica}"+ }+ }+ patch_table "trace_attributes_distributed" {+ engine "distributed" {+ cluster_name = "logs"+ remote_database = "posthog"+ remote_table = "trace_attributes"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/logs/prod-eu/sql/kafka_trace_spans_avro_mv.sql b/posthog/clickhouse/hcl/roles/logs/prod/sql/kafka_trace_spans_avro_mv.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/prod-eu/sql/kafka_trace_spans_avro_mv.sqlrename to posthog/clickhouse/hcl/roles/logs/prod/sql/kafka_trace_spans_avro_mv.sqldiff --git a/posthog/clickhouse/hcl/roles/logs/prod/tables.hcl b/posthog/clickhouse/hcl/roles/logs/prod/tables.hclindex c441e3db4f3e..4907662b6cfd 100644--- a/posthog/clickhouse/hcl/roles/logs/prod/tables.hcl+++ b/posthog/clickhouse/hcl/roles/logs/prod/tables.hcl@@ -80,4 +80,75 @@ database "posthog" {type = "DateTime64(6)"}}++ materialized_view "kafka_trace_spans_avro_mv" {+ to_table = "posthog.trace_spans"+ query = file("sql/kafka_trace_spans_avro_mv.sql")+ column "uuid" {+ type = "String"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "parent_span_id" {+ type = "String"+ }+ column "trace_state" {+ type = "String"+ }+ column "name" {+ type = "String"+ }+ column "kind" {+ type = "Int8"+ }+ column "flags" {+ type = "UInt32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "end_time" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "service_name" {+ type = "String"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "dropped_attributes_count" {+ type = "UInt32"+ }+ column "events" {+ type = "Array(String)"+ }+ column "dropped_events_count" {+ type = "UInt32"+ }+ column "links" {+ type = "Array(String)"+ }+ column "dropped_links_count" {+ type = "UInt32"+ }+ column "status_code" {+ type = "Int16"+ }+ column "team_id" {+ type = "Int32"+ }+ }}diff --git a/posthog/clickhouse/hcl/roles/logs/shared/patches.hcl b/posthog/clickhouse/hcl/roles/logs/shared/patches.hclnew file mode 100644index 000000000000..b944a8756e3d--- /dev/null+++ b/posthog/clickhouse/hcl/roles/logs/shared/patches.hcl@@ -0,0 +1,80 @@+# Cloud deltas to the base logs objects (roles/logs/base): the cloud logs+# cluster and its per-shard replication paths, plus prod-only merge settings.++database "posthog" {++ patch_table "log_attributes2" {+ partition_by = "toDate(time_bucket)"+ ttl = "time_bucket + toIntervalDay(15)"+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/logs/{shard}/log_attributes34"+ replica_name = "{replica}"+ }+ }++ patch_table "log_attributes_distributed" {+ engine "distributed" {+ cluster_name = "logs"+ remote_database = "posthog"+ remote_table = "log_attributes3"+ }+ }++ patch_table "logs_billing_metrics" {+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/logs/{shard}/logs_billing_metrics"+ replica_name = "{replica}"+ }+ }++ patch_table "logs_billing_metrics_distributed" {+ engine "distributed" {+ cluster_name = "logs"+ remote_database = "posthog"+ remote_table = "logs_billing_metrics"+ }+ }++ patch_table "logs_distributed" {+ engine "distributed" {+ cluster_name = "logs"+ remote_database = "posthog"+ remote_table = "logs34"+ }+ }++ patch_table "logs_kafka_metrics" {+ settings = {+ deduplicate_merge_projection_mode = "rebuild"+ }+ engine "replicated_aggregating_merge_tree" {+ zoo_path = "/clickhouse/tables/logs/{shard}/logs_kafka_metrics"+ replica_name = "{replica}"+ }+ }++ patch_table "logs_kafka_metrics_distributed" {+ engine "distributed" {+ cluster_name = "logs"+ remote_database = "posthog"+ remote_table = "logs_kafka_metrics"+ }+ }++ patch_table "metric_samples" {+ engine "distributed" {+ cluster_name = "logs"+ remote_database = "posthog"+ remote_table = "metric_samples1"+ }+ }++ patch_table "metric_series" {+ engine "distributed" {+ cluster_name = "logs"+ remote_database = "posthog"+ remote_table = "metric_series1"+ }+ }++}diff --git a/posthog/clickhouse/hcl/roles/logs/shared/tables.hcl b/posthog/clickhouse/hcl/roles/logs/shared/tables.hclindex 226e25cde000..fca4259aeae1 100644--- a/posthog/clickhouse/hcl/roles/logs/shared/tables.hcl+++ b/posthog/clickhouse/hcl/roles/logs/shared/tables.hcl@@ -1,33 +1,5 @@# LOGS role — managed logs/traces/metrics objects extracted from *-logs.hcl dumps.database "posthog" {- view "custom_metrics" {- query = file("sql/custom_metrics.sql")- }- materialized_view "kafka_logs_avro_kafka_metrics_mv" {- to_table = "posthog.logs_kafka_metrics"- query = file("sql/kafka_logs_avro_kafka_metrics_mv.sql")- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "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_metrics_avro" {column "uuid" {type = "String"@@ -193,10 +165,9 @@ database "posthog" {type = "Int32"}}- table "log_attributes2" {+ table "metric_attributes" {order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]partition_by = "toDate(time_bucket)"- ttl = "time_bucket + toIntervalDay(15)"settings = {deduplicate_merge_projection_mode = "drop"index_granularity = "8192"@@ -218,19 +189,13 @@ database "posthog" {type = "LowCardinality(String)"}column "attribute_value" {- type = "String"- codec = "ZSTD(5)"+ type = "String"}column "attribute_count" {type = "SimpleAggregateFunction(sum, UInt64)"}column "attribute_type" {- type = "LowCardinality(String)"- default = "'log'"- }- column "original_expiry_time_bucket" {- type = "DateTime"- default = "now()"+ type = "LowCardinality(String)"}index "idx_attribute_key" {expr = "attribute_key"@@ -253,22 +218,19 @@ database "posthog" {granularity = 1}engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/log_attributes34"+ zoo_path = "/clickhouse/tables/logs/{shard}/posthog.metric_attributes"replica_name = "{replica}"}}- materialized_view "logs34_to_log_attributes" {- to_table = "posthog.log_attributes2"- query = file("sql/logs34_to_log_attributes.sql")+ materialized_view "metrics1_to_metric_attributes" {+ to_table = "posthog.metric_attributes"+ query = file("sql/metrics1_to_metric_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)"}@@ -288,18 +250,15 @@ database "posthog" {type = "SimpleAggregateFunction(sum, UInt64)"}}- materialized_view "logs34_to_resource_attributes" {- to_table = "posthog.log_attributes2"- query = file("sql/logs34_to_resource_attributes.sql")+ materialized_view "metrics1_to_resource_attributes" {+ to_table = "posthog.metric_attributes"+ query = file("sql/metrics1_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)"}@@ -319,66 +278,10 @@ database "posthog" {type = "SimpleAggregateFunction(sum, UInt64)"}}- table "logs_billing_metrics" {- order_by = ["team_id", "time_bucket", "service_name"]- partition_by = "toYYYYMM(time_bucket)"- settings = {- deduplicate_merge_projection_mode = "rebuild"- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "bytes_uncompressed" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "bytes_compressed" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "record_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/logs_billing_metrics"- replica_name = "{replica}"- }- }- table "logs_billing_metrics_distributed" {- column "team_id" {- type = "Int32"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "bytes_uncompressed" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "bytes_compressed" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "record_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "logs_billing_metrics"- }- }- table "logs_kafka_metrics" {+ table "metrics_kafka_metrics" {order_by = ["_topic", "_partition"]settings = {- deduplicate_merge_projection_mode = "rebuild"- index_granularity = "8192"+ index_granularity = "8192"}column "_partition" {type = "UInt32"@@ -402,318 +305,152 @@ database "posthog" {type = "SimpleAggregateFunction(max, UInt64)"}engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/logs_kafka_metrics"+ zoo_path = "/clickhouse/tables/logs/{shard}/posthog.metrics_kafka_metrics"replica_name = "{replica}"}}- table "logs_kafka_metrics_distributed" {- column "_partition" {- type = "UInt32"++ table "metrics" {+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfDay(timestamp)"}- column "_topic" {+ column "uuid" {type = "String"}- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"+ column "team_id" {+ type = "Int32"}- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"+ column "trace_id" {+ type = "String"}- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"+ column "span_id" {+ type = "String"}- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime64(9))"+ column "trace_flags" {+ type = "Int32"}- column "max_lag" {- type = "SimpleAggregateFunction(max, UInt64)"+ column "timestamp" {+ type = "DateTime64(6)"}- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "logs_kafka_metrics"+ column "observed_timestamp" {+ type = "DateTime64(6)"}- }- table "metric_attributes" {- order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]- partition_by = "toDate(time_bucket)"- settings = {- deduplicate_merge_projection_mode = "drop"- index_granularity = "8192"+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"}- column "team_id" {- type = "Int32"+ column "service_name" {+ type = "LowCardinality(String)"}- column "time_bucket" {- type = "DateTime64(0)"+ column "metric_name" {+ type = "LowCardinality(String)"}- column "service_name" {+ column "metric_type" {type = "LowCardinality(String)"}- column "resource_fingerprint" {+ column "value" {+ type = "Float64"+ }+ column "count" {type = "UInt64"- default = "0"+ default = "1"}- column "attribute_key" {- type = "LowCardinality(String)"+ column "histogram_bounds" {+ type = "Array(Float64)"}- column "attribute_value" {- type = "String"+ column "histogram_counts" {+ type = "Array(UInt64)"}- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"+ column "unit" {+ type = "LowCardinality(String)"}- column "attribute_type" {+ column "aggregation_temporality" {type = "LowCardinality(String)"}- index "idx_attribute_key" {- expr = "attribute_key"- type = "bloom_filter(0.01)"- granularity = 1+ column "is_monotonic" {+ type = "Bool"+ default = "false"}- index "idx_attribute_value" {- expr = "attribute_value"- type = "bloom_filter(0.01)"- granularity = 1+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"}- index "idx_attribute_key_n3" {- expr = "attribute_key"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 1+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"}- index "idx_attribute_value_n3" {- expr = "attribute_value"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 1+ column "instrumentation_scope" {+ type = "String"}- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.metric_attributes"- replica_name = "{replica}"+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ }+ column "time_minute" {+ type = "DateTime"+ alias = "toStartOfMinute(timestamp)"+ }+ column "attributes" {+ type = "Map(String, String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ engine "distributed" {+ cluster_name = "logs"+ remote_database = "posthog"+ remote_table = "metrics1"}}- materialized_view "metrics1_to_metric_attributes" {- to_table = "posthog.metric_attributes"- query = file("sql/metrics1_to_metric_attributes.sql")- column "team_id" {- type = "Int32"++ table "metrics1" {+ order_by = ["team_id", "time_bucket", "service_name", "metric_name", "resource_fingerprint", "timestamp"]+ partition_by = "toDate(timestamp)"+ settings = {+ index_granularity = "8192"+ index_granularity_bytes = "104857600"+ ttl_only_drop_parts = "1"}column "time_bucket" {- type = "DateTime64(0)"+ type = "DateTime"+ materialized = "toStartOfDay(timestamp)"}- column "service_name" {- type = "LowCardinality(String)"+ column "uuid" {+ type = "String"}- column "resource_fingerprint" {- type = "UInt64"+ column "team_id" {+ type = "Int32"}- column "attribute_key" {- type = "LowCardinality(String)"+ column "trace_id" {+ type = "String"}- column "attribute_value" {+ column "span_id" {type = "String"}- column "attribute_type" {- type = "LowCardinality(String)"+ column "trace_flags" {+ type = "Int32"}- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"+ column "timestamp" {+ type = "DateTime64(6)"}- }- materialized_view "metrics1_to_resource_attributes" {- to_table = "posthog.metric_attributes"- query = file("sql/metrics1_to_resource_attributes.sql")- column "team_id" {- type = "Int32"+ column "observed_timestamp" {+ type = "DateTime64(6)"}- column "time_bucket" {- type = "DateTime64(0)"+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"}column "service_name" {type = "LowCardinality(String)"}- column "resource_fingerprint" {- type = "UInt64"+ column "metric_name" {+ type = "LowCardinality(String)"}- column "attribute_key" {+ column "metric_type" {type = "LowCardinality(String)"}- column "attribute_value" {- type = "String"- }- column "attribute_type" {- type = "LowCardinality(String)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- }- table "metrics_kafka_metrics" {- order_by = ["_topic", "_partition"]- settings = {- index_granularity = "8192"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"- }- column "max_offset" {- type = "SimpleAggregateFunction(max, UInt64)"- }- column "max_observed_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_timestamp" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_created_at" {- type = "SimpleAggregateFunction(max, DateTime64(9))"- }- column "max_lag" {- type = "SimpleAggregateFunction(max, UInt64)"- }- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/logs/{shard}/posthog.metrics_kafka_metrics"- replica_name = "{replica}"- }- }- table "log_attributes3" {- order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value", "severity_text"]- partition_by = "toDate(original_expiry_time_bucket)"- ttl = "original_expiry_time_bucket"- settings = {- deduplicate_merge_projection_mode = "drop"- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- codec = "ZSTD(5)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "attribute_type" {- type = "LowCardinality(String)"- default = "'log'"- }- column "original_expiry_time_bucket" {- type = "DateTime"- default = "now()"- }- column "severity_text" {- type = "LowCardinality(String)"- }- index "idx_attribute_key" {- expr = "attribute_key"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attribute_value" {- expr = "attribute_value"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attribute_key_n3" {- expr = "attribute_key"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 1- }- index "idx_attribute_value_n3" {- expr = "attribute_value"- type = "ngrambf_v1(3, 32768, 3, 0)"- granularity = 1- }- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.log_attributes3"- replica_name = "{replica}-{shard}"- }- }- table "metric_samples" {- column "team_id" {- type = "Int32"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "series_fingerprint" {- type = "UInt64"- codec = "DoubleDelta"- }- column "timestamp" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- column "value" {- type = "Float64"- codec = "Gorilla(8)"- }- column "count" {- type = "UInt64"- default = "1"- }- column "histogram_bounds" {- type = "Array(Float64)"- }- column "histogram_counts" {- type = "Array(UInt64)"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "metric_samples1"- }- }- table "metric_samples1" {- order_by = ["team_id", "metric_name", "series_fingerprint", "timestamp"]- partition_by = "toDate(timestamp)"- ttl = "toDateTime(timestamp) + toIntervalDay(30)"- settings = {- index_granularity = "8192"- ttl_only_drop_parts = "1"- }- column "team_id" {- type = "Int32"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "series_fingerprint" {- type = "UInt64"- codec = "DoubleDelta"- }- column "timestamp" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }column "value" {- type = "Float64"- codec = "Gorilla(8)"+ type = "Float64"}column "count" {type = "UInt64"@@ -725,87 +462,6 @@ database "posthog" {column "histogram_counts" {type = "Array(UInt64)"}- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- index "idx_trace_id_bf" {- expr = "trace_id"- type = "bloom_filter(0.01)"- granularity = 1- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.metric_samples1"- replica_name = "{replica}-{shard}"- }- }- table "metric_series" {- column "team_id" {- type = "Int32"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "series_fingerprint" {- type = "UInt64"- codec = "DoubleDelta"- }- column "metric_type" {- type = "LowCardinality(String)"- }- column "unit" {- type = "LowCardinality(String)"- }- column "aggregation_temporality" {- type = "LowCardinality(String)"- }- column "is_monotonic" {- type = "Bool"- default = "false"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- }- column "last_seen" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "metric_series1"- }- }- table "metric_series1" {- order_by = ["team_id", "metric_name", "series_fingerprint"]- ttl = "toDateTime(last_seen) + toIntervalDay(90)"- settings = {- index_granularity = "8192"- }- column "team_id" {- type = "Int32"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "series_fingerprint" {- type = "UInt64"- codec = "DoubleDelta"- }- column "metric_type" {- type = "LowCardinality(String)"- }column "unit" {type = "LowCardinality(String)"}@@ -816,197 +472,6 @@ database "posthog" {type = "Bool"default = "false"}- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_attributes" {- type = "Map(LowCardinality(String), String)"- }- column "attributes" {- type = "Map(LowCardinality(String), String)"- }- column "last_seen" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- index "idx_service_set" {- expr = "service_name"- type = "set(1000)"- granularity = 1- }- index "idx_attr_keys" {- expr = "mapKeys(attributes)"- type = "bloom_filter(0.01)"- granularity = 1- }- index "idx_attr_values" {- expr = "mapValues(attributes)"- type = "bloom_filter(0.01)"- granularity = 1- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.metric_series1"- replica_name = "{replica}-{shard}"- version_column = "last_seen"- }- }- materialized_view "logs34_to_log_attributes3" {- to_table = "posthog.log_attributes3"- query = file("sql/logs34_to_log_attributes3.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 "severity_text" {- 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")-- 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 "severity_text" {- type = "LowCardinality(String)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- }- table "log_attributes_distributed" {- column "team_id" {- type = "Int32"- }- column "time_bucket" {- type = "DateTime64(0)"- }- column "service_name" {- type = "LowCardinality(String)"- }- column "resource_fingerprint" {- type = "UInt64"- default = "0"- }- column "attribute_key" {- type = "LowCardinality(String)"- }- column "attribute_value" {- type = "String"- codec = "ZSTD(5)"- }- column "attribute_count" {- type = "SimpleAggregateFunction(sum, UInt64)"- }- column "attribute_type" {- type = "LowCardinality(String)"- default = "'log'"- }- column "original_expiry_time_bucket" {- type = "DateTime"- default = "now()"- }- column "severity_text" {- type = "LowCardinality(String)"- }- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "log_attributes3"- }- }- table "logs_distributed" {- column "time_bucket" {- type = "DateTime"- materialized = "toStartOfDay(timestamp)"- }- column "original_expiry_timestamp" {- type = "DateTime64(6)"- }- column "uuid" {- type = "String"- }- column "team_id" {- type = "Int32"- }- column "trace_id" {- type = "String"- }- column "span_id" {- type = "String"- }- column "trace_flags" {- type = "Int32"- }- column "timestamp" {- type = "DateTime64(6)"- codec = "DoubleDelta"- }- column "observed_timestamp" {- type = "DateTime64(6)"- }- column "created_at" {- type = "DateTime64(6)"- materialized = "now()"- }- column "body" {- type = "String"- }- column "severity_text" {- type = "LowCardinality(String)"- }- column "severity_number" {- type = "Int32"- }- column "service_name" {- type = "LowCardinality(String)"- }column "resource_attributes" {type = "Map(LowCardinality(String), String)"}@@ -1017,58 +482,48 @@ database "posthog" {column "instrumentation_scope" {type = "String"}- column "event_name" {- type = "String"- }column "attributes_map_str" {type = "Map(LowCardinality(String), String)"}- column "level" {- type = "String"- alias = "severity_text"- }- column "mat_body_ipv4_matches" {- type = "Array(String)"- alias = "extractAll(body, '(\\\\d\\\\.((25[0-5]|(2[0-4]|1(0, 1)[0-9])(0, 1)[0-9])\\\\.)(2, 2)([0-9]))')"+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"}column "time_minute" {type = "DateTime"alias = "toStartOfMinute(timestamp)"}column "attributes" {- type = "Map(LowCardinality(String), String)"+ type = "Map(String, String)"alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"}- column "attributes_map_float" {- type = "Map(LowCardinality(String), Float64)"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"- }- column "attributes_map_datetime" {- type = "Map(LowCardinality(String), DateTime64(6))"- materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"- }- column "_partition" {- type = "UInt32"- }- column "_topic" {- type = "String"+ index "idx_metric_name_set" {+ expr = "metric_name"+ type = "set(100)"+ granularity = 1}- column "_offset" {- type = "UInt64"+ index "idx_metric_type_set" {+ expr = "metric_type"+ type = "set(10)"+ granularity = 1}- column "_bytes_uncompressed" {- type = "UInt64"+ index "idx_attributes_str_keys" {+ expr = "mapKeys(attributes_map_str)"+ type = "bloom_filter(0.01)"+ granularity = 1}- column "_bytes_compressed" {- type = "UInt64"+ index "idx_attributes_str_values" {+ expr = "mapValues(attributes_map_str)"+ type = "bloom_filter(0.001)"+ granularity = 1}- column "_record_count" {- type = "UInt64"+ index "idx_observed_minmax" {+ expr = "observed_timestamp"+ type = "minmax"+ granularity = 1}- engine "distributed" {- cluster_name = "logs"- remote_database = "posthog"- remote_table = "logs34"+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/logs/{shard}/posthog.metrics1"+ replica_name = "{replica}"}}}diff --git a/posthog/clickhouse/hcl/roles/logs/prod-eu/sql/trace_span_to_attributes.sql b/posthog/clickhouse/hcl/roles/logs/traces/sql/trace_span_to_attributes.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/prod-eu/sql/trace_span_to_attributes.sqlrename to posthog/clickhouse/hcl/roles/logs/traces/sql/trace_span_to_attributes.sqldiff --git a/posthog/clickhouse/hcl/roles/logs/prod-eu/sql/trace_span_to_resource_attributes.sql b/posthog/clickhouse/hcl/roles/logs/traces/sql/trace_span_to_resource_attributes.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/prod-eu/sql/trace_span_to_resource_attributes.sqlrename to posthog/clickhouse/hcl/roles/logs/traces/sql/trace_span_to_resource_attributes.sqldiff --git a/posthog/clickhouse/hcl/roles/logs/prod-eu/sql/trace_span_to_span_attributes.sql b/posthog/clickhouse/hcl/roles/logs/traces/sql/trace_span_to_span_attributes.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/prod-eu/sql/trace_span_to_span_attributes.sqlrename to posthog/clickhouse/hcl/roles/logs/traces/sql/trace_span_to_span_attributes.sqldiff --git a/posthog/clickhouse/hcl/roles/logs/traces/tables.hcl b/posthog/clickhouse/hcl/roles/logs/traces/tables.hclnew file mode 100644index 000000000000..bf21a1535473--- /dev/null+++ b/posthog/clickhouse/hcl/roles/logs/traces/tables.hcl@@ -0,0 +1,570 @@+# The trace-spans suite, hosted by the local logs node and both prod logs envs+# (dev has no traces). Env deltas are patch_table blocks in the env layers; the+# ingest MV (kafka_trace_spans_avro_mv) stays per-env until hclexp supports+# overriding materialized views.+database "posthog" {+ table "trace_attributes" {+ order_by = ["team_id", "attribute_type", "time_bucket", "resource_fingerprint", "attribute_key", "attribute_value"]+ partition_by = "toDate(original_expiry_time_bucket)"+ ttl = "original_expiry_time_bucket"+ settings = {+ index_granularity = "8192"+ }+ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ index "idx_attribute_key" {+ expr = "attribute_key"+ type = "bloom_filter(0.01)"+ granularity = 4+ }+ index "idx_attribute_value" {+ expr = "attribute_value"+ type = "bloom_filter(0.01)"+ granularity = 4+ }+ index "idx_attribute_key_n3" {+ expr = "attribute_key"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 4+ }+ index "idx_attribute_value_n3" {+ expr = "attribute_value"+ type = "ngrambf_v1(3, 32768, 3, 0)"+ granularity = 4+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.trace_attributes"+ replica_name = "{replica}-{shard}"+ }+ }++ table "trace_attributes_distributed" {+ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "time_bucket" {+ type = "DateTime64(0)"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ default = "0"+ }+ column "attribute_key" {+ type = "LowCardinality(String)"+ }+ column "attribute_value" {+ type = "String"+ }+ column "attribute_type" {+ type = "LowCardinality(String)"+ }+ column "attribute_count" {+ type = "SimpleAggregateFunction(sum, UInt64)"+ }+ engine "distributed" {+ cluster_name = "posthog_single_shard"+ remote_database = "posthog"+ remote_table = "trace_attributes"+ }+ }++ table "kafka_trace_spans_avro" {+ column "uuid" {+ type = "String"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "parent_span_id" {+ type = "String"+ }+ column "trace_state" {+ type = "String"+ }+ column "name" {+ type = "String"+ }+ column "kind" {+ type = "Int32"+ }+ column "flags" {+ type = "Int32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "end_time" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "service_name" {+ type = "String"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "dropped_attributes_count" {+ type = "Int32"+ }+ column "events" {+ type = "Array(String)"+ }+ column "dropped_events_count" {+ type = "Int32"+ }+ column "links" {+ type = "Array(String)"+ }+ column "dropped_links_count" {+ type = "Int32"+ }+ column "status_code" {+ type = "Int32"+ }+ engine "kafka" {+ broker_list = "warpstream_traces"+ topic_list = "kafka_topic_list = 'clickhouse_traces'"+ group_name = "kafka_group_name = 'clickhouse-traces-avro'"+ format = "kafka_format = 'Avro'"+ num_consumers = 8+ skip_broken_messages = 100+ poll_timeout_ms = 3000+ poll_max_batch_size = 1000+ thread_per_consumer = true+ }+ }++ table "trace_spans" {+ order_by = ["team_id", "time_bucket", "service_name", "resource_fingerprint", "status_code", "name", "timestamp"]+ partition_by = "toDate(original_expiry_timestamp)"+ ttl = "original_expiry_timestamp"+ settings = {+ allow_part_offset_column_in_projections = "1"+ index_granularity = "8192"+ index_granularity_bytes = "104857600"+ map_serialization_version = "with_buckets"+ ttl_only_drop_parts = "1"+ }+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }+ column "uuid" {+ type = "String"+ }+ column "team_id" {+ type = "Int32"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "parent_span_id" {+ type = "String"+ }+ column "is_root_span" {+ type = "Bool"+ materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"+ }+ column "trace_state" {+ type = "String"+ }+ column "name" {+ type = "LowCardinality(String)"+ }+ column "kind" {+ type = "Int8"+ }+ column "flags" {+ type = "UInt32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "end_time" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"+ }+ column "duration_nano" {+ type = "UInt64"+ materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"+ }+ column "status_code" {+ type = "Int16"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ }+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ }+ column "dropped_attributes_count" {+ type = "UInt32"+ }+ column "dropped_events_count" {+ type = "UInt32"+ }+ column "dropped_links_count" {+ type = "UInt32"+ }+ column "events" {+ type = "Array(String)"+ }+ column "links" {+ type = "Array(String)"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "_bytes_uncompressed" {+ type = "UInt64"+ }+ column "_bytes_compressed" {+ type = "UInt64"+ }+ column "_record_count" {+ type = "UInt64"+ }+ index "idx_name" {+ expr = "name"+ type = "ngrambf_v1(4, 5000, 2, 0)"+ granularity = 16+ }+ index "idx_kind" {+ expr = "kind"+ type = "minmax"+ granularity = 4+ }+ index "idx_duration" {+ expr = "duration_nano"+ type = "minmax"+ granularity = 1+ }+ index "idx_status_code" {+ expr = "status_code"+ type = "minmax"+ granularity = 1+ }+ index "idx_timestamp_minmax" {+ expr = "timestamp"+ type = "minmax"+ granularity = 1+ }+ index "idx_observed_minmax" {+ expr = "observed_timestamp"+ type = "minmax"+ granularity = 1+ }+ index "idx_attributes_str_keys" {+ expr = "mapKeys(attributes_map_str)"+ type = "bloom_filter(0.01)"+ granularity = 16+ }+ index "idx_attributes_str_values" {+ expr = "mapValues(attributes_map_str)"+ type = "bloom_filter(0.001)"+ granularity = 16+ }+ index "idx_trace_bloom_part" {+ expr = "trace_id"+ type = "bloom_filter(0.00001)"+ granularity = 99999+ }+ index "idx_span_id_bloom_part" {+ expr = "span_id"+ type = "bloom_filter(0.00001)"+ granularity = 99999+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/logs/{shard}/posthog.trace_spans"+ replica_name = "{replica}"+ }+ }++ table "trace_spans_distributed" {+ column "time_bucket" {+ type = "DateTime"+ materialized = "toStartOfInterval(timestamp, toIntervalHour(4))"+ }+ column "original_expiry_timestamp" {+ type = "DateTime64(6)"+ }+ column "uuid" {+ type = "String"+ }+ column "team_id" {+ type = "Int32"+ }+ column "trace_id" {+ type = "String"+ }+ column "span_id" {+ type = "String"+ }+ column "parent_span_id" {+ type = "String"+ }+ column "is_root_span" {+ type = "Bool"+ materialized = "replaceAll(trimRight(parent_span_id, '='), 'A', '') = ''"+ }+ column "trace_state" {+ type = "String"+ }+ column "name" {+ type = "LowCardinality(String)"+ }+ column "kind" {+ type = "Int8"+ }+ column "flags" {+ type = "UInt32"+ }+ column "timestamp" {+ type = "DateTime64(6)"+ }+ column "end_time" {+ type = "DateTime64(6)"+ }+ column "observed_timestamp" {+ type = "DateTime64(6)"+ }+ column "created_at" {+ type = "DateTime64(6)"+ materialized = "now()"+ }+ column "duration_nano" {+ type = "UInt64"+ materialized = "toUInt64(dateDiff('microsecond', timestamp, end_time)) * 1000"+ }+ column "status_code" {+ type = "Int16"+ }+ column "service_name" {+ type = "LowCardinality(String)"+ }+ column "resource_attributes" {+ type = "Map(LowCardinality(String), String)"+ }+ column "resource_fingerprint" {+ type = "UInt64"+ materialized = "cityHash64(resource_attributes)"+ }+ column "instrumentation_scope" {+ type = "String"+ }+ column "attributes_map_str" {+ type = "Map(LowCardinality(String), String)"+ }+ column "attributes" {+ type = "Map(LowCardinality(String), String)"+ alias = "mapApply((k, v) -> (left(k, -5), v), attributes_map_str)"+ }+ column "attributes_map_float" {+ type = "Map(LowCardinality(String), Float64)"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__float'), toFloat64OrNull(v)), attributes_map_str))"+ }+ column "attributes_map_datetime" {+ type = "Map(LowCardinality(String), DateTime64(6))"+ materialized = "mapFilter((k, v) -> (v IS NOT NULL), mapApply((k, v) -> (concat(left(k, -5), '__datetime'), parseDateTimeBestEffortOrNull(v, 6)), attributes_map_str))"+ }+ column "dropped_attributes_count" {+ type = "UInt32"+ }+ column "dropped_events_count" {+ type = "UInt32"+ }+ column "dropped_links_count" {+ type = "UInt32"+ }+ column "events" {+ type = "Array(String)"+ }+ column "links" {+ type = "Array(String)"+ }+ engine "distributed" {+ cluster_name = "logs"+ remote_database = "posthog"+ remote_table = "trace_spans"+ }+ }++ materialized_view "trace_span_to_attributes" {+ to_table = "posthog.trace_attributes"+ query = file("sql/trace_span_to_attributes.sql")+ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "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 "trace_span_to_resource_attributes" {+ to_table = "posthog.trace_attributes"+ query = file("sql/trace_span_to_resource_attributes.sql")+ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "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 "trace_span_to_span_attributes" {+ to_table = "posthog.trace_attributes"+ query = file("sql/trace_span_to_span_attributes.sql")+ column "team_id" {+ type = "Int32"+ }+ column "original_expiry_time_bucket" {+ type = "DateTime64(0)"+ }+ column "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)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_spans_to_kafka_metrics_mv.sql b/posthog/clickhouse/hcl/roles/logs/traces_kafka_metrics/sql/trace_spans_to_kafka_metrics_mv.sqlsimilarity index 100%rename from posthog/clickhouse/hcl/roles/logs/prod-us/sql/trace_spans_to_kafka_metrics_mv.sqlrename to posthog/clickhouse/hcl/roles/logs/traces_kafka_metrics/sql/trace_spans_to_kafka_metrics_mv.sqldiff --git a/posthog/clickhouse/hcl/roles/logs/traces_kafka_metrics/tables.hcl b/posthog/clickhouse/hcl/roles/logs/traces_kafka_metrics/tables.hclnew file mode 100644index 000000000000..0bfa5f221dc6--- /dev/null+++ b/posthog/clickhouse/hcl/roles/logs/traces_kafka_metrics/tables.hcl@@ -0,0 +1,61 @@+# Kafka-consumer lag metrics for the trace-spans ingest, present on the local+# logs node and prod-us only.+database "posthog" {+ table "trace_spans_kafka_metrics" {+ order_by = ["_topic", "_partition"]+ settings = {+ index_granularity = "8192"+ }+ column "_partition" {+ type = "UInt32"+ }+ column "_topic" {+ type = "String"+ }+ column "max_offset" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ column "max_observed_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_timestamp" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_created_at" {+ type = "SimpleAggregateFunction(max, DateTime64(9))"+ }+ column "max_lag" {+ type = "SimpleAggregateFunction(max, UInt64)"+ }+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/noshard/posthog.trace_spans_kafka_metrics"+ replica_name = "{replica}-{shard}"+ }+ }++ materialized_view "trace_spans_to_kafka_metrics_mv" {+ to_table = "posthog.trace_spans_kafka_metrics"+ query = file("sql/trace_spans_to_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))"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/ops/prod-eu/ops.hcl b/posthog/clickhouse/hcl/roles/ops/prod-eu/ops.hclindex f06c2c155774..602092f25475 100644--- a/posthog/clickhouse/hcl/roles/ops/prod-eu/ops.hcl+++ b/posthog/clickhouse/hcl/roles/ops/prod-eu/ops.hcl@@ -7,96 +7,4 @@# Resolve with: hclexp load -layer <base>,<...>database "posthog" {- table "events_main" {- column "uuid" {- type = "UUID"- }- column "event" {- type = "String"- }- column "properties" {- type = "String"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "elements_chain" {- type = "String"- }- column "created_at" {- type = "DateTime64(6, 'UTC')"- }- column "person_id" {- type = "UUID"- }- column "person_created_at" {- type = "DateTime64(3)"- }- column "person_properties" {- type = "String"- }- column "group0_properties" {- type = "String"- }- column "group1_properties" {- type = "String"- }- column "group2_properties" {- type = "String"- }- column "group3_properties" {- type = "String"- }- column "group4_properties" {- type = "String"- }- column "group0_created_at" {- type = "DateTime64(3)"- }- column "group1_created_at" {- type = "DateTime64(3)"- }- column "group2_created_at" {- type = "DateTime64(3)"- }- column "group3_created_at" {- type = "DateTime64(3)"- }- column "group4_created_at" {- type = "DateTime64(3)"- }- column "person_mode" {- type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "inserted_at" {- type = "DateTime64(6, 'UTC')"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_events"- sharding_key = "sipHash64(distinct_id)"- }- }- # Shape inherited from sharded_tophog_base (prod layer); prod-eu writes to the- # tophog keeper path.- table "sharded_tophog" {- extend = "sharded_tophog_base"- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/ops/{shard}/posthog.tophog"- replica_name = "{replica}"- }- }}diff --git a/posthog/clickhouse/hcl/roles/ops/prod-eu/patches.hcl b/posthog/clickhouse/hcl/roles/ops/prod-eu/patches.hclnew file mode 100644index 000000000000..35ccacb3b8b5--- /dev/null+++ b/posthog/clickhouse/hcl/roles/ops/prod-eu/patches.hcl@@ -0,0 +1,9 @@+# prod-eu deltas to coshared base objects.+database "posthog" {+ patch_table "sharded_tophog" {+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/ops/{shard}/posthog.tophog"+ replica_name = "{replica}"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/ops/prod-us/ops.hcl b/posthog/clickhouse/hcl/roles/ops/prod-us/ops.hclindex da659cbd0568..0d7af9e5db8d 100644--- a/posthog/clickhouse/hcl/roles/ops/prod-us/ops.hcl+++ b/posthog/clickhouse/hcl/roles/ops/prod-us/ops.hcl@@ -12,179 +12,4 @@ database "posthog" {type = "JSON(max_dynamic_paths=0, OSCPUVirtualTimeMicroseconds UInt64, ReadBufferFromS3Bytes UInt64, RealTimeMicroseconds UInt64, S3AbortMultipartUpload UInt64, S3Clients UInt64, S3CompleteMultipartUpload UInt64, S3CopyObject UInt64, S3CreateMultipartUpload UInt64, S3DeleteObjects UInt64, S3GetObject UInt64, S3GetObjectAttributes UInt64, S3HeadObject UInt64, S3ListObjects UInt64, S3PutObject UInt64, S3UploadPart UInt64, S3UploadPartCopy UInt64, WriteBufferFromS3Bytes UInt64)"}}- table "events_main" {- column "uuid" {- type = "UUID"- }- column "event" {- type = "String"- }- column "properties" {- type = "String"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "elements_chain" {- type = "String"- }- column "created_at" {- type = "DateTime64(6, 'UTC')"- }- column "person_id" {- type = "UUID"- }- column "person_created_at" {- type = "DateTime64(3)"- }- column "person_properties" {- type = "String"- }- column "group0_properties" {- type = "String"- }- column "group1_properties" {- type = "String"- }- column "group2_properties" {- type = "String"- }- column "group3_properties" {- type = "String"- }- column "group4_properties" {- type = "String"- }- column "group0_created_at" {- type = "DateTime64(3)"- }- column "group1_created_at" {- type = "DateTime64(3)"- }- column "group2_created_at" {- type = "DateTime64(3)"- }- column "group3_created_at" {- type = "DateTime64(3)"- }- column "group4_created_at" {- type = "DateTime64(3)"- }- column "person_mode" {- type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "inserted_at" {- type = "DateTime64(6, 'UTC')"- }- engine "distributed" {- cluster_name = "posthog"- remote_database = "posthog"- remote_table = "sharded_events"- sharding_key = "sipHash64(distinct_id)"- }- }- table "events_recent" {- column "uuid" {- type = "UUID"- }- column "event" {- type = "String"- }- column "properties" {- type = "String"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "elements_chain" {- type = "String"- }- column "created_at" {- type = "DateTime64(6, 'UTC')"- }- column "person_id" {- type = "UUID"- }- column "person_created_at" {- type = "DateTime64(3)"- }- column "person_properties" {- type = "String"- }- column "group0_properties" {- type = "String"- }- column "group1_properties" {- type = "String"- }- column "group2_properties" {- type = "String"- }- column "group3_properties" {- type = "String"- }- column "group4_properties" {- type = "String"- }- column "group0_created_at" {- type = "DateTime64(3)"- }- column "group1_created_at" {- type = "DateTime64(3)"- }- column "group2_created_at" {- type = "DateTime64(3)"- }- column "group3_created_at" {- type = "DateTime64(3)"- }- column "group4_created_at" {- type = "DateTime64(3)"- }- column "person_mode" {- type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "inserted_at" {- type = "DateTime64(6, 'UTC')"- }- engine "distributed" {- cluster_name = "batch_exports"- remote_database = "posthog"- remote_table = "sharded_events_recent"- sharding_key = "sipHash64(distinct_id)"- }- }- # Shape inherited from sharded_tophog_base (prod layer); prod-us writes to the- # tophog_new keeper path.- table "sharded_tophog" {- extend = "sharded_tophog_base"- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/ops/{shard}/posthog.tophog_new"- replica_name = "{replica}"- }- }}diff --git a/posthog/clickhouse/hcl/roles/ops/prod-us/patches.hcl b/posthog/clickhouse/hcl/roles/ops/prod-us/patches.hclnew file mode 100644index 000000000000..091f0cb9cbf2--- /dev/null+++ b/posthog/clickhouse/hcl/roles/ops/prod-us/patches.hcl@@ -0,0 +1,9 @@+# prod-us deltas to coshared base objects.+database "posthog" {+ patch_table "sharded_tophog" {+ engine "replicated_merge_tree" {+ zoo_path = "/clickhouse/tables/ops/{shard}/posthog.tophog_new"+ replica_name = "{replica}"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/ops/prod/events.hcl b/posthog/clickhouse/hcl/roles/ops/prod/events.hclnew file mode 100644index 000000000000..1751a120aebf--- /dev/null+++ b/posthog/clickhouse/hcl/roles/ops/prod/events.hcl@@ -0,0 +1,86 @@+# The events_main reader, identical on both prod OPS envs.+database "posthog" {+ table "events_main" {+ column "uuid" {+ type = "UUID"+ }+ column "event" {+ type = "String"+ }+ column "properties" {+ type = "String"+ }+ column "timestamp" {+ type = "DateTime64(6, 'UTC')"+ }+ column "team_id" {+ type = "Int64"+ }+ column "distinct_id" {+ type = "String"+ }+ column "elements_chain" {+ type = "String"+ }+ column "created_at" {+ type = "DateTime64(6, 'UTC')"+ }+ column "person_id" {+ type = "UUID"+ }+ column "person_created_at" {+ type = "DateTime64(3)"+ }+ column "person_properties" {+ type = "String"+ }+ column "group0_properties" {+ type = "String"+ }+ column "group1_properties" {+ type = "String"+ }+ column "group2_properties" {+ type = "String"+ }+ column "group3_properties" {+ type = "String"+ }+ column "group4_properties" {+ type = "String"+ }+ column "group0_created_at" {+ type = "DateTime64(3)"+ }+ column "group1_created_at" {+ type = "DateTime64(3)"+ }+ column "group2_created_at" {+ type = "DateTime64(3)"+ }+ column "group3_created_at" {+ type = "DateTime64(3)"+ }+ column "group4_created_at" {+ type = "DateTime64(3)"+ }+ column "person_mode" {+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"+ }+ column "_timestamp" {+ type = "DateTime"+ }+ column "_offset" {+ type = "UInt64"+ }+ column "inserted_at" {+ type = "DateTime64(6, 'UTC')"+ }+ engine "distributed" {+ cluster_name = "posthog"+ remote_database = "posthog"+ remote_table = "sharded_events"+ sharding_key = "sipHash64(distinct_id)"+ }+ }+}diff --git a/posthog/clickhouse/hcl/roles/ops/prod/metrics.hcl b/posthog/clickhouse/hcl/roles/ops/prod/metrics.hclindex 0878d20cc8c4..84347af43f43 100644--- a/posthog/clickhouse/hcl/roles/ops/prod/metrics.hcl+++ b/posthog/clickhouse/hcl/roles/ops/prod/metrics.hcl@@ -1,45 +1,6 @@# OPS role, prod only — metrics suite + sharded_tophog abstract.database "posthog" {- table "sharded_tophog_base" {- abstract = true- order_by = ["pipeline", "lane", "metric", "timestamp", "key"]- partition_by = "toYYYYMMDD(timestamp)"- ttl = "toDate(timestamp) + toIntervalDay(30)"- settings = {- index_granularity = "8192"- ttl_only_drop_parts = "1"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "metric" {- type = "LowCardinality(String)"- }- column "type" {- type = "LowCardinality(String)"- default = "'sum'"- }- column "key" {- type = "Map(LowCardinality(String), String)"- }- column "value" {- type = "Float64"- }- column "count" {- type = "UInt64"- default = "0"- }- column "pipeline" {- type = "LowCardinality(String)"- }- column "lane" {- type = "LowCardinality(String)"- }- column "labels" {- type = "Map(LowCardinality(String), String)"- }- }table "metrics_exemplars" {order_by = ["team_id", "id", "timestamp"]partition_by = "toYYYYMMDD(timestamp)"diff --git a/posthog/clickhouse/hcl/roles/ops/shared/core.hcl b/posthog/clickhouse/hcl/roles/ops/shared/core.hclindex 9b62dafaaaa8..5c79f165c43c 100644--- a/posthog/clickhouse/hcl/roles/ops/shared/core.hcl+++ b/posthog/clickhouse/hcl/roles/ops/shared/core.hcl@@ -513,7 +513,4 @@ database "posthog" {replica_name = "{replica}-{shard}"}}- view "custom_metrics" {- query = file("sql/custom_metrics.sql")- }}diff --git a/posthog/clickhouse/hcl/roles/ops/shared/sql/custom_metrics.sql b/posthog/clickhouse/hcl/roles/ops/shared/sql/custom_metrics.sqldeleted file mode 100644index 1fc4f30cf4c7..000000000000--- a/posthog/clickhouse/hcl/roles/ops/shared/sql/custom_metrics.sql+++ /dev/null@@ -1,70 +0,0 @@-SELECT * REPLACE(toFloat64(value) AS value)-FROM posthog.custom_metrics_test-UNION ALL-SELECT * REPLACE(toFloat64(value) AS value)-FROM posthog.custom_metrics_replication_queue-UNION ALL-SELECT * REPLACE(toFloat64(value) AS value)-FROM posthog.custom_metrics_server_crash-UNION ALL-SELECT *-FROM posthog.custom_metrics_table_sizes-UNION ALL-SELECT * REPLACE(toFloat64(value) AS value)-FROM posthog.custom_metrics_part_counts-UNION ALL-SELECT * REPLACE(toFloat64(value) AS value)-FROM posthog.custom_metrics_dictionaries-UNION ALL-SELECT- 'ClickHouseCustomMetric_S3DiskBytesUsed' AS name,- map('instance', hostname(), 'disk', disk_name) AS labels,- toFloat64(sum(bytes_on_disk)) AS value,- 'Bytes currently used by ClickHouse parts on S3-backed disks on this node' AS help,- 'gauge' AS type-FROM system.parts-WHERE disk_name IN ('s3disk', 'cache')-GROUP BY- disk_name-UNION ALL-SELECT- 'ClickHouseCustomMetric_MergeFailures15m' AS name,- map('instance', hostname()) AS labels,- toFloat64(count()) AS value,- 'Number of failed merge operations in the last 15 minutes' AS help,- 'gauge' AS type-FROM system.part_log-WHERE- (event_time >= (now() - toIntervalMinute(15)))-AND- (event_type = 'MergeParts')-AND- (error > 0)-AND- (merge_reason != 'NotAMerge')-AND- (error != 40)-UNION ALL-SELECT- 'ClickHouseCustomMetric_MergeRetriesMaxPerTable15m' AS name,- map('instance', hostname()) AS labels,- toFloat64(max(cnt)) AS value,- 'Max failed merge retries for any single table in the last 15 minutes' AS help,- 'gauge' AS type-FROM- (- SELECT count() AS cnt- FROM system.part_log- WHERE- (event_time >= (now() - toIntervalMinute(15)))- AND- (event_type = 'MergeParts')- AND- (error > 0)- AND- (merge_reason != 'NotAMerge')- AND- (error != 40)- GROUP BY- database, `table`, partition_id- )diff --git a/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hcl b/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hclindex 98fa8bafd0af..0a60c70a07f7 100644--- a/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hcl+++ b/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hcl@@ -1658,94 +1658,4 @@ database "posthog" {replica_name = "{shard}-{replica}"}}- table "writable_events_recent" {- column "uuid" {- type = "UUID"- }- column "event" {- type = "String"- }- column "properties" {- type = "String"- codec = "ZSTD(3)"- }- column "timestamp" {- type = "DateTime64(6, 'UTC')"- }- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "elements_chain" {- type = "String"- }- column "created_at" {- type = "DateTime64(6, 'UTC')"- }- column "person_id" {- type = "UUID"- }- column "person_created_at" {- type = "DateTime64(3)"- }- column "person_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group0_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group1_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group2_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group3_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group4_properties" {- type = "String"- codec = "ZSTD(3)"- }- column "group0_created_at" {- type = "DateTime64(3)"- }- column "group1_created_at" {- type = "DateTime64(3)"- }- column "group2_created_at" {- type = "DateTime64(3)"- }- column "group3_created_at" {- type = "DateTime64(3)"- }- column "group4_created_at" {- type = "DateTime64(3)"- }- column "person_mode" {- type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"- }- column "historical_migration" {- type = "Bool"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog_writable"- remote_database = "posthog"- remote_table = "sharded_events_recent"- sharding_key = "sipHash64(distinct_id)"- }- }}diff --git a/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl b/posthog/clickhouse/hcl/roles/sessions/shared/tables.hclindex d4d22028e386..2df3fad44ef6 100644--- a/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl+++ b/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl@@ -1,86 +1,6 @@database "posthog" {- table "cohortpeople" {- column "person_id" {- type = "UUID"- }- column "cohort_id" {- type = "Int64"- }- column "team_id" {- type = "Int64"- }- column "sign" {- type = "Int8"- }- column "version" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "cohortpeople"- sharding_key = "rand()"- }- }- table "person_distinct_id_overrides" {- column "team_id" {- type = "Int64"- }- column "distinct_id" {- type = "String"- }- column "person_id" {- type = "UUID"- }- column "is_deleted" {- type = "Int8"- }- column "version" {- type = "Int64"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- column "_partition" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "person_distinct_id_overrides"- sharding_key = "sipHash64(distinct_id)"- }- }- table "person_static_cohort" {- column "id" {- type = "UUID"- }- column "person_id" {- type = "UUID"- }- column "cohort_id" {- type = "Int64"- }- column "team_id" {- type = "Int64"- }- column "_timestamp" {- type = "DateTime"- }- column "_offset" {- type = "UInt64"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "person_static_cohort"- sharding_key = "rand()"- }- }table "raw_sessions" {+ override = trueorder_by = ["team_id", "toStartOfHour(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000)))", "cityHash64(session_id_v7)", "session_id_v7"]partition_by = "toYYYYMM(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000)))"sample_by = "cityHash64(session_id_v7)"@@ -249,6 +169,7 @@ database "posthog" {}}table "sessions" {+ override = trueorder_by = ["toStartOfDay(min_timestamp)", "team_id", "session_id"]partition_by = "toYYYYMM(min_timestamp)"settings = {@@ -349,66 +270,4 @@ database "posthog" {replica_name = "{shard}-{replica}"}}- table "web_pre_aggregated_teams" {- column "team_id" {- type = "UInt64"- }- column "enabled_by" {- type = "String"- default = "'system'"- }- column "version" {- type = "UInt32"- default = "toUnixTimestamp(now())"- }- engine "distributed" {- cluster_name = "posthog_single_shard"- remote_database = "posthog"- remote_table = "web_pre_aggregated_teams"- }- }- dictionary "channel_definition_dict" {- primary_key = ["domain", "kind"]- lifetime {- min = 3000- max = 3600- }- attribute "domain" {- type = "String"- }- attribute "kind" {- type = "String"- }- attribute "domain_type" {- type = "Nullable(String)"- }- attribute "type_if_paid" {- type = "Nullable(String)"- }- attribute "type_if_organic" {- type = "Nullable(String)"- }- source "clickhouse" {- user = "dict_reader"- table = "channel_definition"- }- layout "complex_key_hashed" {- }- }- dictionary "web_pre_aggregated_teams_dict" {- primary_key = ["team_id"]- lifetime {- min = 3000- max = 3600- }- attribute "team_id" {- type = "UInt64"- }- source "clickhouse" {- user = "dict_reader"- query = "SELECT team_id FROM `web_pre_aggregated_teams` FINAL WHERE version > 0"- }- layout "hashed" {- }- }}diff --git a/posthog/clickhouse/hcl/roles/shared/qla.hcl b/posthog/clickhouse/hcl/roles/shared/qla.hclindex 37350c22c33f..69c33df6dde1 100644--- a/posthog/clickhouse/hcl/roles/shared/qla.hcl+++ b/posthog/clickhouse/hcl/roles/shared/qla.hcl@@ -349,201 +349,4 @@ database "posthog" {remote_table = "sharded_query_log_archive"}}- table "writable_query_log_archive" {- column "hostname" {- type = "LowCardinality(String)"- }- column "user" {- type = "LowCardinality(String)"- }- column "query_id" {- type = "String"- }- column "initial_query_id" {- type = "String"- }- column "is_initial_query" {- type = "UInt8"- }- column "type" {- type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"- }- column "event_date" {- type = "Date"- }- column "event_time" {- type = "DateTime"- }- column "event_time_microseconds" {- type = "DateTime64(6)"- }- column "query_start_time" {- type = "DateTime"- }- column "query_start_time_microseconds" {- type = "DateTime64(6)"- }- column "query_duration_ms" {- type = "UInt64"- }- column "read_rows" {- type = "UInt64"- }- column "read_bytes" {- type = "UInt64"- }- column "written_rows" {- type = "UInt64"- }- column "written_bytes" {- type = "UInt64"- }- column "result_rows" {- type = "UInt64"- }- column "result_bytes" {- type = "UInt64"- }- column "memory_usage" {- type = "UInt64"- }- column "peak_threads_usage" {- type = "UInt64"- }- column "current_database" {- type = "LowCardinality(String)"- }- column "query" {- type = "String"- }- column "formatted_query" {- type = "String"- }- column "normalized_query_hash" {- type = "UInt64"- }- column "query_kind" {- type = "LowCardinality(String)"- }- column "exception_code" {- type = "Int32"- }- column "exception" {- type = "String"- }- column "stack_trace" {- type = "String"- }- column "team_id" {- type = "Int64"- }- column "log_comment" {- type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"- }- column "ProfileEvents" {- type = "Map(String, UInt64)"- }- engine "distributed" {- cluster_name = "ops"- remote_database = "posthog"- remote_table = "query_log_archive_buffer"- }- }- materialized_view "ops_query_log_archive_mv" {- to_table = "posthog.writable_query_log_archive"- query = file("sql/ops_query_log_archive_mv.sql")- column "hostname" {- type = "LowCardinality(String)"- }- column "user" {- type = "LowCardinality(String)"- }- column "query_id" {- type = "String"- }- column "initial_query_id" {- type = "String"- }- column "is_initial_query" {- type = "UInt8"- }- column "type" {- type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"- }- column "event_date" {- type = "Date"- }- column "event_time" {- type = "DateTime"- }- column "event_time_microseconds" {- type = "DateTime64(6)"- }- column "query_start_time" {- type = "DateTime"- }- column "query_start_time_microseconds" {- type = "DateTime64(6)"- }- column "query_duration_ms" {- type = "UInt64"- }- column "read_rows" {- type = "UInt64"- }- column "read_bytes" {- type = "UInt64"- }- column "written_rows" {- type = "UInt64"- }- column "written_bytes" {- type = "UInt64"- }- column "result_rows" {- type = "UInt64"- }- column "result_bytes" {- type = "UInt64"- }- column "memory_usage" {- type = "UInt64"- }- column "peak_threads_usage" {- type = "UInt64"- }- column "current_database" {- type = "LowCardinality(String)"- }- column "query" {- type = "String"- }- column "formatted_query" {- type = "String"- }- column "normalized_query_hash" {- type = "UInt64"- }- column "query_kind" {- type = "LowCardinality(String)"- }- column "exception_code" {- type = "Int32"- }- column "exception" {- type = "String"- }- column "stack_trace" {- type = "String"- }- column "team_id" {- type = "Int64"- }- column "log_comment" {- type = "String"- }- column "ProfileEvents" {- type = "Map(LowCardinality(String), UInt64)"- }- }}diff --git a/posthog/clickhouse/hcl/roles/shared/qla_write.hcl b/posthog/clickhouse/hcl/roles/shared/qla_write.hclnew file mode 100644index 000000000000..b56c0ad3c095--- /dev/null+++ b/posthog/clickhouse/hcl/roles/shared/qla_write.hcl@@ -0,0 +1,202 @@+# The write path of the query_log_archive suite: the Distributed writer and the+# archiving MV. Split from qla.hcl because the local logs node runs only the+# query_log_archive table itself (it composes qla.hcl as a single-file layer).+database "posthog" {+ table "writable_query_log_archive" {+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "log_comment" {+ type = "JSON(max_dynamic_paths=256, access_method LowCardinality(String), alert_config_id String, api_key_label String, api_key_mask String, batch_export_id String, chargeable Bool, client_query_id String, cohort_id Int64, `dagster.job_name` String, `dagster.run_id` String, `dagster.tags.owner` String, dashboard_id Int64, experiment_feature_flag_key String, experiment_id Int64, feature LowCardinality(String), id String, insight_id Int64, is_impersonated Bool, kind LowCardinality(String), name String, org_id String, person_on_events_mode LowCardinality(String), product LowCardinality(String), query_type LowCardinality(String), request_name String, route_id String, service_name String, session_id String, table_id String, team_id Int64, `temporal.activity_id` String, `temporal.activity_type` String, `temporal.attempt` Int64, `temporal.workflow_id` String, `temporal.workflow_namespace` String, `temporal.workflow_run_id` String, `temporal.workflow_type` String, user_id Int64, warehouse_query Bool, workflow LowCardinality(String), workload LowCardinality(String), SKIP cache_key, SKIP filter, SKIP hogql_features, SKIP http_referer, SKIP http_request_id, SKIP http_user_agent, SKIP query_settings, SKIP timings, SKIP user_email)"+ }+ column "ProfileEvents" {+ type = "Map(String, UInt64)"+ }+ engine "distributed" {+ cluster_name = "ops"+ remote_database = "posthog"+ remote_table = "query_log_archive_buffer"+ }+ }+ materialized_view "ops_query_log_archive_mv" {+ to_table = "posthog.writable_query_log_archive"+ query = file("sql/ops_query_log_archive_mv.sql")+ column "hostname" {+ type = "LowCardinality(String)"+ }+ column "user" {+ type = "LowCardinality(String)"+ }+ column "query_id" {+ type = "String"+ }+ column "initial_query_id" {+ type = "String"+ }+ column "is_initial_query" {+ type = "UInt8"+ }+ column "type" {+ type = "Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4)"+ }+ column "event_date" {+ type = "Date"+ }+ column "event_time" {+ type = "DateTime"+ }+ column "event_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_start_time" {+ type = "DateTime"+ }+ column "query_start_time_microseconds" {+ type = "DateTime64(6)"+ }+ column "query_duration_ms" {+ type = "UInt64"+ }+ column "read_rows" {+ type = "UInt64"+ }+ column "read_bytes" {+ type = "UInt64"+ }+ column "written_rows" {+ type = "UInt64"+ }+ column "written_bytes" {+ type = "UInt64"+ }+ column "result_rows" {+ type = "UInt64"+ }+ column "result_bytes" {+ type = "UInt64"+ }+ column "memory_usage" {+ type = "UInt64"+ }+ column "peak_threads_usage" {+ type = "UInt64"+ }+ column "current_database" {+ type = "LowCardinality(String)"+ }+ column "query" {+ type = "String"+ }+ column "formatted_query" {+ type = "String"+ }+ column "normalized_query_hash" {+ type = "UInt64"+ }+ column "query_kind" {+ type = "LowCardinality(String)"+ }+ column "exception_code" {+ type = "Int32"+ }+ column "exception" {+ type = "String"+ }+ column "stack_trace" {+ type = "String"+ }+ column "team_id" {+ type = "Int64"+ }+ column "log_comment" {+ type = "String"+ }+ column "ProfileEvents" {+ type = "Map(LowCardinality(String), UInt64)"+ }+ }+}