:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(clickhouse): hand the ops cloud envs to posthog-cloud-infra (#87071)
Paweł Szczurb2446dd6ec46
diff --git a/posthog/clickhouse/hcl/README.md b/posthog/clickhouse/hcl/README.mdindex b3fae93e9da1..f372f16de97d 100644--- a/posthog/clickhouse/hcl/README.md+++ b/posthog/clickhouse/hcl/README.md@@ -5,7 +5,8 @@ Source of truth for satellite ClickHouse clusters, managed declaratively withSchemas are written in HCL, **composed per node** `(env, role)`, verified againstcaptured cluster dumps, and used to generate the migration that applies a change.-Covers the satellite roles (ops, logs, aux, `ai_events`, sessions, sessionsv3, `batch_exports`) in the cloud envs (dev, prod-us, prod-eu) where each exists, plus the local `data` node and the three ingestion roles (`events`, `small`, `medium`) the multinode stack runs.+Covers the satellite roles (logs, aux, `ai_events`, sessions, sessionsv3, `batch_exports`) in the cloud envs (dev, prod-us, prod-eu) where each exists, plus the local `data` node and the three ingestion roles (`events`, `small`, `medium`) the multinode stack runs.+`ops` is local-only here: posthog-cloud-infra authors its cloud env layers and goldens, composing `roles/ops/shared` vendored from this directory.The `local-single` env models the plain dev stack, where one server hosts every role's objects under the role `all`, composed as the union of the roles the multinode stack splits across nodes.The prod data clusters carry per-env `mat_` columns, so their goldens and per-env override layers live in posthog-cloud-infra (see [The cloud side](#the-cloud-side-posthog-cloud-infra)).diff --git a/posthog/clickhouse/hcl/golden/dev/ops.hcl b/posthog/clickhouse/hcl/golden/dev/ops.hcldeleted file mode 100644index 294160fabade..000000000000--- a/posthog/clickhouse/hcl/golden/dev/ops.hcl+++ /dev/null@@ -1,1621 +0,0 @@-database "posthog" {- table "events_team_daily_stats" {- order_by = ["analysis_date", "team_id", "event"]- settings = {- index_granularity = "8192"- }- column "analysis_date" {- type = "Date"- }- column "team_id" {- type = "Int64"- }- column "event" {- type = "String"- }- column "event_count" {- type = "UInt64"- }- column "total_event_bytes" {- type = "UInt64"- }- column "min_event_bytes" {- type = "UInt64"- }- column "max_event_bytes" {- type = "UInt64"- }- column "avg_event_bytes" {- type = "Float64"- }- column "p50_event_bytes" {- type = "Float64"- }- column "p90_event_bytes" {- type = "Float64"- }- column "p95_event_bytes" {- type = "Float64"- }- column "p99_event_bytes" {- type = "Float64"- }- column "event_size_histogram" {- type = "Array(Tuple(Float64, Float64, UInt64))"- }- column "computed_at" {- type = "DateTime"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.events_team_daily_stats"- replica_name = "{replica}"- }- }-- table "prom_metrics" {- column "id" {- type = "UUID"- default = "reinterpretAsUUID(sipHash128(metric_name, all_tags))"- }- column "timestamp" {- type = "DateTime64(3)"- }- column "value" {- type = "Float64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "tags" {- type = "Map(LowCardinality(String), String)"- }- column "all_tags" {- type = "Map(String, String)"- }- column "min_time" {- type = "Nullable(DateTime64(3))"- }- column "max_time" {- type = "Nullable(DateTime64(3))"- }- column "metric_family_name" {- type = "String"- }- column "type" {- type = "String"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- engine "time_series" {- samples {- target = "posthog.prom_metrics_data"- }- tags {- target = "posthog.prom_metrics_tags"- }- metrics {- target = "posthog.prom_metrics_metrics"- }- }- }-- table "prom_metrics_data" {- order_by = ["id", "timestamp"]- settings = {- index_granularity = "8192"- }- column "id" {- type = "UUID"- }- column "timestamp" {- type = "DateTime64(3)"- }- column "value" {- type = "Float64"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.prom_metrics/data"- replica_name = "{replica}"- }- }-- table "prom_metrics_metrics" {- order_by = ["metric_family_name"]- settings = {- index_granularity = "8192"- }- column "metric_family_name" {- type = "String"- }- column "type" {- type = "String"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.prom_metrics/metrics"- replica_name = "{replica}"- }- }-- table "prom_metrics_tags" {- primary_key = ["metric_name"]- order_by = ["metric_name", "id"]- settings = {- index_granularity = "8192"- }- column "id" {- type = "UUID"- default = "reinterpretAsUUID(sipHash128(metric_name, all_tags))"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "tags" {- type = "Map(LowCardinality(String), String)"- }- column "all_tags" {- type = "Map(String, String)"- }- column "min_time" {- type = "SimpleAggregateFunction(min, Nullable(DateTime64(3)))"- }- column "max_time" {- type = "SimpleAggregateFunction(max, Nullable(DateTime64(3)))"- }- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.prom_metrics/tags"- replica_name = "{replica}"- }- }-- 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"- }- }-- table "query_log_archive_buffer" {- 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 "buffer" {- database = "posthog"- table = "sharded_query_log_archive"- num_layers = 16- min_time = 10- max_time = 60- min_rows = 10000- max_rows = 1000000- min_bytes = 10000000- max_bytes = 100000000- }- }-- table "sharded_query_log_archive" {- order_by = ["team_id", "event_date", "event_time", "query_id"]- partition_by = "toYYYYMM(event_date)"- settings = {- index_granularity = "8192"- object_serialization_version = "v3"- object_shared_data_serialization_version = "map_with_buckets"- }- 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 "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.sharded_query_log_archive"- replica_name = "{replica}-{shard}"- }- }-- 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 "writable_prom_metrics" {- column "id" {- type = "UUID"- default = "reinterpretAsUUID(sipHash128(metric_name, all_tags))"- }- column "timestamp" {- type = "DateTime64(3)"- }- column "value" {- type = "Float64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "tags" {- type = "Map(LowCardinality(String), String)"- }- column "all_tags" {- type = "Map(String, String)"- }- column "min_time" {- type = "Nullable(DateTime64(3))"- }- column "max_time" {- type = "Nullable(DateTime64(3))"- }- column "metric_family_name" {- type = "String"- }- column "type" {- type = "String"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- engine "time_series" {- samples {- target = "posthog.writable_prom_metrics_data"- }- tags {- target = "posthog.writable_prom_metrics_tags"- }- metrics {- target = "posthog.writable_prom_metrics_metrics"- }- }- }-- table "writable_prom_metrics_data" {- column "id" {- type = "UUID"- }- column "timestamp" {- type = "DateTime64(3)"- }- column "value" {- type = "Float64"- }- engine "buffer" {- database = "posthog"- table = "prom_metrics_data"- num_layers = 1- min_time = 2- max_time = 5- min_rows = 1- max_rows = 1000000- min_bytes = 1- max_bytes = 100000000- }- }-- table "writable_prom_metrics_metrics" {- column "metric_family_name" {- type = "String"- }- column "type" {- type = "String"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- engine "buffer" {- database = "posthog"- table = "prom_metrics_metrics"- num_layers = 1- min_time = 2- max_time = 5- min_rows = 1- max_rows = 1000000- min_bytes = 1- max_bytes = 100000000- }- }-- table "writable_prom_metrics_tags" {- column "id" {- type = "UUID"- default = "reinterpretAsUUID(sipHash128(metric_name, all_tags))"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "tags" {- type = "Map(LowCardinality(String), String)"- }- column "all_tags" {- type = "Map(String, String)"- }- column "min_time" {- type = "SimpleAggregateFunction(min, Nullable(DateTime64(3)))"- }- column "max_time" {- type = "SimpleAggregateFunction(max, Nullable(DateTime64(3)))"- }- engine "buffer" {- database = "posthog"- table = "prom_metrics_tags"- num_layers = 1- min_time = 2- max_time = 5- min_rows = 1- max_rows = 1000000- min_bytes = 1- max_bytes = 100000000- }- }-- 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 = <<SQL-SELECT- hostname,- user,- query_id,- initial_query_id,- is_initial_query,- type,- event_date,- event_time,- event_time_microseconds,- query_start_time,- query_start_time_microseconds,- query_duration_ms,- read_rows,- read_bytes,- written_rows,- written_bytes,- result_rows,- result_bytes,- memory_usage,- peak_threads_usage,- current_database,- query,- formatted_query,- normalized_query_hash,- query_kind,- exception_code,- exception,- stack_trace,- JSONExtractInt(log_comment, 'team_id') AS team_id,- if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,- ProfileEvents-FROM system.query_log-WHERE type != 'QueryStart'-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)"- }- }-- view "custom_metrics" {- query = <<SQL-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- )-SQL-- }-- view "custom_metrics_backups" {- query = <<SQL-WITH- ['ClickHouseCustomMetric_BackupFailed', 'ClickHouseCustomMetric_BackupSuccess', 'ClickHouseCustomMetric_BackupCancelled', 'ClickHouseCustomMetric_BackupAttempts'] AS names,- [toInt64(countIf(status = 'BACKUP_FAILED')), toInt64(countIf(status = 'BACKUP_CREATED')), toInt64(countIf(status = 'BACKUP_CANCELLED')), toInt64(countIf(status = 'CREATING_BACKUP'))] AS values,- ['Number of failed backups', 'Number of successful backups', 'Number of cancelled backups', 'Number of backup attempts'] AS descriptions,- ['gauge', 'gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.backup_log-WHERE event_date = today()-GROUP BY- event_date-SQL-- }-- view "custom_metrics_dictionaries" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_DictionariesFailed' AS name,- map(- 'instance',- hostname(),- 'database',- d.database,- 'dictionary',- d.dict_name,- 'uuid',- toString(d.uuid),- 'status',- toString(d.status)- ) AS labels,- toUInt64(1) AS value,- 'Dictionary is in FAILED or FAILED_AND_RELOADING status' AS help,- 'gauge' AS type-FROM- (- SELECT name AS dict_name, database, uuid, status- FROM system.dictionaries- WHERE status IN ('FAILED', 'FAILED_AND_RELOADING')- ) AS d-SQL-- }-- view "custom_metrics_part_counts" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_MaxPartCountPerPartition' AS name,- map('instance', hostname(), 'database', database, 'table', `table`, 'partition', partition) AS labels,- part_count AS value,- 'Maximum number of active parts for any partition in a PostHog table' AS help,- 'gauge' AS type-FROM- (- SELECT database, `table`, partition, count() AS part_count- FROM system.parts- WHERE- active- AND- (database = 'posthog')- GROUP BY- database, `table`, partition- ORDER BY database ASC, `table` ASC, part_count DESC, partition ASC- LIMIT 1 BY database, `table`- )-SQL-- }-- view "custom_metrics_replication_queue" {- query = <<SQL-WITH- ['ClickHouseCustomMetric_ReplicationQueueStuckEntries', 'ClickHouseCustomMetric_ReplicationQueueMaxPostponedEntrySeconds', 'ClickHouseCustomMetric_ReplicationQueueMaxErrorEntrySeconds'] AS names,- [toInt64(countIf(create_time < (now() - toIntervalDay(15)))), maxIf(dateDiff('seconds', create_time, last_postpone_time), last_postpone_time != '1970-01-01'), maxIf(dateDiff('seconds', create_time, last_exception_time), (last_exception_time != '1970-01-01') AND (last_exception_time > (now() - toIntervalMinute(5))))] AS values,- ['Number of entries that have been in the replication queue for more than 15 days', 'Maximum number of seconds that an entry has been postponed', 'Maximum number of seconds that an entry has been in error'] AS descriptions,- ['gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('table', `table`, 'instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.replication_queue-GROUP BY- `table`-HAVING- value > 0-SQL-- }-- view "custom_metrics_server_crash" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_ServerCrash' AS name,- map('instance', hostname()) AS labels,- count() AS value,- 'Number of server crashes for current date' AS help,- 'gauge' AS type-FROM system.crash_log-WHERE event_date = today()-GROUP BY- hostname()-SQL-- }-- view "custom_metrics_table_sizes" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_TableTotalBytes' AS name,- map('instance', hostname(), 'database', database, 'table', `table`) AS labels,- CAST(total_bytes, 'Float64') AS value,- 'Size of a database table on a given node (need a sum for sharded)' AS help,- 'gauge' AS type-FROM system.tables-WHERE- (database NOT IN ('INFORMATION_SCHEMA', 'information_schema'))-AND- (total_bytes IS NOT NULL)-SQL-- }-- view "custom_metrics_test" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_Test' AS name,- map('instance', hostname()) AS labels,- 1 AS value,- 'Test to check that the metric endpoint is working' AS help,- 'gauge' AS type-SQL-- }-}diff --git a/posthog/clickhouse/hcl/golden/prod-eu/ops.hcl b/posthog/clickhouse/hcl/golden/prod-eu/ops.hcldeleted file mode 100644index 182b8035f29c..000000000000--- a/posthog/clickhouse/hcl/golden/prod-eu/ops.hcl+++ /dev/null@@ -1,1648 +0,0 @@-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)"- }- }-- table "events_team_daily_stats" {- order_by = ["analysis_date", "team_id", "event"]- settings = {- index_granularity = "8192"- }- column "analysis_date" {- type = "Date"- }- column "team_id" {- type = "Int64"- }- column "event" {- type = "String"- }- column "event_count" {- type = "UInt64"- }- column "total_event_bytes" {- type = "UInt64"- }- column "min_event_bytes" {- type = "UInt64"- }- column "max_event_bytes" {- type = "UInt64"- }- column "avg_event_bytes" {- type = "Float64"- }- column "p50_event_bytes" {- type = "Float64"- }- column "p90_event_bytes" {- type = "Float64"- }- column "p95_event_bytes" {- type = "Float64"- }- column "p99_event_bytes" {- type = "Float64"- }- column "event_size_histogram" {- type = "Array(Tuple(Float64, Float64, UInt64))"- }- column "computed_at" {- type = "DateTime"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.events_team_daily_stats"- replica_name = "{replica}"- }- }-- table "metrics_exemplars" {- order_by = ["team_id", "id", "timestamp"]- partition_by = "toYYYYMMDD(timestamp)"- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "timestamp" {- type = "DateTime64(3, 'UTC')"- }- column "id" {- type = "UInt64"- }- column "value" {- type = "Float64"- }- column "labels_json" {- type = "String"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_exemplars"- replica_name = "{replica}"- }- }-- table "metrics_histograms" {- order_by = ["team_id", "id", "timestamp"]- partition_by = "toYYYYMMDD(timestamp)"- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "timestamp" {- type = "DateTime64(3, 'UTC')"- }- column "id" {- type = "UInt64"- }- column "histogram" {- type = "String"- }- column "version" {- type = "UInt64"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_histograms"- replica_name = "{replica}"- version_column = "version"- }- }-- table "metrics_label_index" {- order_by = ["team_id", "metric_name", "label_name", "label_value", "id"]- settings = {- deduplicate_merge_projection_mode = "rebuild"- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "label_name" {- type = "LowCardinality(String)"- }- column "label_value" {- type = "String"- }- column "id" {- type = "UInt64"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_label_index"- replica_name = "{replica}"- }- }-- table "metrics_metadata" {- order_by = ["team_id", "metric_family_name"]- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_family_name" {- type = "LowCardinality(String)"- }- column "type" {- type = "LowCardinality(String)"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- column "updated_at" {- type = "DateTime64(3, 'UTC')"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_metadata"- replica_name = "{replica}"- version_column = "updated_at"- }- }-- table "metrics_samples" {- order_by = ["team_id", "metric_name", "id", "timestamp"]- partition_by = "toYYYYMMDD(timestamp)"- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "timestamp" {- type = "DateTime64(3, 'UTC')"- }- column "id" {- type = "UInt64"- }- column "value" {- type = "Float64"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_samples"- replica_name = "{replica}"- }- }-- table "metrics_series" {- order_by = ["team_id", "metric_name", "id"]- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "labels_json" {- type = "String"- }- column "min_time" {- type = "DateTime64(3, 'UTC')"- }- column "max_time" {- type = "DateTime64(3, 'UTC')"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_series"- replica_name = "{replica}"- }- }-- 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"- }- }-- table "query_log_archive_buffer" {- 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 "buffer" {- database = "posthog"- table = "sharded_query_log_archive"- num_layers = 16- min_time = 10- max_time = 60- min_rows = 10000- max_rows = 1000000- min_bytes = 10000000- max_bytes = 100000000- }- }-- table "sharded_query_log_archive" {- order_by = ["team_id", "event_date", "event_time", "query_id"]- partition_by = "toYYYYMM(event_date)"- settings = {- index_granularity = "8192"- object_serialization_version = "v3"- object_shared_data_serialization_version = "map_with_buckets"- }- 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 "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.sharded_query_log_archive"- replica_name = "{replica}-{shard}"- }- }-- 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/ops/{shard}/posthog.tophog"- replica_name = "{replica}"- }- }-- 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 "metrics_label_index_from_series_mv" {- to_table = "posthog.metrics_label_index"- query = <<SQL-SELECT- team_id,- metric_name,- tupleElement(label_pair, 1) AS label_name,- tupleElement(label_pair, 2) AS label_value,- id-FROM- posthog.metrics_series ARRAY JOIN JSONExtractKeysAndValues(labels_json, 'String') AS label_pair-SQL-- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "label_name" {- type = "LowCardinality(String)"- }- column "label_value" {- type = "String"- }- column "id" {- type = "UInt64"- }- }-- materialized_view "ops_query_log_archive_mv" {- to_table = "posthog.writable_query_log_archive"- query = <<SQL-SELECT- hostname,- user,- query_id,- initial_query_id,- is_initial_query,- type,- event_date,- event_time,- event_time_microseconds,- query_start_time,- query_start_time_microseconds,- query_duration_ms,- read_rows,- read_bytes,- written_rows,- written_bytes,- result_rows,- result_bytes,- memory_usage,- peak_threads_usage,- current_database,- query,- formatted_query,- normalized_query_hash,- query_kind,- exception_code,- exception,- stack_trace,- JSONExtractInt(log_comment, 'team_id') AS team_id,- if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,- ProfileEvents-FROM system.query_log-WHERE type != 'QueryStart'-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)"- }- }-- view "custom_metrics" {- query = <<SQL-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- )-SQL-- }-- view "custom_metrics_backups" {- query = <<SQL-WITH- ['ClickHouseCustomMetric_BackupFailed', 'ClickHouseCustomMetric_BackupSuccess', 'ClickHouseCustomMetric_BackupCancelled', 'ClickHouseCustomMetric_BackupAttempts'] AS names,- [toInt64(countIf(status = 'BACKUP_FAILED')), toInt64(countIf(status = 'BACKUP_CREATED')), toInt64(countIf(status = 'BACKUP_CANCELLED')), toInt64(countIf(status = 'CREATING_BACKUP'))] AS values,- ['Number of failed backups', 'Number of successful backups', 'Number of cancelled backups', 'Number of backup attempts'] AS descriptions,- ['gauge', 'gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.backup_log-WHERE event_date = today()-GROUP BY- event_date-SQL-- }-- view "custom_metrics_dictionaries" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_DictionariesFailed' AS name,- map(- 'instance',- hostname(),- 'database',- d.database,- 'dictionary',- d.dict_name,- 'uuid',- toString(d.uuid),- 'status',- toString(d.status)- ) AS labels,- toUInt64(1) AS value,- 'Dictionary is in FAILED or FAILED_AND_RELOADING status' AS help,- 'gauge' AS type-FROM- (- SELECT name AS dict_name, database, uuid, status- FROM system.dictionaries- WHERE status IN ('FAILED', 'FAILED_AND_RELOADING')- ) AS d-SQL-- }-- view "custom_metrics_part_counts" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_MaxPartCountPerPartition' AS name,- map('instance', hostname(), 'database', database, 'table', `table`, 'partition', partition) AS labels,- part_count AS value,- 'Maximum number of active parts for any partition in a PostHog table' AS help,- 'gauge' AS type-FROM- (- SELECT database, `table`, partition, count() AS part_count- FROM system.parts- WHERE- active- AND- (database = 'posthog')- GROUP BY- database, `table`, partition- ORDER BY database ASC, `table` ASC, part_count DESC, partition ASC- LIMIT 1 BY database, `table`- )-SQL-- }-- view "custom_metrics_replication_queue" {- query = <<SQL-WITH- ['ClickHouseCustomMetric_ReplicationQueueStuckEntries', 'ClickHouseCustomMetric_ReplicationQueueMaxPostponedEntrySeconds', 'ClickHouseCustomMetric_ReplicationQueueMaxErrorEntrySeconds'] AS names,- [toInt64(countIf(create_time < (now() - toIntervalDay(15)))), maxIf(dateDiff('seconds', create_time, last_postpone_time), last_postpone_time != '1970-01-01'), maxIf(dateDiff('seconds', create_time, last_exception_time), (last_exception_time != '1970-01-01') AND (last_exception_time > (now() - toIntervalMinute(5))))] AS values,- ['Number of entries that have been in the replication queue for more than 15 days', 'Maximum number of seconds that an entry has been postponed', 'Maximum number of seconds that an entry has been in error'] AS descriptions,- ['gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('table', `table`, 'instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.replication_queue-GROUP BY- `table`-HAVING- value > 0-SQL-- }-- view "custom_metrics_server_crash" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_ServerCrash' AS name,- map('instance', hostname()) AS labels,- count() AS value,- 'Number of server crashes for current date' AS help,- 'gauge' AS type-FROM system.crash_log-WHERE event_date = today()-GROUP BY- hostname()-SQL-- }-- view "custom_metrics_table_sizes" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_TableTotalBytes' AS name,- map('instance', hostname(), 'database', database, 'table', `table`) AS labels,- CAST(total_bytes, 'Float64') AS value,- 'Size of a database table on a given node (need a sum for sharded)' AS help,- 'gauge' AS type-FROM system.tables-WHERE- (database NOT IN ('INFORMATION_SCHEMA', 'information_schema'))-AND- (total_bytes IS NOT NULL)-SQL-- }-- view "custom_metrics_test" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_Test' AS name,- map('instance', hostname()) AS labels,- 1 AS value,- 'Test to check that the metric endpoint is working' AS help,- 'gauge' AS type-SQL-- }-}diff --git a/posthog/clickhouse/hcl/golden/prod-us/ops.hcl b/posthog/clickhouse/hcl/golden/prod-us/ops.hcldeleted file mode 100644index 9815a3b905e8..000000000000--- a/posthog/clickhouse/hcl/golden/prod-us/ops.hcl+++ /dev/null@@ -1,1735 +0,0 @@-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)"- }- }-- 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)"- }- }-- table "events_team_daily_stats" {- order_by = ["analysis_date", "team_id", "event"]- settings = {- index_granularity = "8192"- }- column "analysis_date" {- type = "Date"- }- column "team_id" {- type = "Int64"- }- column "event" {- type = "String"- }- column "event_count" {- type = "UInt64"- }- column "total_event_bytes" {- type = "UInt64"- }- column "min_event_bytes" {- type = "UInt64"- }- column "max_event_bytes" {- type = "UInt64"- }- column "avg_event_bytes" {- type = "Float64"- }- column "p50_event_bytes" {- type = "Float64"- }- column "p90_event_bytes" {- type = "Float64"- }- column "p95_event_bytes" {- type = "Float64"- }- column "p99_event_bytes" {- type = "Float64"- }- column "event_size_histogram" {- type = "Array(Tuple(Float64, Float64, UInt64))"- }- column "computed_at" {- type = "DateTime"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.events_team_daily_stats"- replica_name = "{replica}"- }- }-- table "metrics_exemplars" {- order_by = ["team_id", "id", "timestamp"]- partition_by = "toYYYYMMDD(timestamp)"- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "timestamp" {- type = "DateTime64(3, 'UTC')"- }- column "id" {- type = "UInt64"- }- column "value" {- type = "Float64"- }- column "labels_json" {- type = "String"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_exemplars"- replica_name = "{replica}"- }- }-- table "metrics_histograms" {- order_by = ["team_id", "id", "timestamp"]- partition_by = "toYYYYMMDD(timestamp)"- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "timestamp" {- type = "DateTime64(3, 'UTC')"- }- column "id" {- type = "UInt64"- }- column "histogram" {- type = "String"- }- column "version" {- type = "UInt64"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_histograms"- replica_name = "{replica}"- version_column = "version"- }- }-- table "metrics_label_index" {- order_by = ["team_id", "metric_name", "label_name", "label_value", "id"]- settings = {- deduplicate_merge_projection_mode = "rebuild"- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "label_name" {- type = "LowCardinality(String)"- }- column "label_value" {- type = "String"- }- column "id" {- type = "UInt64"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_label_index"- replica_name = "{replica}"- }- }-- table "metrics_metadata" {- order_by = ["team_id", "metric_family_name"]- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_family_name" {- type = "LowCardinality(String)"- }- column "type" {- type = "LowCardinality(String)"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- column "updated_at" {- type = "DateTime64(3, 'UTC')"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_metadata"- replica_name = "{replica}"- version_column = "updated_at"- }- }-- table "metrics_samples" {- order_by = ["team_id", "metric_name", "id", "timestamp"]- partition_by = "toYYYYMMDD(timestamp)"- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "timestamp" {- type = "DateTime64(3, 'UTC')"- }- column "id" {- type = "UInt64"- }- column "value" {- type = "Float64"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_samples"- replica_name = "{replica}"- }- }-- table "metrics_series" {- order_by = ["team_id", "metric_name", "id"]- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "labels_json" {- type = "String"- }- column "min_time" {- type = "DateTime64(3, 'UTC')"- }- column "max_time" {- type = "DateTime64(3, 'UTC')"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_series"- replica_name = "{replica}"- }- }-- 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"- }- }-- table "query_log_archive_buffer" {- 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 "buffer" {- database = "posthog"- table = "sharded_query_log_archive"- num_layers = 16- min_time = 10- max_time = 60- min_rows = 10000- max_rows = 1000000- min_bytes = 10000000- max_bytes = 100000000- }- }-- table "sharded_query_log_archive" {- order_by = ["team_id", "event_date", "event_time", "query_id"]- partition_by = "toYYYYMM(event_date)"- settings = {- index_granularity = "8192"- object_serialization_version = "v3"- object_shared_data_serialization_version = "map_with_buckets"- }- 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'), '')"- }- column "ProfileEvents2" {- 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)"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/tables/noshard/posthog.sharded_query_log_archive"- replica_name = "{replica}-{shard}"- }- }-- 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/ops/{shard}/posthog.tophog_new"- replica_name = "{replica}"- }- }-- 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 "metrics_label_index_from_series_mv" {- to_table = "posthog.metrics_label_index"- query = <<SQL-SELECT- team_id,- metric_name,- tupleElement(label_pair, 1) AS label_name,- tupleElement(label_pair, 2) AS label_value,- id-FROM- posthog.metrics_series ARRAY JOIN JSONExtractKeysAndValues(labels_json, 'String') AS label_pair-SQL-- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "label_name" {- type = "LowCardinality(String)"- }- column "label_value" {- type = "String"- }- column "id" {- type = "UInt64"- }- }-- materialized_view "ops_query_log_archive_mv" {- to_table = "posthog.writable_query_log_archive"- query = <<SQL-SELECT- hostname,- user,- query_id,- initial_query_id,- is_initial_query,- type,- event_date,- event_time,- event_time_microseconds,- query_start_time,- query_start_time_microseconds,- query_duration_ms,- read_rows,- read_bytes,- written_rows,- written_bytes,- result_rows,- result_bytes,- memory_usage,- peak_threads_usage,- current_database,- query,- formatted_query,- normalized_query_hash,- query_kind,- exception_code,- exception,- stack_trace,- JSONExtractInt(log_comment, 'team_id') AS team_id,- if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,- ProfileEvents-FROM system.query_log-WHERE type != 'QueryStart'-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)"- }- }-- view "custom_metrics" {- query = <<SQL-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- )-SQL-- }-- view "custom_metrics_backups" {- query = <<SQL-WITH- ['ClickHouseCustomMetric_BackupFailed', 'ClickHouseCustomMetric_BackupSuccess', 'ClickHouseCustomMetric_BackupCancelled', 'ClickHouseCustomMetric_BackupAttempts'] AS names,- [toInt64(countIf(status = 'BACKUP_FAILED')), toInt64(countIf(status = 'BACKUP_CREATED')), toInt64(countIf(status = 'BACKUP_CANCELLED')), toInt64(countIf(status = 'CREATING_BACKUP'))] AS values,- ['Number of failed backups', 'Number of successful backups', 'Number of cancelled backups', 'Number of backup attempts'] AS descriptions,- ['gauge', 'gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.backup_log-WHERE event_date = today()-GROUP BY- event_date-SQL-- }-- view "custom_metrics_dictionaries" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_DictionariesFailed' AS name,- map(- 'instance',- hostname(),- 'database',- d.database,- 'dictionary',- d.dict_name,- 'uuid',- toString(d.uuid),- 'status',- toString(d.status)- ) AS labels,- toUInt64(1) AS value,- 'Dictionary is in FAILED or FAILED_AND_RELOADING status' AS help,- 'gauge' AS type-FROM- (- SELECT name AS dict_name, database, uuid, status- FROM system.dictionaries- WHERE status IN ('FAILED', 'FAILED_AND_RELOADING')- ) AS d-SQL-- }-- view "custom_metrics_part_counts" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_MaxPartCountPerPartition' AS name,- map('instance', hostname(), 'database', database, 'table', `table`, 'partition', partition) AS labels,- part_count AS value,- 'Maximum number of active parts for any partition in a PostHog table' AS help,- 'gauge' AS type-FROM- (- SELECT database, `table`, partition, count() AS part_count- FROM system.parts- WHERE- active- AND- (database = 'posthog')- GROUP BY- database, `table`, partition- ORDER BY database ASC, `table` ASC, part_count DESC, partition ASC- LIMIT 1 BY database, `table`- )-SQL-- }-- view "custom_metrics_replication_queue" {- query = <<SQL-WITH- ['ClickHouseCustomMetric_ReplicationQueueStuckEntries', 'ClickHouseCustomMetric_ReplicationQueueMaxPostponedEntrySeconds', 'ClickHouseCustomMetric_ReplicationQueueMaxErrorEntrySeconds'] AS names,- [toInt64(countIf(create_time < (now() - toIntervalDay(15)))), maxIf(dateDiff('seconds', create_time, last_postpone_time), last_postpone_time != '1970-01-01'), maxIf(dateDiff('seconds', create_time, last_exception_time), (last_exception_time != '1970-01-01') AND (last_exception_time > (now() - toIntervalMinute(5))))] AS values,- ['Number of entries that have been in the replication queue for more than 15 days', 'Maximum number of seconds that an entry has been postponed', 'Maximum number of seconds that an entry has been in error'] AS descriptions,- ['gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('table', `table`, 'instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.replication_queue-GROUP BY- `table`-HAVING- value > 0-SQL-- }-- view "custom_metrics_server_crash" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_ServerCrash' AS name,- map('instance', hostname()) AS labels,- count() AS value,- 'Number of server crashes for current date' AS help,- 'gauge' AS type-FROM system.crash_log-WHERE event_date = today()-GROUP BY- hostname()-SQL-- }-- view "custom_metrics_table_sizes" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_TableTotalBytes' AS name,- map('instance', hostname(), 'database', database, 'table', `table`) AS labels,- CAST(total_bytes, 'Float64') AS value,- 'Size of a database table on a given node (need a sum for sharded)' AS help,- 'gauge' AS type-FROM system.tables-WHERE- (database NOT IN ('INFORMATION_SCHEMA', 'information_schema'))-AND- (total_bytes IS NOT NULL)-SQL-- }-- view "custom_metrics_test" {- query = <<SQL-SELECT- 'ClickHouseCustomMetric_Test' AS name,- map('instance', hostname()) AS labels,- 1 AS value,- 'Test to check that the metric endpoint is working' AS help,- 'gauge' AS type-SQL-- }-}diff --git a/posthog/clickhouse/hcl/manifest.hcl b/posthog/clickhouse/hcl/manifest.hclindex b27492064b96..1618cdfdef8a 100644--- a/posthog/clickhouse/hcl/manifest.hcl+++ b/posthog/clickhouse/hcl/manifest.hcl@@ -15,9 +15,10 @@# `shared` = all envs of that role and `prod` = both prod envs (e.g. the OPS metrics# suite is prod-only but env-identical).#-# OPS and LOGS are modeled for all three cloud envs (dev, prod-us, prod-eu). OPS carries-# the env differences; LOGS carries the shared managed subset (env-identical, but verified-# per env for fidelity). The satellite roles are modeled where a node of that role exists+# LOGS is modeled for all three cloud envs (dev, prod-us, prod-eu) and carries the shared+# managed subset (env-identical, but verified per env for fidelity). OPS keeps only its+# local-multi block: posthog-cloud-infra authors the ops env layers and goldens now, and+# vendors roles/ops/shared from here. The satellite roles are modeled where a node of that role exists# to model: every role the multinode stack runs has a `local-multi` env block, and the# convergence gate (dump-live.sh + check-live.sh) dumps and gates all of them.#@@ -26,9 +27,6 @@role "ops" {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/coshared/tophog", "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 itdiff --git a/posthog/clickhouse/hcl/roles/ops/dev/ops.hcl b/posthog/clickhouse/hcl/roles/ops/dev/ops.hcldeleted file mode 100644index 34766296bd46..000000000000--- a/posthog/clickhouse/hcl/roles/ops/dev/ops.hcl+++ /dev/null@@ -1,256 +0,0 @@-# OPS dev env layer — prom_metrics experiment (dev only)-#-# Generated/maintained as the declarative source of truth for the OPS ClickHouse cluster.-# Resolve with: hclexp load -layer <base>,<...>-database "posthog" {- table "prom_metrics" {- column "id" {- type = "UUID"- default = "reinterpretAsUUID(sipHash128(metric_name, all_tags))"- }- column "timestamp" {- type = "DateTime64(3)"- }- column "value" {- type = "Float64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "tags" {- type = "Map(LowCardinality(String), String)"- }- column "all_tags" {- type = "Map(String, String)"- }- column "min_time" {- type = "Nullable(DateTime64(3))"- }- column "max_time" {- type = "Nullable(DateTime64(3))"- }- column "metric_family_name" {- type = "String"- }- column "type" {- type = "String"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- engine "time_series" {- samples {- target = "posthog.prom_metrics_data"- }- tags {- target = "posthog.prom_metrics_tags"- }- metrics {- target = "posthog.prom_metrics_metrics"- }- }- }- table "prom_metrics_data" {- order_by = ["id", "timestamp"]- settings = {- index_granularity = "8192"- }- column "id" {- type = "UUID"- }- column "timestamp" {- type = "DateTime64(3)"- }- column "value" {- type = "Float64"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.prom_metrics/data"- replica_name = "{replica}"- }- }- table "prom_metrics_metrics" {- order_by = ["metric_family_name"]- settings = {- index_granularity = "8192"- }- column "metric_family_name" {- type = "String"- }- column "type" {- type = "String"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.prom_metrics/metrics"- replica_name = "{replica}"- }- }- table "prom_metrics_tags" {- primary_key = ["metric_name"]- order_by = ["metric_name", "id"]- settings = {- index_granularity = "8192"- }- column "id" {- type = "UUID"- default = "reinterpretAsUUID(sipHash128(metric_name, all_tags))"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "tags" {- type = "Map(LowCardinality(String), String)"- }- column "all_tags" {- type = "Map(String, String)"- }- column "min_time" {- type = "SimpleAggregateFunction(min, Nullable(DateTime64(3)))"- }- column "max_time" {- type = "SimpleAggregateFunction(max, Nullable(DateTime64(3)))"- }- engine "replicated_aggregating_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.prom_metrics/tags"- replica_name = "{replica}"- }- }- table "writable_prom_metrics" {- column "id" {- type = "UUID"- default = "reinterpretAsUUID(sipHash128(metric_name, all_tags))"- }- column "timestamp" {- type = "DateTime64(3)"- }- column "value" {- type = "Float64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "tags" {- type = "Map(LowCardinality(String), String)"- }- column "all_tags" {- type = "Map(String, String)"- }- column "min_time" {- type = "Nullable(DateTime64(3))"- }- column "max_time" {- type = "Nullable(DateTime64(3))"- }- column "metric_family_name" {- type = "String"- }- column "type" {- type = "String"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- engine "time_series" {- samples {- target = "posthog.writable_prom_metrics_data"- }- tags {- target = "posthog.writable_prom_metrics_tags"- }- metrics {- target = "posthog.writable_prom_metrics_metrics"- }- }- }- table "writable_prom_metrics_data" {- column "id" {- type = "UUID"- }- column "timestamp" {- type = "DateTime64(3)"- }- column "value" {- type = "Float64"- }- engine "buffer" {- database = "posthog"- table = "prom_metrics_data"- num_layers = 1- min_time = 2- max_time = 5- min_rows = 1- max_rows = 1000000- min_bytes = 1- max_bytes = 100000000- }- }- table "writable_prom_metrics_metrics" {- column "metric_family_name" {- type = "String"- }- column "type" {- type = "String"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- engine "buffer" {- database = "posthog"- table = "prom_metrics_metrics"- num_layers = 1- min_time = 2- max_time = 5- min_rows = 1- max_rows = 1000000- min_bytes = 1- max_bytes = 100000000- }- }- table "writable_prom_metrics_tags" {- column "id" {- type = "UUID"- default = "reinterpretAsUUID(sipHash128(metric_name, all_tags))"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "tags" {- type = "Map(LowCardinality(String), String)"- }- column "all_tags" {- type = "Map(String, String)"- }- column "min_time" {- type = "SimpleAggregateFunction(min, Nullable(DateTime64(3)))"- }- column "max_time" {- type = "SimpleAggregateFunction(max, Nullable(DateTime64(3)))"- }- engine "buffer" {- database = "posthog"- table = "prom_metrics_tags"- num_layers = 1- min_time = 2- max_time = 5- min_rows = 1- max_rows = 1000000- min_bytes = 1- max_bytes = 100000000- }- }-}diff --git a/posthog/clickhouse/hcl/roles/ops/prod-eu/ops.hcl b/posthog/clickhouse/hcl/roles/ops/prod-eu/ops.hcldeleted file mode 100644index 602092f25475..000000000000--- a/posthog/clickhouse/hcl/roles/ops/prod-eu/ops.hcl+++ /dev/null@@ -1,10 +0,0 @@-# OPS prod-eu env layer — sharded_tophog (tophog zoo_path)-#-# query_log_archive_old (legacy/transitional) is intentionally unmanaged — not-# authored here and trimmed from the golden, so it is left untouched on the cluster.-#-# Generated/maintained as the declarative source of truth for the OPS ClickHouse cluster.-# Resolve with: hclexp load -layer <base>,<...>--database "posthog" {-}diff --git a/posthog/clickhouse/hcl/roles/ops/prod-eu/patches.hcl b/posthog/clickhouse/hcl/roles/ops/prod-eu/patches.hcldeleted file mode 100644index 35ccacb3b8b5..000000000000--- a/posthog/clickhouse/hcl/roles/ops/prod-eu/patches.hcl+++ /dev/null@@ -1,9 +0,0 @@-# 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.hcldeleted file mode 100644index 0d7af9e5db8d..000000000000--- a/posthog/clickhouse/hcl/roles/ops/prod-us/ops.hcl+++ /dev/null@@ -1,15 +0,0 @@-# OPS prod-us env layer — events distributed proxies, sharded_tophog (tophog_new zoo_path)-#-# Generated/maintained as the declarative source of truth for the OPS ClickHouse cluster.-# Resolve with: hclexp load -layer <base>,<...>--database "posthog" {- # prod-us-only experiment: an extra ProfileEvents2 JSON column on the base- # sharded_query_log_archive table. Additive patch so the shared base stays- # region-agnostic; drop this once the experiment ends or rolls out to prod-eu.- patch_table "sharded_query_log_archive" {- column "ProfileEvents2" {- 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)"- }- }-}diff --git a/posthog/clickhouse/hcl/roles/ops/prod-us/patches.hcl b/posthog/clickhouse/hcl/roles/ops/prod-us/patches.hcldeleted file mode 100644index 091f0cb9cbf2..000000000000--- a/posthog/clickhouse/hcl/roles/ops/prod-us/patches.hcl+++ /dev/null@@ -1,9 +0,0 @@-# 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.hcldeleted file mode 100644index 1751a120aebf..000000000000--- a/posthog/clickhouse/hcl/roles/ops/prod/events.hcl+++ /dev/null@@ -1,86 +0,0 @@-# 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.hcldeleted file mode 100644index 84347af43f43..000000000000--- a/posthog/clickhouse/hcl/roles/ops/prod/metrics.hcl+++ /dev/null@@ -1,188 +0,0 @@-# OPS role, prod only — metrics suite + sharded_tophog abstract.--database "posthog" {- table "metrics_exemplars" {- order_by = ["team_id", "id", "timestamp"]- partition_by = "toYYYYMMDD(timestamp)"- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "timestamp" {- type = "DateTime64(3, 'UTC')"- }- column "id" {- type = "UInt64"- }- column "value" {- type = "Float64"- }- column "labels_json" {- type = "String"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_exemplars"- replica_name = "{replica}"- }- }- table "metrics_histograms" {- order_by = ["team_id", "id", "timestamp"]- partition_by = "toYYYYMMDD(timestamp)"- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "timestamp" {- type = "DateTime64(3, 'UTC')"- }- column "id" {- type = "UInt64"- }- column "histogram" {- type = "String"- }- column "version" {- type = "UInt64"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_histograms"- replica_name = "{replica}"- version_column = "version"- }- }- table "metrics_label_index" {- order_by = ["team_id", "metric_name", "label_name", "label_value", "id"]- settings = {- deduplicate_merge_projection_mode = "rebuild"- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "label_name" {- type = "LowCardinality(String)"- }- column "label_value" {- type = "String"- }- column "id" {- type = "UInt64"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_label_index"- replica_name = "{replica}"- }- }- table "metrics_metadata" {- order_by = ["team_id", "metric_family_name"]- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_family_name" {- type = "LowCardinality(String)"- }- column "type" {- type = "LowCardinality(String)"- }- column "unit" {- type = "String"- }- column "help" {- type = "String"- }- column "updated_at" {- type = "DateTime64(3, 'UTC')"- }- engine "replicated_replacing_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_metadata"- replica_name = "{replica}"- version_column = "updated_at"- }- }- table "metrics_samples" {- order_by = ["team_id", "metric_name", "id", "timestamp"]- partition_by = "toYYYYMMDD(timestamp)"- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "timestamp" {- type = "DateTime64(3, 'UTC')"- }- column "id" {- type = "UInt64"- }- column "value" {- type = "Float64"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_samples"- replica_name = "{replica}"- }- }- table "metrics_series" {- order_by = ["team_id", "metric_name", "id"]- settings = {- index_granularity = "1024"- }- column "team_id" {- type = "UInt64"- }- column "id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "labels_json" {- type = "String"- }- column "min_time" {- type = "DateTime64(3, 'UTC')"- }- column "max_time" {- type = "DateTime64(3, 'UTC')"- }- engine "replicated_merge_tree" {- zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_series"- replica_name = "{replica}"- }- }- materialized_view "metrics_label_index_from_series_mv" {- to_table = "posthog.metrics_label_index"- query = file("sql/metrics_label_index_from_series_mv.sql")- column "team_id" {- type = "UInt64"- }- column "metric_name" {- type = "LowCardinality(String)"- }- column "label_name" {- type = "LowCardinality(String)"- }- column "label_value" {- type = "String"- }- column "id" {- type = "UInt64"- }- }-}diff --git a/posthog/clickhouse/hcl/roles/ops/prod/sql/metrics_label_index_from_series_mv.sql b/posthog/clickhouse/hcl/roles/ops/prod/sql/metrics_label_index_from_series_mv.sqldeleted file mode 100644index 3f54275a8019..000000000000--- a/posthog/clickhouse/hcl/roles/ops/prod/sql/metrics_label_index_from_series_mv.sql+++ /dev/null@@ -1,8 +0,0 @@-SELECT- team_id,- metric_name,- tupleElement(label_pair, 1) AS label_name,- tupleElement(label_pair, 2) AS label_value,- id-FROM- posthog.metrics_series ARRAY JOIN JSONExtractKeysAndValues(labels_json, 'String') AS label_pairdiff --git a/posthog/clickhouse/hcl/sql/dev/ops.sql b/posthog/clickhouse/hcl/sql/dev/ops.sqldeleted file mode 100644index 753cfb4a1bd6..000000000000--- a/posthog/clickhouse/hcl/sql/dev/ops.sql+++ /dev/null@@ -1,558 +0,0 @@--- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.--- Full CREATE schema for the dev/ops node. Apply to a fresh ClickHouse to build it.--CREATE TABLE posthog.events_team_daily_stats (- analysis_date Date,- team_id Int64,- event String,- event_count UInt64,- total_event_bytes UInt64,- min_event_bytes UInt64,- max_event_bytes UInt64,- avg_event_bytes Float64,- p50_event_bytes Float64,- p90_event_bytes Float64,- p95_event_bytes Float64,- p99_event_bytes Float64,- event_size_histogram Array(Tuple(Float64, Float64, UInt64)),- computed_at DateTime-) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.events_team_daily_stats', '{replica}') ORDER BY (analysis_date, team_id, event) SETTINGS index_granularity = 8192;-CREATE TABLE posthog.prom_metrics_data (- id UUID,- timestamp DateTime64(3),- value Float64-) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.prom_metrics/data', '{replica}') ORDER BY (id, timestamp) SETTINGS index_granularity = 8192;-CREATE TABLE posthog.prom_metrics_metrics (- metric_family_name String,- type String,- unit String,- help String-) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/ops/tables/{shard}/posthog.prom_metrics/metrics', '{replica}') ORDER BY (metric_family_name) SETTINGS index_granularity = 8192;-CREATE TABLE posthog.prom_metrics_tags (- id UUID DEFAULT reinterpretAsUUID(sipHash128(metric_name, all_tags)),- metric_name LowCardinality(String),- tags Map(LowCardinality(String), String),- all_tags Map(String, String),- min_time SimpleAggregateFunction(min, Nullable(DateTime64(3))),- max_time SimpleAggregateFunction(max, Nullable(DateTime64(3)))-) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/ops/tables/{shard}/posthog.prom_metrics/tags', '{replica}') PRIMARY KEY (metric_name) ORDER BY (metric_name, id) SETTINGS index_granularity = 8192;-CREATE TABLE posthog.sharded_query_log_archive (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64),- exception_name String ALIAS errorCodeToName(exception_code),- ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],- ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],- ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],- ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],- ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],- ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],- ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],- ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],- ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],- ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],- ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],- ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],- ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],- ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],- ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],- ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],- ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],- lc_workflow LowCardinality(String) ALIAS log_comment.workflow,- lc_kind LowCardinality(String) ALIAS log_comment.kind,- lc_id String ALIAS CAST(log_comment.id, 'String'),- lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),- lc_access_method LowCardinality(String) ALIAS log_comment.access_method,- lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),- lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),- lc_query_type LowCardinality(String) ALIAS log_comment.query_type,- lc_product LowCardinality(String) ALIAS log_comment.product,- lc_chargeable Bool ALIAS log_comment.chargeable,- lc_name String ALIAS CAST(log_comment.name, 'String'),- lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),- lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),- lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),- lc_user_id Int64 ALIAS log_comment.user_id,- lc_is_impersonated Bool ALIAS log_comment.is_impersonated,- lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),- lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,- lc_insight_id Int64 ALIAS log_comment.insight_id,- lc_cohort_id Int64 ALIAS log_comment.cohort_id,- lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),- lc_experiment_id Int64 ALIAS log_comment.experiment_id,- lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),- lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),- lc_feature LowCardinality(String) ALIAS log_comment.feature,- lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),- lc_warehouse_query Bool ALIAS log_comment.warehouse_query,- lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,- lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),- lc_workload LowCardinality(String) ALIAS log_comment.workload,- lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),- lc_query__query 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')),- lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),- lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),- lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),- lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),- lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),- lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),- lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),- lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,- lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),- lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),- lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')-) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.sharded_query_log_archive', '{replica}-{shard}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets';-CREATE TABLE posthog.sharded_tophog (- timestamp DateTime64(6, 'UTC'),- metric LowCardinality(String),- type LowCardinality(String) DEFAULT 'sum',- key Map(LowCardinality(String), String),- value Float64,- count UInt64 DEFAULT 0,- pipeline LowCardinality(String),- lane LowCardinality(String),- labels Map(LowCardinality(String), String)-) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/posthog.tophog', '{replica}') 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;-CREATE TABLE posthog.writable_prom_metrics_data (- id UUID,- timestamp DateTime64(3),- value Float64-) ENGINE = Buffer('posthog', 'prom_metrics_data', 1, 2, 5, 1, 1000000, 1, 100000000);-CREATE TABLE posthog.writable_prom_metrics_metrics (- metric_family_name String,- type String,- unit String,- help String-) ENGINE = Buffer('posthog', 'prom_metrics_metrics', 1, 2, 5, 1, 1000000, 1, 100000000);-CREATE TABLE posthog.writable_prom_metrics_tags (- id UUID DEFAULT reinterpretAsUUID(sipHash128(metric_name, all_tags)),- metric_name LowCardinality(String),- tags Map(LowCardinality(String), String),- all_tags Map(String, String),- min_time SimpleAggregateFunction(min, Nullable(DateTime64(3))),- max_time SimpleAggregateFunction(max, Nullable(DateTime64(3)))-) ENGINE = Buffer('posthog', 'prom_metrics_tags', 1, 2, 5, 1, 1000000, 1, 100000000);-CREATE VIEW posthog.custom_metrics_backups AS WITH- ['ClickHouseCustomMetric_BackupFailed', 'ClickHouseCustomMetric_BackupSuccess', 'ClickHouseCustomMetric_BackupCancelled', 'ClickHouseCustomMetric_BackupAttempts'] AS names,- [toInt64(countIf(status = 'BACKUP_FAILED')), toInt64(countIf(status = 'BACKUP_CREATED')), toInt64(countIf(status = 'BACKUP_CANCELLED')), toInt64(countIf(status = 'CREATING_BACKUP'))] AS values,- ['Number of failed backups', 'Number of successful backups', 'Number of cancelled backups', 'Number of backup attempts'] AS descriptions,- ['gauge', 'gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.backup_log-WHERE event_date = today()-GROUP BY- event_date;-CREATE VIEW posthog.custom_metrics_dictionaries AS SELECT- 'ClickHouseCustomMetric_DictionariesFailed' AS name,- map(- 'instance',- hostname(),- 'database',- d.database,- 'dictionary',- d.dict_name,- 'uuid',- toString(d.uuid),- 'status',- toString(d.status)- ) AS labels,- toUInt64(1) AS value,- 'Dictionary is in FAILED or FAILED_AND_RELOADING status' AS help,- 'gauge' AS type-FROM- (- SELECT name AS dict_name, database, uuid, status- FROM system.dictionaries- WHERE status IN ('FAILED', 'FAILED_AND_RELOADING')- ) AS d;-CREATE VIEW posthog.custom_metrics_part_counts AS SELECT- 'ClickHouseCustomMetric_MaxPartCountPerPartition' AS name,- map('instance', hostname(), 'database', database, 'table', `table`, 'partition', partition) AS labels,- part_count AS value,- 'Maximum number of active parts for any partition in a PostHog table' AS help,- 'gauge' AS type-FROM- (- SELECT database, `table`, partition, count() AS part_count- FROM system.parts- WHERE- active- AND- (database = 'posthog')- GROUP BY- database, `table`, partition- ORDER BY database ASC, `table` ASC, part_count DESC, partition ASC- LIMIT 1 BY database, `table`- );-CREATE VIEW posthog.custom_metrics_replication_queue AS WITH- ['ClickHouseCustomMetric_ReplicationQueueStuckEntries', 'ClickHouseCustomMetric_ReplicationQueueMaxPostponedEntrySeconds', 'ClickHouseCustomMetric_ReplicationQueueMaxErrorEntrySeconds'] AS names,- [toInt64(countIf(create_time < (now() - toIntervalDay(15)))), maxIf(dateDiff('seconds', create_time, last_postpone_time), last_postpone_time != '1970-01-01'), maxIf(dateDiff('seconds', create_time, last_exception_time), (last_exception_time != '1970-01-01') AND (last_exception_time > (now() - toIntervalMinute(5))))] AS values,- ['Number of entries that have been in the replication queue for more than 15 days', 'Maximum number of seconds that an entry has been postponed', 'Maximum number of seconds that an entry has been in error'] AS descriptions,- ['gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('table', `table`, 'instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.replication_queue-GROUP BY- `table`-HAVING- value > 0;-CREATE VIEW posthog.custom_metrics_server_crash AS SELECT- 'ClickHouseCustomMetric_ServerCrash' AS name,- map('instance', hostname()) AS labels,- count() AS value,- 'Number of server crashes for current date' AS help,- 'gauge' AS type-FROM system.crash_log-WHERE event_date = today()-GROUP BY- hostname();-CREATE VIEW posthog.custom_metrics_table_sizes AS SELECT- 'ClickHouseCustomMetric_TableTotalBytes' AS name,- map('instance', hostname(), 'database', database, 'table', `table`) AS labels,- CAST(total_bytes, 'Float64') AS value,- 'Size of a database table on a given node (need a sum for sharded)' AS help,- 'gauge' AS type-FROM system.tables-WHERE- (database NOT IN ('INFORMATION_SCHEMA', 'information_schema'))-AND- (total_bytes IS NOT NULL);-CREATE VIEW posthog.custom_metrics_test AS SELECT- 'ClickHouseCustomMetric_Test' AS name,- map('instance', hostname()) AS labels,- 1 AS value,- 'Test to check that the metric endpoint is working' AS help,- 'gauge' AS type;-CREATE TABLE posthog.prom_metrics (- id UUID DEFAULT reinterpretAsUUID(sipHash128(metric_name, all_tags)),- timestamp DateTime64(3),- value Float64,- metric_name LowCardinality(String),- tags Map(LowCardinality(String), String),- all_tags Map(String, String),- min_time Nullable(DateTime64(3)),- max_time Nullable(DateTime64(3)),- metric_family_name String,- type String,- unit String,- help String-) ENGINE = TimeSeries SAMPLES posthog.prom_metrics_data TAGS posthog.prom_metrics_tags METRICS posthog.prom_metrics_metrics;-CREATE TABLE posthog.query_log_archive (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64),- exception_name String ALIAS errorCodeToName(exception_code),- ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],- ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],- ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],- ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],- ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],- ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],- ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],- ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],- ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],- ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],- ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],- ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],- ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],- ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],- ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],- ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],- ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],- lc_workflow LowCardinality(String) ALIAS log_comment.workflow,- lc_kind LowCardinality(String) ALIAS log_comment.kind,- lc_id String ALIAS CAST(log_comment.id, 'String'),- lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),- lc_access_method LowCardinality(String) ALIAS log_comment.access_method,- lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),- lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),- lc_query_type LowCardinality(String) ALIAS log_comment.query_type,- lc_product LowCardinality(String) ALIAS log_comment.product,- lc_chargeable Bool ALIAS log_comment.chargeable,- lc_name String ALIAS CAST(log_comment.name, 'String'),- lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),- lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),- lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),- lc_user_id Int64 ALIAS log_comment.user_id,- lc_is_impersonated Bool ALIAS log_comment.is_impersonated,- lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),- lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,- lc_insight_id Int64 ALIAS log_comment.insight_id,- lc_cohort_id Int64 ALIAS log_comment.cohort_id,- lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),- lc_experiment_id Int64 ALIAS log_comment.experiment_id,- lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),- lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),- lc_feature LowCardinality(String) ALIAS log_comment.feature,- lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),- lc_warehouse_query Bool ALIAS log_comment.warehouse_query,- lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,- lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),- lc_workload LowCardinality(String) ALIAS log_comment.workload,- lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),- lc_query__query 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')),- lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),- lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),- lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),- lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),- lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),- lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),- lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),- lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,- lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),- lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),- lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')-) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');-CREATE TABLE posthog.query_log_archive_buffer (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64)-) ENGINE = Buffer('posthog', 'sharded_query_log_archive', 16, 10, 60, 10000, 1000000, 10000000, 100000000);-CREATE TABLE posthog.writable_prom_metrics (- id UUID DEFAULT reinterpretAsUUID(sipHash128(metric_name, all_tags)),- timestamp DateTime64(3),- value Float64,- metric_name LowCardinality(String),- tags Map(LowCardinality(String), String),- all_tags Map(String, String),- min_time Nullable(DateTime64(3)),- max_time Nullable(DateTime64(3)),- metric_family_name String,- type String,- unit String,- help String-) ENGINE = TimeSeries SAMPLES posthog.writable_prom_metrics_data TAGS posthog.writable_prom_metrics_tags METRICS posthog.writable_prom_metrics_metrics;-CREATE TABLE posthog.writable_query_log_archive (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64)-) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');-CREATE MATERIALIZED VIEW posthog.ops_query_log_archive_mv TO posthog.writable_query_log_archive (hostname LowCardinality(String), user LowCardinality(String), query_id String, initial_query_id String, is_initial_query UInt8, type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4), event_date Date, event_time DateTime, event_time_microseconds DateTime64(6), query_start_time DateTime, query_start_time_microseconds DateTime64(6), query_duration_ms UInt64, read_rows UInt64, read_bytes UInt64, written_rows UInt64, written_bytes UInt64, result_rows UInt64, result_bytes UInt64, memory_usage UInt64, peak_threads_usage UInt64, current_database LowCardinality(String), query String, formatted_query String, normalized_query_hash UInt64, query_kind LowCardinality(String), exception_code Int32, exception String, stack_trace String, team_id Int64, log_comment String, ProfileEvents Map(LowCardinality(String), UInt64)) AS SELECT- hostname,- user,- query_id,- initial_query_id,- is_initial_query,- type,- event_date,- event_time,- event_time_microseconds,- query_start_time,- query_start_time_microseconds,- query_duration_ms,- read_rows,- read_bytes,- written_rows,- written_bytes,- result_rows,- result_bytes,- memory_usage,- peak_threads_usage,- current_database,- query,- formatted_query,- normalized_query_hash,- query_kind,- exception_code,- exception,- stack_trace,- JSONExtractInt(log_comment, 'team_id') AS team_id,- if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,- ProfileEvents-FROM system.query_log-WHERE type != 'QueryStart';-CREATE VIEW posthog.custom_metrics AS 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/sql/prod-eu/ops.sql b/posthog/clickhouse/hcl/sql/prod-eu/ops.sqldeleted file mode 100644index d18899fdfe18..000000000000--- a/posthog/clickhouse/hcl/sql/prod-eu/ops.sql+++ /dev/null@@ -1,572 +0,0 @@--- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.--- Full CREATE schema for the prod-eu/ops node. Apply to a fresh ClickHouse to build it.--CREATE TABLE posthog.events_main (- uuid UUID,- event String,- properties String,- timestamp DateTime64(6, 'UTC'),- team_id Int64,- distinct_id String,- elements_chain String,- created_at DateTime64(6, 'UTC'),- person_id UUID,- person_created_at DateTime64(3),- person_properties String,- group0_properties String,- group1_properties String,- group2_properties String,- group3_properties String,- group4_properties String,- group0_created_at DateTime64(3),- group1_created_at DateTime64(3),- group2_created_at DateTime64(3),- group3_created_at DateTime64(3),- group4_created_at DateTime64(3),- person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),- _timestamp DateTime,- _offset UInt64,- inserted_at DateTime64(6, 'UTC')-) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));-CREATE TABLE posthog.events_team_daily_stats (- analysis_date Date,- team_id Int64,- event String,- event_count UInt64,- total_event_bytes UInt64,- min_event_bytes UInt64,- max_event_bytes UInt64,- avg_event_bytes Float64,- p50_event_bytes Float64,- p90_event_bytes Float64,- p95_event_bytes Float64,- p99_event_bytes Float64,- event_size_histogram Array(Tuple(Float64, Float64, UInt64)),- computed_at DateTime-) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.events_team_daily_stats', '{replica}') ORDER BY (analysis_date, team_id, event) SETTINGS index_granularity = 8192;-CREATE TABLE posthog.metrics_exemplars (- team_id UInt64,- timestamp DateTime64(3, 'UTC'),- id UInt64,- value Float64,- labels_json String-) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_exemplars', '{replica}') ORDER BY (team_id, id, timestamp) PARTITION BY toYYYYMMDD(timestamp) SETTINGS index_granularity = 1024;-CREATE TABLE posthog.metrics_histograms (- team_id UInt64,- metric_name LowCardinality(String),- timestamp DateTime64(3, 'UTC'),- id UInt64,- histogram String,- version UInt64-) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_histograms', '{replica}', version) ORDER BY (team_id, id, timestamp) PARTITION BY toYYYYMMDD(timestamp) SETTINGS index_granularity = 1024;-CREATE TABLE posthog.metrics_label_index (- team_id UInt64,- metric_name LowCardinality(String),- label_name LowCardinality(String),- label_value String,- id UInt64-) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_label_index', '{replica}') ORDER BY (team_id, metric_name, label_name, label_value, id) SETTINGS deduplicate_merge_projection_mode = 'rebuild', index_granularity = 1024;-CREATE TABLE posthog.metrics_metadata (- team_id UInt64,- metric_family_name LowCardinality(String),- type LowCardinality(String),- unit String,- help String,- updated_at DateTime64(3, 'UTC')-) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_metadata', '{replica}', updated_at) ORDER BY (team_id, metric_family_name) SETTINGS index_granularity = 1024;-CREATE TABLE posthog.metrics_samples (- team_id UInt64,- metric_name LowCardinality(String),- timestamp DateTime64(3, 'UTC'),- id UInt64,- value Float64-) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_samples', '{replica}') ORDER BY (team_id, metric_name, id, timestamp) PARTITION BY toYYYYMMDD(timestamp) SETTINGS index_granularity = 1024;-CREATE TABLE posthog.metrics_series (- team_id UInt64,- id UInt64,- metric_name LowCardinality(String),- labels_json String,- min_time DateTime64(3, 'UTC'),- max_time DateTime64(3, 'UTC')-) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_series', '{replica}') ORDER BY (team_id, metric_name, id) SETTINGS index_granularity = 1024;-CREATE TABLE posthog.sharded_query_log_archive (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64),- exception_name String ALIAS errorCodeToName(exception_code),- ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],- ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],- ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],- ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],- ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],- ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],- ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],- ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],- ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],- ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],- ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],- ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],- ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],- ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],- ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],- ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],- ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],- lc_workflow LowCardinality(String) ALIAS log_comment.workflow,- lc_kind LowCardinality(String) ALIAS log_comment.kind,- lc_id String ALIAS CAST(log_comment.id, 'String'),- lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),- lc_access_method LowCardinality(String) ALIAS log_comment.access_method,- lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),- lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),- lc_query_type LowCardinality(String) ALIAS log_comment.query_type,- lc_product LowCardinality(String) ALIAS log_comment.product,- lc_chargeable Bool ALIAS log_comment.chargeable,- lc_name String ALIAS CAST(log_comment.name, 'String'),- lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),- lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),- lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),- lc_user_id Int64 ALIAS log_comment.user_id,- lc_is_impersonated Bool ALIAS log_comment.is_impersonated,- lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),- lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,- lc_insight_id Int64 ALIAS log_comment.insight_id,- lc_cohort_id Int64 ALIAS log_comment.cohort_id,- lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),- lc_experiment_id Int64 ALIAS log_comment.experiment_id,- lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),- lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),- lc_feature LowCardinality(String) ALIAS log_comment.feature,- lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),- lc_warehouse_query Bool ALIAS log_comment.warehouse_query,- lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,- lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),- lc_workload LowCardinality(String) ALIAS log_comment.workload,- lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),- lc_query__query 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')),- lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),- lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),- lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),- lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),- lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),- lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),- lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),- lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,- lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),- lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),- lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')-) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.sharded_query_log_archive', '{replica}-{shard}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets';-CREATE TABLE posthog.sharded_tophog (- timestamp DateTime64(6, 'UTC'),- metric LowCardinality(String),- type LowCardinality(String) DEFAULT 'sum',- key Map(LowCardinality(String), String),- value Float64,- count UInt64 DEFAULT 0,- pipeline LowCardinality(String),- lane LowCardinality(String),- labels Map(LowCardinality(String), String)-) ENGINE = ReplicatedMergeTree('/clickhouse/tables/ops/{shard}/posthog.tophog', '{replica}') 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;-CREATE MATERIALIZED VIEW posthog.metrics_label_index_from_series_mv TO posthog.metrics_label_index (team_id UInt64, metric_name LowCardinality(String), label_name LowCardinality(String), label_value String, id UInt64) AS SELECT- team_id,- metric_name,- tupleElement(label_pair, 1) AS label_name,- tupleElement(label_pair, 2) AS label_value,- id-FROM- posthog.metrics_series ARRAY JOIN JSONExtractKeysAndValues(labels_json, 'String') AS label_pair;-CREATE VIEW posthog.custom_metrics_backups AS WITH- ['ClickHouseCustomMetric_BackupFailed', 'ClickHouseCustomMetric_BackupSuccess', 'ClickHouseCustomMetric_BackupCancelled', 'ClickHouseCustomMetric_BackupAttempts'] AS names,- [toInt64(countIf(status = 'BACKUP_FAILED')), toInt64(countIf(status = 'BACKUP_CREATED')), toInt64(countIf(status = 'BACKUP_CANCELLED')), toInt64(countIf(status = 'CREATING_BACKUP'))] AS values,- ['Number of failed backups', 'Number of successful backups', 'Number of cancelled backups', 'Number of backup attempts'] AS descriptions,- ['gauge', 'gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.backup_log-WHERE event_date = today()-GROUP BY- event_date;-CREATE VIEW posthog.custom_metrics_dictionaries AS SELECT- 'ClickHouseCustomMetric_DictionariesFailed' AS name,- map(- 'instance',- hostname(),- 'database',- d.database,- 'dictionary',- d.dict_name,- 'uuid',- toString(d.uuid),- 'status',- toString(d.status)- ) AS labels,- toUInt64(1) AS value,- 'Dictionary is in FAILED or FAILED_AND_RELOADING status' AS help,- 'gauge' AS type-FROM- (- SELECT name AS dict_name, database, uuid, status- FROM system.dictionaries- WHERE status IN ('FAILED', 'FAILED_AND_RELOADING')- ) AS d;-CREATE VIEW posthog.custom_metrics_part_counts AS SELECT- 'ClickHouseCustomMetric_MaxPartCountPerPartition' AS name,- map('instance', hostname(), 'database', database, 'table', `table`, 'partition', partition) AS labels,- part_count AS value,- 'Maximum number of active parts for any partition in a PostHog table' AS help,- 'gauge' AS type-FROM- (- SELECT database, `table`, partition, count() AS part_count- FROM system.parts- WHERE- active- AND- (database = 'posthog')- GROUP BY- database, `table`, partition- ORDER BY database ASC, `table` ASC, part_count DESC, partition ASC- LIMIT 1 BY database, `table`- );-CREATE VIEW posthog.custom_metrics_replication_queue AS WITH- ['ClickHouseCustomMetric_ReplicationQueueStuckEntries', 'ClickHouseCustomMetric_ReplicationQueueMaxPostponedEntrySeconds', 'ClickHouseCustomMetric_ReplicationQueueMaxErrorEntrySeconds'] AS names,- [toInt64(countIf(create_time < (now() - toIntervalDay(15)))), maxIf(dateDiff('seconds', create_time, last_postpone_time), last_postpone_time != '1970-01-01'), maxIf(dateDiff('seconds', create_time, last_exception_time), (last_exception_time != '1970-01-01') AND (last_exception_time > (now() - toIntervalMinute(5))))] AS values,- ['Number of entries that have been in the replication queue for more than 15 days', 'Maximum number of seconds that an entry has been postponed', 'Maximum number of seconds that an entry has been in error'] AS descriptions,- ['gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('table', `table`, 'instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.replication_queue-GROUP BY- `table`-HAVING- value > 0;-CREATE VIEW posthog.custom_metrics_server_crash AS SELECT- 'ClickHouseCustomMetric_ServerCrash' AS name,- map('instance', hostname()) AS labels,- count() AS value,- 'Number of server crashes for current date' AS help,- 'gauge' AS type-FROM system.crash_log-WHERE event_date = today()-GROUP BY- hostname();-CREATE VIEW posthog.custom_metrics_table_sizes AS SELECT- 'ClickHouseCustomMetric_TableTotalBytes' AS name,- map('instance', hostname(), 'database', database, 'table', `table`) AS labels,- CAST(total_bytes, 'Float64') AS value,- 'Size of a database table on a given node (need a sum for sharded)' AS help,- 'gauge' AS type-FROM system.tables-WHERE- (database NOT IN ('INFORMATION_SCHEMA', 'information_schema'))-AND- (total_bytes IS NOT NULL);-CREATE VIEW posthog.custom_metrics_test AS SELECT- 'ClickHouseCustomMetric_Test' AS name,- map('instance', hostname()) AS labels,- 1 AS value,- 'Test to check that the metric endpoint is working' AS help,- 'gauge' AS type;-CREATE TABLE posthog.query_log_archive (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64),- exception_name String ALIAS errorCodeToName(exception_code),- ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],- ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],- ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],- ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],- ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],- ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],- ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],- ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],- ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],- ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],- ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],- ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],- ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],- ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],- ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],- ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],- ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],- lc_workflow LowCardinality(String) ALIAS log_comment.workflow,- lc_kind LowCardinality(String) ALIAS log_comment.kind,- lc_id String ALIAS CAST(log_comment.id, 'String'),- lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),- lc_access_method LowCardinality(String) ALIAS log_comment.access_method,- lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),- lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),- lc_query_type LowCardinality(String) ALIAS log_comment.query_type,- lc_product LowCardinality(String) ALIAS log_comment.product,- lc_chargeable Bool ALIAS log_comment.chargeable,- lc_name String ALIAS CAST(log_comment.name, 'String'),- lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),- lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),- lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),- lc_user_id Int64 ALIAS log_comment.user_id,- lc_is_impersonated Bool ALIAS log_comment.is_impersonated,- lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),- lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,- lc_insight_id Int64 ALIAS log_comment.insight_id,- lc_cohort_id Int64 ALIAS log_comment.cohort_id,- lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),- lc_experiment_id Int64 ALIAS log_comment.experiment_id,- lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),- lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),- lc_feature LowCardinality(String) ALIAS log_comment.feature,- lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),- lc_warehouse_query Bool ALIAS log_comment.warehouse_query,- lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,- lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),- lc_workload LowCardinality(String) ALIAS log_comment.workload,- lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),- lc_query__query 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')),- lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),- lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),- lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),- lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),- lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),- lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),- lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),- lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,- lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),- lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),- lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')-) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');-CREATE TABLE posthog.query_log_archive_buffer (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64)-) ENGINE = Buffer('posthog', 'sharded_query_log_archive', 16, 10, 60, 10000, 1000000, 10000000, 100000000);-CREATE TABLE posthog.writable_query_log_archive (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64)-) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');-CREATE MATERIALIZED VIEW posthog.ops_query_log_archive_mv TO posthog.writable_query_log_archive (hostname LowCardinality(String), user LowCardinality(String), query_id String, initial_query_id String, is_initial_query UInt8, type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4), event_date Date, event_time DateTime, event_time_microseconds DateTime64(6), query_start_time DateTime, query_start_time_microseconds DateTime64(6), query_duration_ms UInt64, read_rows UInt64, read_bytes UInt64, written_rows UInt64, written_bytes UInt64, result_rows UInt64, result_bytes UInt64, memory_usage UInt64, peak_threads_usage UInt64, current_database LowCardinality(String), query String, formatted_query String, normalized_query_hash UInt64, query_kind LowCardinality(String), exception_code Int32, exception String, stack_trace String, team_id Int64, log_comment String, ProfileEvents Map(LowCardinality(String), UInt64)) AS SELECT- hostname,- user,- query_id,- initial_query_id,- is_initial_query,- type,- event_date,- event_time,- event_time_microseconds,- query_start_time,- query_start_time_microseconds,- query_duration_ms,- read_rows,- read_bytes,- written_rows,- written_bytes,- result_rows,- result_bytes,- memory_usage,- peak_threads_usage,- current_database,- query,- formatted_query,- normalized_query_hash,- query_kind,- exception_code,- exception,- stack_trace,- JSONExtractInt(log_comment, 'team_id') AS team_id,- if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,- ProfileEvents-FROM system.query_log-WHERE type != 'QueryStart';-CREATE VIEW posthog.custom_metrics AS 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/sql/prod-us/ops.sql b/posthog/clickhouse/hcl/sql/prod-us/ops.sqldeleted file mode 100644index 9adb8860bf2a..000000000000--- a/posthog/clickhouse/hcl/sql/prod-us/ops.sql+++ /dev/null@@ -1,600 +0,0 @@--- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.--- Full CREATE schema for the prod-us/ops node. Apply to a fresh ClickHouse to build it.--CREATE TABLE posthog.events_main (- uuid UUID,- event String,- properties String,- timestamp DateTime64(6, 'UTC'),- team_id Int64,- distinct_id String,- elements_chain String,- created_at DateTime64(6, 'UTC'),- person_id UUID,- person_created_at DateTime64(3),- person_properties String,- group0_properties String,- group1_properties String,- group2_properties String,- group3_properties String,- group4_properties String,- group0_created_at DateTime64(3),- group1_created_at DateTime64(3),- group2_created_at DateTime64(3),- group3_created_at DateTime64(3),- group4_created_at DateTime64(3),- person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),- _timestamp DateTime,- _offset UInt64,- inserted_at DateTime64(6, 'UTC')-) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));-CREATE TABLE posthog.events_recent (- uuid UUID,- event String,- properties String,- timestamp DateTime64(6, 'UTC'),- team_id Int64,- distinct_id String,- elements_chain String,- created_at DateTime64(6, 'UTC'),- person_id UUID,- person_created_at DateTime64(3),- person_properties String,- group0_properties String,- group1_properties String,- group2_properties String,- group3_properties String,- group4_properties String,- group0_created_at DateTime64(3),- group1_created_at DateTime64(3),- group2_created_at DateTime64(3),- group3_created_at DateTime64(3),- group4_created_at DateTime64(3),- person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),- _timestamp DateTime,- _offset UInt64,- inserted_at DateTime64(6, 'UTC')-) ENGINE = Distributed('batch_exports', 'posthog', 'sharded_events_recent', sipHash64(distinct_id));-CREATE TABLE posthog.events_team_daily_stats (- analysis_date Date,- team_id Int64,- event String,- event_count UInt64,- total_event_bytes UInt64,- min_event_bytes UInt64,- max_event_bytes UInt64,- avg_event_bytes Float64,- p50_event_bytes Float64,- p90_event_bytes Float64,- p95_event_bytes Float64,- p99_event_bytes Float64,- event_size_histogram Array(Tuple(Float64, Float64, UInt64)),- computed_at DateTime-) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.events_team_daily_stats', '{replica}') ORDER BY (analysis_date, team_id, event) SETTINGS index_granularity = 8192;-CREATE TABLE posthog.metrics_exemplars (- team_id UInt64,- timestamp DateTime64(3, 'UTC'),- id UInt64,- value Float64,- labels_json String-) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_exemplars', '{replica}') ORDER BY (team_id, id, timestamp) PARTITION BY toYYYYMMDD(timestamp) SETTINGS index_granularity = 1024;-CREATE TABLE posthog.metrics_histograms (- team_id UInt64,- metric_name LowCardinality(String),- timestamp DateTime64(3, 'UTC'),- id UInt64,- histogram String,- version UInt64-) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_histograms', '{replica}', version) ORDER BY (team_id, id, timestamp) PARTITION BY toYYYYMMDD(timestamp) SETTINGS index_granularity = 1024;-CREATE TABLE posthog.metrics_label_index (- team_id UInt64,- metric_name LowCardinality(String),- label_name LowCardinality(String),- label_value String,- id UInt64-) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_label_index', '{replica}') ORDER BY (team_id, metric_name, label_name, label_value, id) SETTINGS deduplicate_merge_projection_mode = 'rebuild', index_granularity = 1024;-CREATE TABLE posthog.metrics_metadata (- team_id UInt64,- metric_family_name LowCardinality(String),- type LowCardinality(String),- unit String,- help String,- updated_at DateTime64(3, 'UTC')-) ENGINE = ReplicatedReplacingMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_metadata', '{replica}', updated_at) ORDER BY (team_id, metric_family_name) SETTINGS index_granularity = 1024;-CREATE TABLE posthog.metrics_samples (- team_id UInt64,- metric_name LowCardinality(String),- timestamp DateTime64(3, 'UTC'),- id UInt64,- value Float64-) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_samples', '{replica}') ORDER BY (team_id, metric_name, id, timestamp) PARTITION BY toYYYYMMDD(timestamp) SETTINGS index_granularity = 1024;-CREATE TABLE posthog.metrics_series (- team_id UInt64,- id UInt64,- metric_name LowCardinality(String),- labels_json String,- min_time DateTime64(3, 'UTC'),- max_time DateTime64(3, 'UTC')-) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_series', '{replica}') ORDER BY (team_id, metric_name, id) SETTINGS index_granularity = 1024;-CREATE TABLE posthog.sharded_query_log_archive (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64),- exception_name String ALIAS errorCodeToName(exception_code),- ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],- ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],- ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],- ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],- ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],- ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],- ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],- ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],- ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],- ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],- ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],- ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],- ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],- ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],- ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],- ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],- ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],- lc_workflow LowCardinality(String) ALIAS log_comment.workflow,- lc_kind LowCardinality(String) ALIAS log_comment.kind,- lc_id String ALIAS CAST(log_comment.id, 'String'),- lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),- lc_access_method LowCardinality(String) ALIAS log_comment.access_method,- lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),- lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),- lc_query_type LowCardinality(String) ALIAS log_comment.query_type,- lc_product LowCardinality(String) ALIAS log_comment.product,- lc_chargeable Bool ALIAS log_comment.chargeable,- lc_name String ALIAS CAST(log_comment.name, 'String'),- lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),- lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),- lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),- lc_user_id Int64 ALIAS log_comment.user_id,- lc_is_impersonated Bool ALIAS log_comment.is_impersonated,- lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),- lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,- lc_insight_id Int64 ALIAS log_comment.insight_id,- lc_cohort_id Int64 ALIAS log_comment.cohort_id,- lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),- lc_experiment_id Int64 ALIAS log_comment.experiment_id,- lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),- lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),- lc_feature LowCardinality(String) ALIAS log_comment.feature,- lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),- lc_warehouse_query Bool ALIAS log_comment.warehouse_query,- lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,- lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),- lc_workload LowCardinality(String) ALIAS log_comment.workload,- lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),- lc_query__query 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')),- lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),- lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),- lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),- lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),- lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),- lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),- lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),- lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,- lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),- lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),- lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), ''),- ProfileEvents2 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)-) ENGINE = ReplicatedMergeTree('/clickhouse/tables/noshard/posthog.sharded_query_log_archive', '{replica}-{shard}') ORDER BY (team_id, event_date, event_time, query_id) PARTITION BY toYYYYMM(event_date) SETTINGS index_granularity = 8192, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets';-CREATE TABLE posthog.sharded_tophog (- timestamp DateTime64(6, 'UTC'),- metric LowCardinality(String),- type LowCardinality(String) DEFAULT 'sum',- key Map(LowCardinality(String), String),- value Float64,- count UInt64 DEFAULT 0,- pipeline LowCardinality(String),- lane LowCardinality(String),- labels Map(LowCardinality(String), String)-) ENGINE = ReplicatedMergeTree('/clickhouse/tables/ops/{shard}/posthog.tophog_new', '{replica}') 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;-CREATE MATERIALIZED VIEW posthog.metrics_label_index_from_series_mv TO posthog.metrics_label_index (team_id UInt64, metric_name LowCardinality(String), label_name LowCardinality(String), label_value String, id UInt64) AS SELECT- team_id,- metric_name,- tupleElement(label_pair, 1) AS label_name,- tupleElement(label_pair, 2) AS label_value,- id-FROM- posthog.metrics_series ARRAY JOIN JSONExtractKeysAndValues(labels_json, 'String') AS label_pair;-CREATE VIEW posthog.custom_metrics_backups AS WITH- ['ClickHouseCustomMetric_BackupFailed', 'ClickHouseCustomMetric_BackupSuccess', 'ClickHouseCustomMetric_BackupCancelled', 'ClickHouseCustomMetric_BackupAttempts'] AS names,- [toInt64(countIf(status = 'BACKUP_FAILED')), toInt64(countIf(status = 'BACKUP_CREATED')), toInt64(countIf(status = 'BACKUP_CANCELLED')), toInt64(countIf(status = 'CREATING_BACKUP'))] AS values,- ['Number of failed backups', 'Number of successful backups', 'Number of cancelled backups', 'Number of backup attempts'] AS descriptions,- ['gauge', 'gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.backup_log-WHERE event_date = today()-GROUP BY- event_date;-CREATE VIEW posthog.custom_metrics_dictionaries AS SELECT- 'ClickHouseCustomMetric_DictionariesFailed' AS name,- map(- 'instance',- hostname(),- 'database',- d.database,- 'dictionary',- d.dict_name,- 'uuid',- toString(d.uuid),- 'status',- toString(d.status)- ) AS labels,- toUInt64(1) AS value,- 'Dictionary is in FAILED or FAILED_AND_RELOADING status' AS help,- 'gauge' AS type-FROM- (- SELECT name AS dict_name, database, uuid, status- FROM system.dictionaries- WHERE status IN ('FAILED', 'FAILED_AND_RELOADING')- ) AS d;-CREATE VIEW posthog.custom_metrics_part_counts AS SELECT- 'ClickHouseCustomMetric_MaxPartCountPerPartition' AS name,- map('instance', hostname(), 'database', database, 'table', `table`, 'partition', partition) AS labels,- part_count AS value,- 'Maximum number of active parts for any partition in a PostHog table' AS help,- 'gauge' AS type-FROM- (- SELECT database, `table`, partition, count() AS part_count- FROM system.parts- WHERE- active- AND- (database = 'posthog')- GROUP BY- database, `table`, partition- ORDER BY database ASC, `table` ASC, part_count DESC, partition ASC- LIMIT 1 BY database, `table`- );-CREATE VIEW posthog.custom_metrics_replication_queue AS WITH- ['ClickHouseCustomMetric_ReplicationQueueStuckEntries', 'ClickHouseCustomMetric_ReplicationQueueMaxPostponedEntrySeconds', 'ClickHouseCustomMetric_ReplicationQueueMaxErrorEntrySeconds'] AS names,- [toInt64(countIf(create_time < (now() - toIntervalDay(15)))), maxIf(dateDiff('seconds', create_time, last_postpone_time), last_postpone_time != '1970-01-01'), maxIf(dateDiff('seconds', create_time, last_exception_time), (last_exception_time != '1970-01-01') AND (last_exception_time > (now() - toIntervalMinute(5))))] AS values,- ['Number of entries that have been in the replication queue for more than 15 days', 'Maximum number of seconds that an entry has been postponed', 'Maximum number of seconds that an entry has been in error'] AS descriptions,- ['gauge', 'gauge', 'gauge'] AS types,- arrayJoin(arrayZip(names, values, descriptions, types)) AS tpl-SELECT- tpl.1 AS name,- map('table', `table`, 'instance', hostname()) AS labels,- tpl.2 AS value,- tpl.3 AS help,- tpl.4 AS type-FROM system.replication_queue-GROUP BY- `table`-HAVING- value > 0;-CREATE VIEW posthog.custom_metrics_server_crash AS SELECT- 'ClickHouseCustomMetric_ServerCrash' AS name,- map('instance', hostname()) AS labels,- count() AS value,- 'Number of server crashes for current date' AS help,- 'gauge' AS type-FROM system.crash_log-WHERE event_date = today()-GROUP BY- hostname();-CREATE VIEW posthog.custom_metrics_table_sizes AS SELECT- 'ClickHouseCustomMetric_TableTotalBytes' AS name,- map('instance', hostname(), 'database', database, 'table', `table`) AS labels,- CAST(total_bytes, 'Float64') AS value,- 'Size of a database table on a given node (need a sum for sharded)' AS help,- 'gauge' AS type-FROM system.tables-WHERE- (database NOT IN ('INFORMATION_SCHEMA', 'information_schema'))-AND- (total_bytes IS NOT NULL);-CREATE VIEW posthog.custom_metrics_test AS SELECT- 'ClickHouseCustomMetric_Test' AS name,- map('instance', hostname()) AS labels,- 1 AS value,- 'Test to check that the metric endpoint is working' AS help,- 'gauge' AS type;-CREATE TABLE posthog.query_log_archive (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64),- exception_name String ALIAS errorCodeToName(exception_code),- ProfileEvents_RealTimeMicroseconds Int64 ALIAS ProfileEvents['RealTimeMicroseconds'],- ProfileEvents_OSCPUVirtualTimeMicroseconds Int64 ALIAS ProfileEvents['OSCPUVirtualTimeMicroseconds'],- ProfileEvents_S3Clients Int64 ALIAS ProfileEvents['S3Clients'],- ProfileEvents_S3DeleteObjects Int64 ALIAS ProfileEvents['S3DeleteObjects'],- ProfileEvents_S3CopyObject Int64 ALIAS ProfileEvents['S3CopyObject'],- ProfileEvents_S3ListObjects Int64 ALIAS ProfileEvents['S3ListObjects'],- ProfileEvents_S3HeadObject Int64 ALIAS ProfileEvents['S3HeadObject'],- ProfileEvents_S3GetObjectAttributes Int64 ALIAS ProfileEvents['S3GetObjectAttributes'],- ProfileEvents_S3CreateMultipartUpload Int64 ALIAS ProfileEvents['S3CreateMultipartUpload'],- ProfileEvents_S3UploadPartCopy Int64 ALIAS ProfileEvents['S3UploadPartCopy'],- ProfileEvents_S3UploadPart Int64 ALIAS ProfileEvents['S3UploadPart'],- ProfileEvents_S3AbortMultipartUpload Int64 ALIAS ProfileEvents['S3AbortMultipartUpload'],- ProfileEvents_S3CompleteMultipartUpload Int64 ALIAS ProfileEvents['S3CompleteMultipartUpload'],- ProfileEvents_S3PutObject Int64 ALIAS ProfileEvents['S3PutObject'],- ProfileEvents_S3GetObject Int64 ALIAS ProfileEvents['S3GetObject'],- ProfileEvents_ReadBufferFromS3Bytes Int64 ALIAS ProfileEvents['ReadBufferFromS3Bytes'],- ProfileEvents_WriteBufferFromS3Bytes Int64 ALIAS ProfileEvents['WriteBufferFromS3Bytes'],- lc_workflow LowCardinality(String) ALIAS log_comment.workflow,- lc_kind LowCardinality(String) ALIAS log_comment.kind,- lc_id String ALIAS CAST(log_comment.id, 'String'),- lc_route_id String ALIAS CAST(log_comment.route_id, 'String'),- lc_access_method LowCardinality(String) ALIAS log_comment.access_method,- lc_api_key_label String ALIAS CAST(log_comment.api_key_label, 'String'),- lc_api_key_mask String ALIAS CAST(log_comment.api_key_mask, 'String'),- lc_query_type LowCardinality(String) ALIAS log_comment.query_type,- lc_product LowCardinality(String) ALIAS log_comment.product,- lc_chargeable Bool ALIAS log_comment.chargeable,- lc_name String ALIAS CAST(log_comment.name, 'String'),- lc_request_name String ALIAS CAST(log_comment.request_name, 'String'),- lc_client_query_id String ALIAS CAST(log_comment.client_query_id, 'String'),- lc_org_id String ALIAS CAST(log_comment.org_id, 'String'),- lc_user_id Int64 ALIAS log_comment.user_id,- lc_is_impersonated Bool ALIAS log_comment.is_impersonated,- lc_session_id String ALIAS CAST(log_comment.session_id, 'String'),- lc_dashboard_id Int64 ALIAS log_comment.dashboard_id,- lc_insight_id Int64 ALIAS log_comment.insight_id,- lc_cohort_id Int64 ALIAS log_comment.cohort_id,- lc_batch_export_id String ALIAS CAST(log_comment.batch_export_id, 'String'),- lc_experiment_id Int64 ALIAS log_comment.experiment_id,- lc_experiment_feature_flag_key String ALIAS CAST(log_comment.experiment_feature_flag_key, 'String'),- lc_alert_config_id String ALIAS CAST(log_comment.alert_config_id, 'String'),- lc_feature LowCardinality(String) ALIAS log_comment.feature,- lc_table_id String ALIAS CAST(log_comment.table_id, 'String'),- lc_warehouse_query Bool ALIAS log_comment.warehouse_query,- lc_person_on_events_mode LowCardinality(String) ALIAS log_comment.person_on_events_mode,- lc_service_name String ALIAS CAST(log_comment.service_name, 'String'),- lc_workload LowCardinality(String) ALIAS log_comment.workload,- lc_query__kind LowCardinality(String) ALIAS if(JSONHas(toString(log_comment), 'query', 'source'), JSONExtractString(toString(log_comment), 'query', 'source', 'kind'), JSONExtractString(toString(log_comment), 'query', 'kind')),- lc_query__query 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')),- lc_query String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'query'), ''),- lc_temporal__workflow_namespace String ALIAS CAST(log_comment.`temporal.workflow_namespace`, 'String'),- lc_temporal__workflow_type String ALIAS CAST(log_comment.`temporal.workflow_type`, 'String'),- lc_temporal__workflow_id String ALIAS CAST(log_comment.`temporal.workflow_id`, 'String'),- lc_temporal__workflow_run_id String ALIAS CAST(log_comment.`temporal.workflow_run_id`, 'String'),- lc_temporal__activity_type String ALIAS CAST(log_comment.`temporal.activity_type`, 'String'),- lc_temporal__activity_id String ALIAS CAST(log_comment.`temporal.activity_id`, 'String'),- lc_temporal__attempt Int64 ALIAS log_comment.`temporal.attempt`,- lc_dagster__job_name String ALIAS CAST(log_comment.`dagster.job_name`, 'String'),- lc_dagster__run_id String ALIAS CAST(log_comment.`dagster.run_id`, 'String'),- lc_dagster__owner String ALIAS CAST(log_comment.`dagster.tags.owner`, 'String'),- lc_modifiers String ALIAS if(is_initial_query, JSONExtractRaw(toString(log_comment), 'modifiers'), '')-) ENGINE = Distributed('ops', 'posthog', 'sharded_query_log_archive');-CREATE TABLE posthog.query_log_archive_buffer (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64)-) ENGINE = Buffer('posthog', 'sharded_query_log_archive', 16, 10, 60, 10000, 1000000, 10000000, 100000000);-CREATE TABLE posthog.writable_query_log_archive (- hostname LowCardinality(String),- user LowCardinality(String),- query_id String,- initial_query_id String,- is_initial_query UInt8,- type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4),- event_date Date,- event_time DateTime,- event_time_microseconds DateTime64(6),- query_start_time DateTime,- query_start_time_microseconds DateTime64(6),- query_duration_ms UInt64,- read_rows UInt64,- read_bytes UInt64,- written_rows UInt64,- written_bytes UInt64,- result_rows UInt64,- result_bytes UInt64,- memory_usage UInt64,- peak_threads_usage UInt64,- current_database LowCardinality(String),- query String,- formatted_query String,- normalized_query_hash UInt64,- query_kind LowCardinality(String),- exception_code Int32,- exception String,- stack_trace String,- team_id Int64,- log_comment 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),- ProfileEvents Map(String, UInt64)-) ENGINE = Distributed('ops', 'posthog', 'query_log_archive_buffer');-CREATE MATERIALIZED VIEW posthog.ops_query_log_archive_mv TO posthog.writable_query_log_archive (hostname LowCardinality(String), user LowCardinality(String), query_id String, initial_query_id String, is_initial_query UInt8, type Enum8('QueryStart'=1, 'QueryFinish'=2, 'ExceptionBeforeStart'=3, 'ExceptionWhileProcessing'=4), event_date Date, event_time DateTime, event_time_microseconds DateTime64(6), query_start_time DateTime, query_start_time_microseconds DateTime64(6), query_duration_ms UInt64, read_rows UInt64, read_bytes UInt64, written_rows UInt64, written_bytes UInt64, result_rows UInt64, result_bytes UInt64, memory_usage UInt64, peak_threads_usage UInt64, current_database LowCardinality(String), query String, formatted_query String, normalized_query_hash UInt64, query_kind LowCardinality(String), exception_code Int32, exception String, stack_trace String, team_id Int64, log_comment String, ProfileEvents Map(LowCardinality(String), UInt64)) AS SELECT- hostname,- user,- query_id,- initial_query_id,- is_initial_query,- type,- event_date,- event_time,- event_time_microseconds,- query_start_time,- query_start_time_microseconds,- query_duration_ms,- read_rows,- read_bytes,- written_rows,- written_bytes,- result_rows,- result_bytes,- memory_usage,- peak_threads_usage,- current_database,- query,- formatted_query,- normalized_query_hash,- query_kind,- exception_code,- exception,- stack_trace,- JSONExtractInt(log_comment, 'team_id') AS team_id,- if(isValidJSON(log_comment), log_comment, '{}') AS log_comment,- ProfileEvents-FROM system.query_log-WHERE type != 'QueryStart';-CREATE VIEW posthog.custom_metrics AS 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- );