Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(clickhouse): repair the kafka engine model and restore ops envs (#93456)

Paweł Szczura6c11b1fca10
diff --git a/posthog/clickhouse/hcl/README.md b/posthog/clickhouse/hcl/README.md
index 790a33205684..f62557915d20 100644
--- a/posthog/clickhouse/hcl/README.md
+++ b/posthog/clickhouse/hcl/README.md
@@ -5,8 +5,7 @@ Source of truth for satellite ClickHouse clusters, managed declaratively with
Schemas are written in HCL, **composed per node** `(env, role)`, verified against
captured cluster dumps, and used to generate the migration that applies a change.
-Covers the satellite roles (logs, aux, `ai_events`, sessions, `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.
+Covers the satellite roles (ops, logs, aux, `ai_events`, sessions, `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.
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)).
@@ -40,6 +39,7 @@ hcl/
check.sh # CI guard (offline): validate + diff every node vs golden + verify golden/ & sql/ are fresh
dump-live.sh # CI gate step 1 (live): introspect the migrated OPS/LOGS nodes into HCL dumps
check-live.sh # CI gate step 2 (offline): diff those dumps vs golden — catches migrations that desync from the HCL
+ check-cloud.sh # manual, needs sibling checkouts: compose vs the cloud node dumps + posthog-cloud-infra still composes
exclude.hcl # objects the gate drops (transient + cross-cluster proxies + out-of-band-managed, not in the managed set)
diff.sh # preview the DDL your uncommitted edits produce, per node
gen-golden.sh # (re)generate golden/ — hclexp load per node
@@ -227,6 +227,24 @@ The cloud envs compose the same base layers, vendored by commit sha, plus privat
After a base change merges here, a **base-ref bump PR** there advances the pinned sha, regenerates the cloud goldens (your change now appears in every env's composed output), and produces the ordered migration SQL for the cloud clusters.
That PR runs the strict check (goldens asserted, baseline exact), so the golden movement the compose gate waved through gets reviewed and applied there.
+### Checking both sides locally (`check-cloud.sh`)
+
+`check.sh` is hermetic and deliberately knows nothing about the cloud.
+`check-cloud.sh` is the manual pass that answers the two questions it cannot, given the sibling checkouts:
+
+```bash
+bash posthog/clickhouse/hcl/check-cloud.sh # ../clickhouse-schema and ../posthog-cloud-infra
+bash posthog/clickhouse/hcl/check-cloud.sh prod-us # one env
+DUMPS=<path> CLOUD_INFRA=<path> bash posthog/clickhouse/hcl/check-cloud.sh
+```
+
+It reconciles every composed node against the per-node dumps in PostHog/clickhouse-schema, and replays the compose gate against your working tree, so you learn before pushing whether a layer you moved or renamed breaks posthog-cloud-infra.
+Each half is skipped, loudly, when its checkout is absent.
+It copies posthog-cloud-infra's tree to a scratch dir before vendoring into it, so it never leaves that checkout in a state that disagrees with its own `base-ref`.
+
+A red run is not a build break: the dump repo refreshes daily, so its answer changes without this repo changing.
+Read it as drift to catalog or a fix to make.
+
## Build a node from scratch
`sql/<env>/<role>.sql` is the full, dependency-ordered CREATE schema for that node — e.g. apply
diff --git a/posthog/clickhouse/hcl/bin/hclexp b/posthog/clickhouse/hcl/bin/hclexp
index 620d1a89a4b2..83083c36a2d7 100755
--- a/posthog/clickhouse/hcl/bin/hclexp
+++ b/posthog/clickhouse/hcl/bin/hclexp
@@ -27,5 +27,13 @@ fi
# Mount the repo (relative layer/golden paths resolve under -w /work) and the temp
# dir (diff.sh/gen-sql.sh/the generator pass absolute committed-tree and scratch paths
# under $TMPDIR) so both resolve inside the container.
+#
+# $HCLEXP_MOUNT bind-mounts one more host dir at its own path, for inputs that
+# legitimately live outside the repo — check-cloud.sh reading the sibling
+# PostHog/clickhouse-schema checkout is the case this exists for. Without it any
+# path outside $PWD and $TMPDIR simply is not there, and hclexp reports the file
+# as missing rather than as unmounted.
TMP="${TMPDIR:-/tmp}"; TMP="${TMP%/}"
-exec docker run --rm -v "$PWD:/work" -v "$TMP:$TMP" -w /work "$HCLEXP_IMAGE" "$@"
+exec docker run --rm \
+ -v "$PWD:/work" -v "$TMP:$TMP" ${HCLEXP_MOUNT:+-v "$HCLEXP_MOUNT:$HCLEXP_MOUNT"} \
+ -w /work "$HCLEXP_IMAGE" "$@"
diff --git a/posthog/clickhouse/hcl/bin/image.txt b/posthog/clickhouse/hcl/bin/image.txt
index d03fa49820df..a4575c1a6633 100644
--- a/posthog/clickhouse/hcl/bin/image.txt
+++ b/posthog/clickhouse/hcl/bin/image.txt
@@ -1 +1 @@
-ghcr.io/posthog/chschema:sha-81cef08
+ghcr.io/posthog/chschema:sha-89109e5
diff --git a/posthog/clickhouse/hcl/check-cloud.sh b/posthog/clickhouse/hcl/check-cloud.sh
new file mode 100755
index 000000000000..69d901577077
--- /dev/null
+++ b/posthog/clickhouse/hcl/check-cloud.sh
@@ -0,0 +1,159 @@
+#!/usr/bin/env bash
+# The two checks that need a repo other than this one.
+#
+# check.sh compose(layers) == golden/ are we self-consistent?
+# check-live.sh golden == a live node does the local stack agree?
+# check-cloud.sh compose(layers) == the cloud nodes are we RIGHT about the cloud?
+# + posthog-cloud-infra still composes against these layers
+#
+# check.sh is the merge gate and is hermetic. This one reads sibling checkouts whose
+# contents change without this repo changing -- the dump repo's bot refreshes it daily
+# -- so a red run here is not a build break. It is either drift to catalog or a real
+# fix to make. Run it deliberately, before moving schema between the two repos.
+#
+# Usage, from the repo root:
+# bash posthog/clickhouse/hcl/check-cloud.sh # both checks, every env
+# bash posthog/clickhouse/hcl/check-cloud.sh prod-us # just one env
+# DUMPS=/path/to/clickhouse-schema bash posthog/clickhouse/hcl/check-cloud.sh
+# CLOUD_INFRA=/path/to/posthog-cloud-infra bash posthog/clickhouse/hcl/check-cloud.sh
+#
+# Either half is skipped, loudly, when its checkout is absent, so this still runs
+# with only one of them.
+#
+# Exit 1 if a composition breaks or an env drifts, so it can drive a scheduled report.
+set -euo pipefail
+
+HCL=posthog/clickhouse/hcl
+HCLEXP="$HCL/bin/hclexp"
+
+. "$HCL/lib.sh"
+
+DUMPS="${DUMPS:-../clickhouse-schema}"
+CLOUD_INFRA="${CLOUD_INFRA:-../posthog-cloud-infra}"
+
+rc=0
+envs="${*:-$(manifest_envs)}"
+
+# ---------------------------------------------------------------------------
+# 1. Reconcile: what we declare vs what the nodes actually run.
+#
+# Read the operations as "what you would run to make the live nodes match this
+# repo". A DROP means the nodes have an object we do not declare, not that
+# anything is about to be dropped -- nothing here applies DDL.
+#
+# .unsafe[] is a separate carrier from .operations[]: a change that needs a table
+# recreated can appear there with no DDL at all, so an env can be drifting with
+# zero operations. Both are counted.
+# ---------------------------------------------------------------------------
+if [ ! -d "$DUMPS" ]; then
+ echo "== reconcile: SKIPPED, no dump repo at $DUMPS (set \$DUMPS) =="
+else
+ # The dump repo sits outside $PWD and $TMPDIR, so the container cannot see it
+ # without an explicit mount. Absolute, because that is the path it mounts at.
+ HCLEXP_MOUNT="$(cd "$DUMPS" && pwd)"
+ export HCLEXP_MOUNT
+ DUMPS="$HCLEXP_MOUNT"
+
+ for env in $envs; do
+ [ -d "$DUMPS/$env" ] || { echo "== $env: no dumps in $DUMPS, skipping =="; continue; }
+
+ json="$("$HCLEXP" plan -manifest "$MANIFEST" -env "$env" -layer-root "$HCL" \
+ -dump "$DUMPS/$env" -exclude "$HCL/exclude.hcl" -format json 2>/dev/null)" || {
+ echo "FAIL: plan $env against $DUMPS/$env"; rc=1; continue
+ }
+
+ nops="$(printf '%s' "$json" | jq '.operations // [] | length')"
+ nunsafe="$(printf '%s' "$json" | jq '.unsafe // [] | length')"
+ roles="$(printf '%s' "$json" | jq -r '[.roles[].role] | join(", ")')"
+
+ if [ "$nops" = 0 ] && [ "$nunsafe" = 0 ]; then
+ echo "== $env: in sync with $DUMPS/$env ($roles) =="
+ continue
+ fi
+
+ echo "== $env: $nops operation(s), $nunsafe unsafe vs $DUMPS/$env ($roles) =="
+ printf '%s' "$json" | jq -r '(.operations // [])[] |
+ " \(.kind) \(.object_type) \(.database // "-").\(.object)\(if .unsafe then " [UNSAFE]" else "" end)"'
+ printf '%s' "$json" | jq -r '(.unsafe // [])[] | " !! UNSAFE \(.object): \(.reason)"'
+ rc=1
+ done
+fi
+
+# ---------------------------------------------------------------------------
+# 2. The compose gate, locally.
+#
+# posthog-cloud-infra pins this repo at its base-ref and sparse-vendors layers on
+# demand. CI proves it still composes by dispatching a workflow there against this
+# branch; this reproduces that answer offline.
+#
+# Its checkout is copied to a scratch dir first and vendored there. Vendoring into
+# the real one would leave a tree that does not match its base-ref, which is a
+# confusing state to hand back to someone.
+# ---------------------------------------------------------------------------
+if [ ! -d "$CLOUD_INFRA/clickhouse/hcl" ]; then
+ echo "== compose gate: SKIPPED, no posthog-cloud-infra at $CLOUD_INFRA (set \$CLOUD_INFRA) =="
+else
+ stage="$(mktemp -d)"
+ trap 'rm -rf "$stage"' EXIT
+ cp -R "$CLOUD_INFRA/clickhouse" "$stage/clickhouse"
+ CI_HCL="$stage/clickhouse/hcl"
+ CI_MANIFEST="$CI_HCL/manifest.hcl"
+ vendor="$CI_HCL/vendor/posthog-hcl"
+ rm -rf "$vendor"
+
+ # Vendor exactly what its manifest names, the way bin/vendor-base.sh does, but
+ # from the working tree instead of from base-ref: the question is whether THIS
+ # tree still composes there.
+ missing=""
+ for path in $(grep -oE '"vendor/posthog-hcl/[^"]+"' "$CI_MANIFEST" | tr -d '"' | sort -u); do
+ rel="${path#vendor/posthog-hcl/}"
+ if [ ! -e "$HCL/$rel" ]; then
+ missing="$missing $rel"$'\n'
+ continue
+ fi
+ mkdir -p "$vendor/$(dirname "$rel")"
+ cp -R "$HCL/$rel" "$vendor/$rel"
+ done
+
+ if [ -n "$missing" ]; then
+ echo "FAIL: posthog-cloud-infra's manifest references layers this tree does not have:"
+ printf '%s' "$missing"
+ echo " Removing or renaming a vendored layer breaks its composition -- add it back, or land the rename there first."
+ rc=1
+ fi
+
+ echo "== compose gate: posthog-cloud-infra vs this working tree =="
+ for env in $(MANIFEST="$CI_MANIFEST" manifest_envs); do
+ # -skip-validation '*' matches its own check.sh: the cross-cluster remotes it
+ # cannot resolve are roles that repo does not compose, so they are skipped there
+ # too. This asks the narrower question the gate asks -- does it still compose.
+ if "$HCLEXP" validate -manifest "$CI_MANIFEST" -env "$env" -layer-root "$CI_HCL" \
+ -skip-validation '*' >/dev/null 2>&1; then
+ echo " $env: composes"
+ else
+ echo " FAIL: $env does not compose against these layers"
+ "$HCLEXP" validate -manifest "$CI_MANIFEST" -env "$env" -layer-root "$CI_HCL" \
+ -skip-validation '*' 2>&1 | sed 's/^/ /' | tail -20
+ rc=1
+ fi
+ done
+
+ # Its once-only guard reads across both repos' layers at once, so a hoist here can
+ # collide with something it declares. Its baseline is the reference, not ours.
+ ci_baseline="$CI_HCL/duplicates-baseline.txt"
+ if [ -f "$ci_baseline" ]; then
+ cur="$("$HCLEXP" locate -manifest "$CI_MANIFEST" -layer-root "$CI_HCL" -duplicates -format json 2>/dev/null \
+ | jq -r '.duplicates[]? | "\(.database).\(.name)"' | sort -u || true)"
+ base="$(grep -vE '^[[:space:]]*(#|$)' "$ci_baseline" | sort -u || true)"
+ new="$(comm -13 <(printf '%s\n' "$base") <(printf '%s\n' "$cur") | grep -v '^$' || true)"
+ if [ -n "$new" ]; then
+ echo " FAIL: these objects become duplicates in posthog-cloud-infra's composition:"
+ printf '%s\n' "$new" | sed 's/^/ + /'
+ rc=1
+ else
+ echo " duplicates: no new entries against its baseline"
+ fi
+ fi
+fi
+
+exit $rc
diff --git a/posthog/clickhouse/hcl/exclude-local-single.hcl b/posthog/clickhouse/hcl/exclude-local-single.hcl
index c7c05d2987d5..84ee008f9891 100644
--- a/posthog/clickhouse/hcl/exclude-local-single.hcl
+++ b/posthog/clickhouse/hcl/exclude-local-single.hcl
@@ -8,11 +8,11 @@
# exclude.hcl's `*_staging` / `*_backfill` globs are also too broad for this node — they
# match real objects (web_pre_aggregated_*_staging tables, *_batch_export_backfill views)
# — so this file spells the transient patterns out rather than reusing them wholesale.
+#
+# Kafka named collections stay in the dump for the same reason as in exclude.hcl: a
+# dump without them cannot resolve the kafka_* tables that name them.
exclude {
- # Secret Kafka broker/credential config; never modeled in the goldens.
- object_types = ["named_collection"]
-
patterns = [
# --- transient (ClickHouse atomic CREATE-OR-REPLACE / EXCHANGE) ---
"_tmp_replace_*",
diff --git a/posthog/clickhouse/hcl/exclude.hcl b/posthog/clickhouse/hcl/exclude.hcl
index 902d327a2b56..cb633d414173 100644
--- a/posthog/clickhouse/hcl/exclude.hcl
+++ b/posthog/clickhouse/hcl/exclude.hcl
@@ -6,22 +6,23 @@
# filepath.Match globs against both the bare name ("events_main") and the
# db-qualified form ("posthog.events_main"); object_types drops a whole kind.
#
-# Three classes live here:
-# 1. Whole object kinds the goldens never model (object_types).
-# 2. Transient objects (atomic-replace temporaries, migration/backfill scratch,
+# Two classes live here:
+# 1. Transient objects (atomic-replace temporaries, migration/backfill scratch,
# backups) — never part of the managed schema.
-# 3. Cross-cluster proxies present on the node but intentionally NOT authored in
+# 2. Cross-cluster proxies present on the node but intentionally NOT authored in
# that role's golden — they belong to another role's managed set (e.g. the
# events_* distributed proxies the OPS node carries so it can query the main
# cluster). These are the same names check.sh lists in its validate SKIP.
#
+# Kafka named collections are NOT excluded, despite carrying broker credentials on
+# the server: a dump that drops them cannot resolve the kafka_* tables that name
+# them. They are declared as `external` instead (roles/coshared/named_collections),
+# which binds the reference and stores nothing.
+#
# Grow this list from what the reconciliation pass surfaces — anything the live
# node has that the golden intentionally omits goes here, with a one-line reason.
exclude {
- # Secret Kafka broker/credential config; never modeled in the goldens.
- object_types = ["named_collection"]
-
patterns = [
# --- transient (ClickHouse atomic CREATE-OR-REPLACE / EXCHANGE) ---
"_tmp_replace_*",
@@ -42,6 +43,13 @@ exclude {
"events_main",
"events_recent",
+ # --- infra-created, never by a migration ---
+ # Iceberg readers over the logs archive bucket. The bucket is per environment
+ # and named in the DDL, so declaring these would put one environment's storage
+ # layout in the schema of all of them.
+ "logs_archive",
+ "logs_archive_*",
+
# --- out-of-band managed: real on prod, not created by the local
# migrate_clickhouse path, so the gate ignores them on BOTH sides until
# a proper OPS migration reproduces them locally. Remove each entry once
diff --git a/posthog/clickhouse/hcl/golden/dev/ai_events.hcl b/posthog/clickhouse/hcl/golden/dev/ai_events.hcl
index a812017224ac..2533cd86ef15 100644
--- a/posthog/clickhouse/hcl/golden/dev/ai_events.hcl
+++ b/posthog/clickhouse/hcl/golden/dev/ai_events.hcl
@@ -283,10 +283,10 @@ database "posthog" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ai_events_json'"
- group_name = "kafka_group_name = 'clickhouse_ai_events_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ai_events_json"
+ group_name = "clickhouse_ai_events_ws"
+ format = "JSONEachRow"
num_consumers = 1
max_block_size = 5000
skip_broken_messages = 100
@@ -1268,10 +1268,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -1344,10 +1344,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -1408,3 +1408,39 @@ SQL
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl b/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl
index 49d59398cb6a..a9ebf92f4d5c 100644
--- a/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl
+++ b/posthog/clickhouse/hcl/golden/dev/auxiliary.hcl
@@ -540,10 +540,10 @@ database "posthog" {
type = "UInt8"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
- group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_hog_invocation_results"
+ group_name = "clickhouse_hog_invocation_results"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -565,10 +565,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"
- group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ingestion_warnings"
+ group_name = "clickhouse_ingestion_warnings_v2"
+ format = "JSONEachRow"
}
}
@@ -622,10 +622,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_message_assets'"
- group_name = "kafka_group_name = 'clickhouse_message_assets'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_message_assets"
+ group_name = "clickhouse_message_assets"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -647,10 +647,10 @@ database "posthog" {
type = "UInt64"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_property_values'"
- group_name = "kafka_group_name = 'clickhouse_property_values'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_property_values"
+ group_name = "clickhouse_property_values"
+ format = "JSONEachRow"
num_consumers = 1
thread_per_consumer = true
}
@@ -3912,10 +3912,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -3988,10 +3988,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -4082,3 +4082,39 @@ SQL
}
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/dev/batch_exports.hcl b/posthog/clickhouse/hcl/golden/dev/batch_exports.hcl
index f83e323db06b..000e5af18adc 100644
--- a/posthog/clickhouse/hcl/golden/dev/batch_exports.hcl
+++ b/posthog/clickhouse/hcl/golden/dev/batch_exports.hcl
@@ -756,10 +756,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -832,10 +832,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/golden/dev/logs.hcl b/posthog/clickhouse/hcl/golden/dev/logs.hcl
index 5bf0a5b32502..222fd0112d64 100644
--- a/posthog/clickhouse/hcl/golden/dev/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/dev/logs.hcl
@@ -61,16 +61,16 @@ database "posthog" {
type = "Nullable(Int64)"
}
engine "kafka" {
- broker_list = "warpstream_metrics"
- topic_list = "kafka_topic_list = 'clickhouse_metrics'"
- group_name = "kafka_group_name = 'clickhouse-metrics-avro-new'"
- format = "kafka_format = 'Avro'"
- num_consumers = 8
- max_block_size = 65536
+ collection = "warpstream_metrics"
+ topic_list = "clickhouse_metrics"
+ group_name = "clickhouse-metrics-avro-new"
+ format = "Avro"
+ num_consumers = 2
+ max_block_size = 4096
skip_broken_messages = 100
- poll_timeout_ms = 3000
- poll_max_batch_size = 65536
- flush_interval_ms = 7500
+ poll_timeout_ms = 10000
+ poll_max_batch_size = 4096
+ flush_interval_ms = 10000
thread_per_consumer = true
}
}
@@ -140,10 +140,10 @@ database "posthog" {
type = "Int32"
}
engine "kafka" {
- broker_list = "warpstream_traces"
- topic_list = "kafka_topic_list = 'clickhouse_traces'"
- group_name = "kafka_group_name = 'clickhouse-traces-avro'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_traces"
+ topic_list = "clickhouse_traces"
+ group_name = "clickhouse-traces-avro"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -3749,10 +3749,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -3825,10 +3825,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -3889,3 +3889,39 @@ SQL
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/dev/ops.hcl b/posthog/clickhouse/hcl/golden/dev/ops.hcl
new file mode 100644
index 000000000000..114859f2e1ec
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/dev/ops.hcl
@@ -0,0 +1,1913 @@
+database "posthog" {
+ table "event_property_daily_stats" {
+ order_by = ["analysis_date", "team_id", "property_key"]
+ ttl = "analysis_date + toIntervalDay(30)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "analysis_date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "event_count" {
+ type = "UInt64"
+ }
+ column "distinct_event_names" {
+ type = "UInt32"
+ }
+ column "total_property_bytes" {
+ type = "UInt64"
+ }
+ column "min_property_bytes" {
+ type = "UInt64"
+ }
+ column "max_property_bytes" {
+ type = "UInt64"
+ }
+ column "avg_property_bytes" {
+ type = "Float64"
+ }
+ column "p50_property_bytes" {
+ type = "Float64"
+ }
+ column "p90_property_bytes" {
+ type = "Float64"
+ }
+ column "p95_property_bytes" {
+ type = "Float64"
+ }
+ column "p99_property_bytes" {
+ type = "Float64"
+ }
+ column "property_size_histogram" {
+ type = "Array(Tuple(Float64, Float64, UInt64))"
+ }
+ column "top_event_names" {
+ type = "Array(String)"
+ }
+ column "sample_rate" {
+ type = "Float32"
+ }
+ column "computed_at" {
+ type = "DateTime"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.event_property_daily_stats"
+ replica_name = "{replica}"
+ }
+ }
+
+ 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"
+ }
+ projection "by_label_value" {
+ query = <<SQL
+SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, label_name, label_value, id, metric_name
+SQL
+
+ }
+ projection "by_id_label" {
+ query = <<SQL
+SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, id, label_name, metric_name, label_value
+SQL
+
+ }
+ 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", "toStartOfTenMinutes(timestamp)", "id", "timestamp"]
+ partition_by = "toYYYYMMDD(timestamp)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "UInt64"
+ codec = "T64, Default"
+ }
+ column "metric_name" {
+ type = "LowCardinality(String)"
+ }
+ column "timestamp" {
+ type = "DateTime64(3, 'UTC')"
+ codec = "DoubleDelta, Default"
+ }
+ column "id" {
+ type = "UInt64"
+ }
+ column "value" {
+ type = "Float64"
+ codec = "Gorilla(8), Default"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_samples_new"
+ 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')"
+ }
+ projection "by_id" {
+ query = <<SQL
+SELECT team_id, id, metric_name, labels_json, min_time, max_time
+ORDER BY team_id, id
+SQL
+
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_series"
+ 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"
+ storage_policy = "s3_tiered"
+ }
+ 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_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 "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/dev/sessions.hcl b/posthog/clickhouse/hcl/golden/dev/sessions.hcl
new file mode 100644
index 000000000000..af32c5fcfe00
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/dev/sessions.hcl
@@ -0,0 +1,1652 @@
+database "posthog" {
+ table "channel_definition" {
+ order_by = ["domain", "kind"]
+ settings = {
+ default_compression_codec = "lz4"
+ index_granularity = "8192"
+ }
+ column "domain" {
+ type = "String"
+ }
+ column "kind" {
+ type = "String"
+ }
+ column "domain_type" {
+ type = "Nullable(String)"
+ }
+ column "type_if_paid" {
+ type = "Nullable(String)"
+ }
+ column "type_if_organic" {
+ type = "Nullable(String)"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.channel_definition"
+ replica_name = "{replica}-{shard}"
+ }
+ }
+
+ table "cohortpeople" {
+ column "person_id" {
+ type = "UUID"
+ }
+ column "cohort_id" {
+ type = "Int64"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "sign" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "cohortpeople"
+ sharding_key = "rand()"
+ }
+ }
+
+ table "events" {
+ 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_hash" {
+ type = "String"
+ }
+ column "created_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "elements_chain" {
+ type = "String"
+ }
+ column "$group_0" {
+ type = "String"
+ comment = "column_materializer::$group_0"
+ }
+ column "$group_1" {
+ type = "String"
+ comment = "column_materializer::$group_1"
+ }
+ column "$group_2" {
+ type = "String"
+ comment = "column_materializer::$group_2"
+ }
+ column "$group_3" {
+ type = "String"
+ comment = "column_materializer::$group_3"
+ }
+ column "$group_4" {
+ type = "String"
+ comment = "column_materializer::$group_4"
+ }
+ column "$window_id" {
+ type = "String"
+ comment = "column_materializer::$window_id"
+ }
+ column "$session_id" {
+ type = "String"
+ comment = "column_materializer::$session_id"
+ }
+ column "group_0" {
+ type = "String"
+ alias = "`$group_0`"
+ }
+ column "group_1" {
+ type = "String"
+ alias = "`$group_1`"
+ }
+ column "group_2" {
+ type = "String"
+ alias = "`$group_2`"
+ }
+ column "group_3" {
+ type = "String"
+ alias = "`$group_3`"
+ }
+ column "group_4" {
+ type = "String"
+ alias = "`$group_4`"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ 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 "person_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group0_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group1_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group2_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group3_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group4_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "inserted_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ default = "now64()"
+ }
+ column "person_mode" {
+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
+ }
+ column "elements_chain_href" {
+ type = "String"
+ comment = "column_materializer::elements_chain::href"
+ }
+ column "elements_chain_texts" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::texts"
+ }
+ column "elements_chain_ids" {
+ type = "Array(String)"
+ comment = "column_materializer::elements_chain::ids"
+ }
+ column "elements_chain_elements" {
+ type = "Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7))"
+ comment = "column_materializer::elements_chain::elements"
+ }
+ column "properties_group_custom" {
+ type = "Map(String, String)"
+ }
+ column "properties_group_feature_flags" {
+ type = "Map(String, String)"
+ }
+ column "is_deleted" {
+ type = "Bool"
+ }
+ column "person_properties_map_custom" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_trace_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_trace_id"
+ }
+ column "$session_id_uuid" {
+ type = "Nullable(UInt128)"
+ }
+ column "consumer_breadcrumbs" {
+ type = "Array(String)"
+ }
+ column "properties_group_ai" {
+ type = "Map(String, String)"
+ }
+ column "mat_historical_migration" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::historical_migration"
+ }
+ column "mat_$ai_session_id" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_session_id"
+ }
+ column "mat_$ai_is_error" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_is_error"
+ }
+ column "dmat_string_0" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_1" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_2" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_3" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_4" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_5" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_6" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_7" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_8" {
+ type = "Nullable(String)"
+ }
+ column "dmat_string_9" {
+ type = "Nullable(String)"
+ }
+ column "historical_migration" {
+ type = "Bool"
+ }
+ column "properties_group_ai_large" {
+ type = "Map(String, String)"
+ }
+ column "mat_$ai_prompt_name" {
+ type = "Nullable(String)"
+ comment = "column_materializer::properties::$ai_prompt_name"
+ }
+ engine "distributed" {
+ cluster_name = "posthog"
+ remote_database = "posthog"
+ remote_table = "sharded_events"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+
+ table "person_distinct_id_overrides" {
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "is_deleted" {
+ type = "Int8"
+ }
+ column "version" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "person_distinct_id_overrides"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+
+ table "person_static_cohort" {
+ column "id" {
+ type = "UUID"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "cohort_id" {
+ type = "Int64"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "person_static_cohort"
+ sharding_key = "rand()"
+ }
+ }
+
+ table "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 "raw_sessions" {
+ order_by = ["team_id", "toStartOfHour(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000)))", "cityHash64(session_id_v7)", "session_id_v7"]
+ partition_by = "toYYYYMM(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000)))"
+ sample_by = "cityHash64(session_id_v7)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "session_id_v7" {
+ type = "UInt128"
+ }
+ column "distinct_id" {
+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"
+ }
+ column "min_timestamp" {
+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"
+ }
+ column "max_timestamp" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "max_inserted_at" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "urls" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"
+ }
+ column "entry_url" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "end_url" {
+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"
+ }
+ column "last_external_click_url" {
+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_browser" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_browser_version" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_os" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_os_version" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_device_type" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_viewport_width" {
+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"
+ }
+ column "initial_viewport_height" {
+ type = "AggregateFunction(argMin, Int64, DateTime64(6, 'UTC'))"
+ }
+ column "initial_geoip_country_code" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_geoip_subdivision_1_code" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_geoip_subdivision_1_name" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_geoip_subdivision_city_name" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_geoip_time_zone" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_referring_domain" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_utm_source" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_utm_campaign" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_utm_medium" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_utm_term" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_utm_content" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_gclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_gad_source" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_gclsrc" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_dclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_gbraid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_wbraid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_fbclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_msclkid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_twclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_li_fat_id" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_mc_cid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_igshid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_ttclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_irclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "pageview_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "pageview_uniq" {
+ type = "AggregateFunction(uniq, Nullable(UUID))"
+ }
+ column "autocapture_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "autocapture_uniq" {
+ type = "AggregateFunction(uniq, Nullable(UUID))"
+ }
+ column "screen_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "screen_uniq" {
+ type = "AggregateFunction(uniq, Nullable(UUID))"
+ }
+ column "maybe_has_session_replay" {
+ type = "SimpleAggregateFunction(max, Bool)"
+ }
+ column "page_screen_autocapture_uniq_up_to" {
+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"
+ }
+ column "vitals_lcp" {
+ type = "AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC'))"
+ }
+ column "initial__kx" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+
+ table "raw_sessions_v3" {
+ order_by = ["team_id", "session_timestamp", "session_id_v7"]
+ partition_by = "toYYYYMM(session_timestamp)"
+ settings = {
+ index_granularity = "8192"
+ storage_policy = "s3_tiered"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "session_id_v7" {
+ type = "UInt128"
+ }
+ column "session_timestamp" {
+ type = "DateTime64(3)"
+ default = "fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80)))"
+ }
+ column "distinct_id" {
+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"
+ }
+ column "distinct_ids" {
+ type = "AggregateFunction(groupUniqArray, String)"
+ }
+ column "min_timestamp" {
+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"
+ }
+ column "max_timestamp" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "max_inserted_at" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "urls" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"
+ }
+ column "entry_url" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "end_url" {
+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "last_external_click_url" {
+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "browser" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "browser_version" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "os" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "os_version" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "device_type" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "viewport_width" {
+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"
+ }
+ column "viewport_height" {
+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"
+ }
+ column "geoip_country_code" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "geoip_subdivision_1_code" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "geoip_subdivision_1_name" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "geoip_subdivision_city_name" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "geoip_time_zone" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_referring_domain" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_utm_source" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_utm_campaign" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_utm_medium" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_utm_term" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_utm_content" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_gclid" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_gad_source" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_fbclid" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_has_gclid" {
+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"
+ }
+ column "entry_has_fbclid" {
+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"
+ }
+ column "entry_ad_ids_map" {
+ type = "AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_ad_ids_set" {
+ type = "AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_channel_type_properties" {
+ type = "AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC'))"
+ }
+ column "pageview_uniq" {
+ type = "AggregateFunction(uniqExact, Nullable(UUID))"
+ }
+ column "autocapture_uniq" {
+ type = "AggregateFunction(uniqExact, Nullable(UUID))"
+ }
+ column "screen_uniq" {
+ type = "AggregateFunction(uniqExact, Nullable(UUID))"
+ }
+ column "page_screen_uniq_up_to" {
+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"
+ }
+ column "has_autocapture" {
+ type = "SimpleAggregateFunction(max, Bool)"
+ }
+ column "flag_values" {
+ type = "AggregateFunction(groupUniqArrayMap, Map(String, String))"
+ }
+ column "flag_keys" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"
+ }
+ column "event_names" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"
+ }
+ column "hosts" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray(100), Array(String))"
+ }
+ column "emails" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray(10), Array(String))"
+ }
+ column "has_replay_events" {
+ type = "SimpleAggregateFunction(max, Bool)"
+ }
+ index "event_names_bloom_filter" {
+ expr = "event_names"
+ type = "bloom_filter()"
+ granularity = 1
+ }
+ index "flag_keys_bloom_filter" {
+ expr = "flag_keys"
+ type = "bloom_filter()"
+ granularity = 1
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+
+ table "sessions" {
+ order_by = ["toStartOfDay(min_timestamp)", "team_id", "session_id"]
+ partition_by = "toYYYYMM(min_timestamp)"
+ settings = {
+ index_granularity = "512"
+ }
+ column "session_id" {
+ type = "String"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "SimpleAggregateFunction(any, String)"
+ }
+ column "min_timestamp" {
+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"
+ }
+ column "max_timestamp" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "urls" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"
+ }
+ column "entry_url" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "exit_url" {
+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_referring_domain" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_utm_source" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_utm_campaign" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_utm_medium" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_utm_term" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_utm_content" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_gclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_gad_source" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_gclsrc" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_dclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_gbraid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_wbraid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_fbclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_msclkid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_twclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_li_fat_id" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_mc_cid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_igshid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "initial_ttclid" {
+ type = "AggregateFunction(argMin, String, DateTime64(6, 'UTC'))"
+ }
+ column "event_count_map" {
+ type = "SimpleAggregateFunction(sumMap, Map(String, Int64))"
+ }
+ column "pageview_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ column "autocapture_count" {
+ type = "SimpleAggregateFunction(sum, Int64)"
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.sessions"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+
+ table "web_pre_aggregated_teams" {
+ column "team_id" {
+ type = "UInt64"
+ }
+ column "enabled_by" {
+ type = "String"
+ default = "'system'"
+ }
+ column "version" {
+ type = "UInt32"
+ default = "toUnixTimestamp(now())"
+ }
+ engine "distributed" {
+ cluster_name = "posthog_single_shard"
+ remote_database = "posthog"
+ remote_table = "web_pre_aggregated_teams"
+ }
+ }
+
+ 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
+
+ }
+
+ dictionary "channel_definition_dict" {
+ primary_key = ["domain", "kind"]
+ lifetime {
+ min = 3000
+ max = 3600
+ }
+ attribute "domain" {
+ type = "String"
+ }
+ attribute "kind" {
+ type = "String"
+ }
+ attribute "domain_type" {
+ type = "Nullable(String)"
+ }
+ attribute "type_if_paid" {
+ type = "Nullable(String)"
+ }
+ attribute "type_if_organic" {
+ type = "Nullable(String)"
+ }
+ source "clickhouse" {
+ user = "dict_reader"
+ table = "channel_definition"
+ }
+ layout "complex_key_hashed" {
+ }
+ }
+
+ dictionary "web_pre_aggregated_teams_dict" {
+ primary_key = ["team_id"]
+ lifetime {
+ min = 3000
+ max = 3600
+ }
+ attribute "team_id" {
+ type = "UInt64"
+ }
+ source "clickhouse" {
+ user = "dict_reader"
+ query = "SELECT team_id FROM `web_pre_aggregated_teams` FINAL WHERE version > 0"
+ }
+ layout "hashed" {
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/golden/local-multi/ai_events.hcl b/posthog/clickhouse/hcl/golden/local-multi/ai_events.hcl
index 12cd9835cb41..40a52e84809d 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/ai_events.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/ai_events.hcl
@@ -228,10 +228,10 @@ database "posthog" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_ai_events_json'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_ai_events_json"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -1378,10 +1378,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -1454,10 +1454,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -1518,3 +1518,39 @@ SQL
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl b/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl
index 06599034e724..d9bfc4843ab6 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/auxiliary.hcl
@@ -512,10 +512,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_error_tracking_fingerprint_issue_state'"
- group_name = "kafka_group_name = 'clickhouse-error-tracking-fingerprint-issue-state'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_error_tracking_fingerprint_issue_state"
+ group_name = "clickhouse-error-tracking-fingerprint-issue-state"
+ format = "JSONEachRow"
}
}
@@ -584,10 +584,10 @@ database "posthog" {
type = "UInt8"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
- group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_hog_invocation_results"
+ group_name = "clickhouse_hog_invocation_results"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -609,10 +609,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"
- group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ingestion_warnings"
+ group_name = "clickhouse_ingestion_warnings_v2"
+ format = "JSONEachRow"
}
}
@@ -666,10 +666,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_message_assets'"
- group_name = "kafka_group_name = 'clickhouse_message_assets'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_message_assets"
+ group_name = "clickhouse_message_assets"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -691,10 +691,10 @@ database "posthog" {
type = "UInt64"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_property_values'"
- group_name = "kafka_group_name = 'clickhouse_property_values'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_property_values"
+ group_name = "clickhouse_property_values"
+ format = "JSONEachRow"
num_consumers = 8
thread_per_consumer = true
}
@@ -3913,10 +3913,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -3989,10 +3989,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -4083,3 +4083,39 @@ SQL
}
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/local-multi/data.hcl b/posthog/clickhouse/hcl/golden/local-multi/data.hcl
index 544a7a618e5c..e827f020b24c 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/data.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/data.hcl
@@ -2337,10 +2337,10 @@ database "posthog" {
type = "Nullable(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_events_json'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_events_json"
+ group_name = "group1"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -2488,10 +2488,10 @@ database "posthog" {
type = "Float64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_performance_events'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_performance_events"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -2512,10 +2512,10 @@ database "posthog" {
type = "Nullable(Int8)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person_unique_id'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person_unique_id"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -11507,10 +11507,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -11583,10 +11583,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -12209,3 +12209,39 @@ SQL
}
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl b/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl
index e815033b7b82..09ace9abf004 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/ingestion_events.hcl
@@ -116,10 +116,10 @@ database "posthog" {
type = "Nullable(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_events_json'"
- group_name = "kafka_group_name = 'clickhouse_events_json_native_json'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_events_json"
+ group_name = "clickhouse_events_json_native_json"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -180,10 +180,10 @@ database "posthog" {
type = "Nullable(Int32)"
}
engine "kafka" {
- broker_list = "warpstream_logs"
- topic_list = "kafka_topic_list = 'clickhouse_logs'"
- group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_logs"
+ topic_list = "clickhouse_logs"
+ group_name = "clickhouse-logs-avro-new"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -1003,3 +1003,39 @@ SQL
}
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hcl b/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hcl
index 0d25a95d3bc4..29257331fd74 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/ingestion_medium.hcl
@@ -34,10 +34,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_app_metrics2"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -67,10 +67,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"
- group_name = "kafka_group_name = 'clickhouse_app_metrics2_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_app_metrics2"
+ group_name = "clickhouse_app_metrics2_ws"
+ format = "JSONEachRow"
}
}
@@ -91,10 +91,10 @@ database "posthog" {
type = "DateTime64(6)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'cohort_membership_changed'"
- group_name = "kafka_group_name = 'clickhouse_cohort_membership_changed'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "cohort_membership_changed"
+ group_name = "clickhouse_cohort_membership_changed"
+ format = "JSONEachRow"
}
}
@@ -109,10 +109,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'distinct_id_usage_events_json'"
- group_name = "kafka_group_name = 'clickhouse_distinct_id_usage'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "distinct_id_usage_events_json"
+ group_name = "clickhouse_distinct_id_usage"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -164,10 +164,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_flag_evaluations'"
- group_name = "kafka_group_name = 'clickhouse_flag_evaluations'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_flag_evaluations"
+ group_name = "clickhouse_flag_evaluations"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -210,10 +210,10 @@ database "posthog" {
type = "LowCardinality(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_heatmap_events'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_heatmap_events"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -240,10 +240,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_prefiltered_events'"
- group_name = "kafka_group_name = 'clickhouse_prefiltered_events'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_prefiltered_events"
+ group_name = "clickhouse_prefiltered_events"
+ format = "JSONEachRow"
num_consumers = 1
max_block_size = 1000000
skip_broken_messages = 100
@@ -273,10 +273,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_precalculated_person_properties'"
- group_name = "kafka_group_name = 'clickhouse_precalculated_person_properties'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_precalculated_person_properties"
+ group_name = "clickhouse_precalculated_person_properties"
+ format = "JSONEachRow"
num_consumers = 1
max_block_size = 1000000
skip_broken_messages = 100
@@ -495,10 +495,10 @@ database "posthog" {
type = "UInt8"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_session_replay_features'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_session_replay_features"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -534,10 +534,10 @@ database "posthog" {
type = "Map(LowCardinality(String), String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_tophog'"
- group_name = "kafka_group_name = 'clickhouse_tophog'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_tophog"
+ group_name = "clickhouse_tophog"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -574,10 +574,10 @@ database "posthog" {
type = "Map(LowCardinality(String), String)"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_tophog'"
- group_name = "kafka_group_name = 'clickhouse_tophog_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_tophog"
+ group_name = "clickhouse_tophog_ws"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -2229,3 +2229,39 @@ SQL
}
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hcl b/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hcl
index 50b8ba27bfe6..dc806c1d0810 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/ingestion_small.hcl
@@ -44,10 +44,10 @@ database "posthog" {
codec = "ZSTD(3)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_app_metrics'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_app_metrics"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -86,10 +86,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_billing_usage_records'"
- group_name = "kafka_group_name = 'clickhouse_billing_usage_records'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_billing_usage_records"
+ group_name = "clickhouse_billing_usage_records"
+ format = "JSONEachRow"
}
}
@@ -143,10 +143,10 @@ database "posthog" {
type = "DateTime64(3, 'UTC')"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_events_duplicates'"
- group_name = "kafka_group_name = 'clickhouse_duplicate_events'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_ingestion_events_duplicates"
+ group_name = "clickhouse_duplicate_events"
+ format = "JSONEachRow"
}
}
@@ -170,10 +170,10 @@ database "posthog" {
type = "Array(Float64)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint_embeddings'"
- group_name = "kafka_group_name = 'clickhouse_error_tracking_fingerprint_embeddings'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_error_tracking_issue_fingerprint_embeddings"
+ group_name = "clickhouse_error_tracking_fingerprint_embeddings"
+ format = "JSONEachRow"
}
}
@@ -194,10 +194,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint'"
- group_name = "kafka_group_name = 'clickhouse-error-tracking-issue-fingerprint-overrides'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_error_tracking_issue_fingerprint"
+ group_name = "clickhouse-error-tracking-issue-fingerprint-overrides"
+ format = "JSONEachRow"
}
}
@@ -251,10 +251,10 @@ database "posthog" {
type = "Array(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'events_dead_letter_queue'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "events_dead_letter_queue"
+ group_name = "group1"
+ format = "JSONEachRow"
skip_broken_messages = 1000
}
}
@@ -276,10 +276,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_groups'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_groups"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -301,10 +301,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_ingestion_warnings"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -331,10 +331,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'log_entries'"
- group_name = "kafka_group_name = 'clickhouse_log_entries'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "log_entries"
+ group_name = "clickhouse_log_entries"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -362,10 +362,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'log_entries'"
- group_name = "kafka_group_name = 'clickhouse_log_entries_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "log_entries"
+ group_name = "clickhouse_log_entries_ws"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -396,10 +396,10 @@ database "posthog" {
type = "Nullable(DateTime64(3))"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -420,10 +420,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person_distinct_id"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -444,10 +444,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"
- group_name = "kafka_group_name = 'clickhouse-person-distinct-id-overrides'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person_distinct_id"
+ group_name = "clickhouse-person-distinct-id-overrides"
+ format = "JSONEachRow"
}
}
@@ -480,10 +480,10 @@ database "posthog" {
type = "UUID"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'plugin_log_entries'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "plugin_log_entries"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -522,10 +522,10 @@ database "posthog" {
type = "Array(Float64)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_document_embeddings'"
- group_name = "kafka_group_name = 'clickhouse_document_embeddings'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_document_embeddings"
+ group_name = "clickhouse_document_embeddings"
+ format = "JSONEachRow"
}
}
@@ -609,10 +609,10 @@ database "posthog" {
type = "Nullable(Float32)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_session_replay_events'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_session_replay_events"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -640,10 +640,10 @@ database "posthog" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_events_json'"
- group_name = "kafka_group_name = 'clickhouse_usage_report_events_preagg'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_events_json"
+ group_name = "clickhouse_usage_report_events_preagg"
+ format = "JSONEachRow"
num_consumers = 1
skip_broken_messages = 100
thread_per_consumer = true
@@ -2790,3 +2790,39 @@ SQL
}
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl b/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
index a26d508580fd..306c1123565e 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/logs.hcl
@@ -61,10 +61,10 @@ database "posthog" {
type = "Nullable(Int64)"
}
engine "kafka" {
- broker_list = "warpstream_metrics"
- topic_list = "kafka_topic_list = 'clickhouse_metrics'"
- group_name = "kafka_group_name = 'clickhouse-metrics-avro-new'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_metrics"
+ topic_list = "clickhouse_metrics"
+ group_name = "clickhouse-metrics-avro-new"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -138,10 +138,10 @@ database "posthog" {
type = "Int32"
}
engine "kafka" {
- broker_list = "warpstream_traces"
- topic_list = "kafka_topic_list = 'clickhouse_traces'"
- group_name = "kafka_group_name = 'clickhouse-traces-avro'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_traces"
+ topic_list = "clickhouse_traces"
+ group_name = "clickhouse-traces-avro"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -3990,3 +3990,39 @@ SQL
}
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/local-multi/ops.hcl b/posthog/clickhouse/hcl/golden/local-multi/ops.hcl
index c87095c2add2..fe59e10d1296 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/ops.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/ops.hcl
@@ -1178,10 +1178,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -1254,10 +1254,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/golden/local-multi/sessions.hcl b/posthog/clickhouse/hcl/golden/local-multi/sessions.hcl
index 659228d54d89..850221fefe59 100644
--- a/posthog/clickhouse/hcl/golden/local-multi/sessions.hcl
+++ b/posthog/clickhouse/hcl/golden/local-multi/sessions.hcl
@@ -587,10 +587,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -663,10 +663,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/golden/local-single/all.hcl b/posthog/clickhouse/hcl/golden/local-single/all.hcl
index 4795d1fb89ee..7f653d6615d0 100644
--- a/posthog/clickhouse/hcl/golden/local-single/all.hcl
+++ b/posthog/clickhouse/hcl/golden/local-single/all.hcl
@@ -2521,10 +2521,10 @@ database "posthog" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_ai_events_json'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_ai_events_json"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -2564,10 +2564,10 @@ database "posthog" {
codec = "ZSTD(3)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_app_metrics'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_app_metrics"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -2597,10 +2597,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_app_metrics2"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -2630,10 +2630,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"
- group_name = "kafka_group_name = 'clickhouse_app_metrics2_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_app_metrics2"
+ group_name = "clickhouse_app_metrics2_ws"
+ format = "JSONEachRow"
}
}
@@ -2672,10 +2672,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_billing_usage_records'"
- group_name = "kafka_group_name = 'clickhouse_billing_usage_records'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_billing_usage_records"
+ group_name = "clickhouse_billing_usage_records"
+ format = "JSONEachRow"
}
}
@@ -2696,10 +2696,10 @@ database "posthog" {
type = "DateTime64(6)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'cohort_membership_changed'"
- group_name = "kafka_group_name = 'clickhouse_cohort_membership_changed'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "cohort_membership_changed"
+ group_name = "clickhouse_cohort_membership_changed"
+ format = "JSONEachRow"
}
}
@@ -2714,10 +2714,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'distinct_id_usage_events_json'"
- group_name = "kafka_group_name = 'clickhouse_distinct_id_usage'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "distinct_id_usage_events_json"
+ group_name = "clickhouse_distinct_id_usage"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -2772,10 +2772,10 @@ database "posthog" {
type = "DateTime64(3, 'UTC')"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_events_duplicates'"
- group_name = "kafka_group_name = 'clickhouse_duplicate_events'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_ingestion_events_duplicates"
+ group_name = "clickhouse_duplicate_events"
+ format = "JSONEachRow"
}
}
@@ -2817,10 +2817,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_error_tracking_fingerprint_issue_state'"
- group_name = "kafka_group_name = 'clickhouse-error-tracking-fingerprint-issue-state'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_error_tracking_fingerprint_issue_state"
+ group_name = "clickhouse-error-tracking-fingerprint-issue-state"
+ format = "JSONEachRow"
}
}
@@ -2844,10 +2844,10 @@ database "posthog" {
type = "Array(Float64)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint_embeddings'"
- group_name = "kafka_group_name = 'clickhouse_error_tracking_fingerprint_embeddings'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_error_tracking_issue_fingerprint_embeddings"
+ group_name = "clickhouse_error_tracking_fingerprint_embeddings"
+ format = "JSONEachRow"
}
}
@@ -2868,10 +2868,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint'"
- group_name = "kafka_group_name = 'clickhouse-error-tracking-issue-fingerprint-overrides'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_error_tracking_issue_fingerprint"
+ group_name = "clickhouse-error-tracking-issue-fingerprint-overrides"
+ format = "JSONEachRow"
}
}
@@ -2925,10 +2925,10 @@ database "posthog" {
type = "Array(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'events_dead_letter_queue'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "events_dead_letter_queue"
+ group_name = "group1"
+ format = "JSONEachRow"
skip_broken_messages = 1000
}
}
@@ -3041,10 +3041,10 @@ database "posthog" {
type = "Nullable(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_events_json'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_events_json"
+ group_name = "group1"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -3157,10 +3157,10 @@ database "posthog" {
type = "Nullable(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_events_json'"
- group_name = "kafka_group_name = 'clickhouse_events_json_native_json'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_events_json"
+ group_name = "clickhouse_events_json_native_json"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -3212,10 +3212,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_flag_evaluations'"
- group_name = "kafka_group_name = 'clickhouse_flag_evaluations'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_flag_evaluations"
+ group_name = "clickhouse_flag_evaluations"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -3237,10 +3237,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_groups'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_groups"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -3282,10 +3282,10 @@ database "posthog" {
type = "LowCardinality(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_heatmap_events'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_heatmap_events"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -3354,10 +3354,10 @@ database "posthog" {
type = "UInt8"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
- group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_hog_invocation_results"
+ group_name = "clickhouse_hog_invocation_results"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -3380,10 +3380,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_ingestion_warnings"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -3404,10 +3404,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"
- group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ingestion_warnings"
+ group_name = "clickhouse_ingestion_warnings_v2"
+ format = "JSONEachRow"
}
}
@@ -3434,10 +3434,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'log_entries'"
- group_name = "kafka_group_name = 'clickhouse_log_entries'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "log_entries"
+ group_name = "clickhouse_log_entries"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -3465,10 +3465,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'log_entries'"
- group_name = "kafka_group_name = 'clickhouse_log_entries_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "log_entries"
+ group_name = "clickhouse_log_entries_ws"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -3529,10 +3529,10 @@ database "posthog" {
type = "Nullable(Int32)"
}
engine "kafka" {
- broker_list = "warpstream_logs"
- topic_list = "kafka_topic_list = 'clickhouse_logs'"
- group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_logs"
+ topic_list = "clickhouse_logs"
+ group_name = "clickhouse-logs-avro-new"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -3591,10 +3591,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_message_assets'"
- group_name = "kafka_group_name = 'clickhouse_message_assets'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_message_assets"
+ group_name = "clickhouse_message_assets"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -3661,10 +3661,10 @@ database "posthog" {
type = "Nullable(Int64)"
}
engine "kafka" {
- broker_list = "warpstream_metrics"
- topic_list = "kafka_topic_list = 'clickhouse_metrics'"
- group_name = "kafka_group_name = 'clickhouse-metrics-avro-new'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_metrics"
+ topic_list = "clickhouse_metrics"
+ group_name = "clickhouse-metrics-avro-new"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -3816,10 +3816,10 @@ database "posthog" {
type = "Float64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_performance_events'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_performance_events"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -3849,10 +3849,10 @@ database "posthog" {
type = "Nullable(DateTime64(3))"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -3873,10 +3873,10 @@ database "posthog" {
type = "Nullable(Int8)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person_unique_id'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person_unique_id"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -3897,10 +3897,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person_distinct_id"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -3921,10 +3921,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"
- group_name = "kafka_group_name = 'clickhouse-person-distinct-id-overrides'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person_distinct_id"
+ group_name = "clickhouse-person-distinct-id-overrides"
+ format = "JSONEachRow"
}
}
@@ -3984,10 +3984,10 @@ database "posthog" {
type = "UUID"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'plugin_log_entries'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "plugin_log_entries"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -4026,10 +4026,10 @@ database "posthog" {
type = "Array(Float64)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_document_embeddings'"
- group_name = "kafka_group_name = 'clickhouse_document_embeddings'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_document_embeddings"
+ group_name = "clickhouse_document_embeddings"
+ format = "JSONEachRow"
}
}
@@ -4056,10 +4056,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_prefiltered_events'"
- group_name = "kafka_group_name = 'clickhouse_prefiltered_events'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_prefiltered_events"
+ group_name = "clickhouse_prefiltered_events"
+ format = "JSONEachRow"
num_consumers = 1
max_block_size = 1000000
skip_broken_messages = 100
@@ -4089,10 +4089,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_precalculated_person_properties'"
- group_name = "kafka_group_name = 'clickhouse_precalculated_person_properties'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_precalculated_person_properties"
+ group_name = "clickhouse_precalculated_person_properties"
+ format = "JSONEachRow"
num_consumers = 1
max_block_size = 1000000
skip_broken_messages = 100
@@ -4119,10 +4119,10 @@ database "posthog" {
type = "UInt64"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_property_values'"
- group_name = "kafka_group_name = 'clickhouse_property_values'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_property_values"
+ group_name = "clickhouse_property_values"
+ format = "JSONEachRow"
num_consumers = 8
thread_per_consumer = true
}
@@ -4208,10 +4208,10 @@ database "posthog" {
type = "Nullable(Float32)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_session_replay_events'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_session_replay_events"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -4424,10 +4424,10 @@ database "posthog" {
type = "UInt8"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_session_replay_features'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_session_replay_features"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -4463,10 +4463,10 @@ database "posthog" {
type = "Map(LowCardinality(String), String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_tophog'"
- group_name = "kafka_group_name = 'clickhouse_tophog'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_tophog"
+ group_name = "clickhouse_tophog"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -4503,10 +4503,10 @@ database "posthog" {
type = "Map(LowCardinality(String), String)"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_tophog'"
- group_name = "kafka_group_name = 'clickhouse_tophog_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_tophog"
+ group_name = "clickhouse_tophog_ws"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -4576,10 +4576,10 @@ database "posthog" {
type = "Int32"
}
engine "kafka" {
- broker_list = "warpstream_traces"
- topic_list = "kafka_topic_list = 'clickhouse_traces'"
- group_name = "kafka_group_name = 'clickhouse-traces-avro'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_traces"
+ topic_list = "clickhouse_traces"
+ group_name = "clickhouse-traces-avro"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -4612,10 +4612,10 @@ database "posthog" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_events_json'"
- group_name = "kafka_group_name = 'clickhouse_usage_report_events_preagg'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_events_json"
+ group_name = "clickhouse_usage_report_events_preagg"
+ format = "JSONEachRow"
num_consumers = 1
skip_broken_messages = 100
thread_per_consumer = true
@@ -23104,10 +23104,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -23180,10 +23180,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -23806,3 +23806,39 @@ SQL
}
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-eu/ai_events.hcl b/posthog/clickhouse/hcl/golden/prod-eu/ai_events.hcl
index 96281ceca5a0..8c12d55e1506 100644
--- a/posthog/clickhouse/hcl/golden/prod-eu/ai_events.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-eu/ai_events.hcl
@@ -283,10 +283,10 @@ database "posthog" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ai_events_json'"
- group_name = "kafka_group_name = 'clickhouse_ai_events_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ai_events_json"
+ group_name = "clickhouse_ai_events_ws"
+ format = "JSONEachRow"
num_consumers = 16
max_block_size = 5000
skip_broken_messages = 100
@@ -1268,10 +1268,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -1344,10 +1344,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -1408,3 +1408,39 @@ SQL
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl b/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl
index 08e551859a56..440d190e618a 100644
--- a/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-eu/auxiliary.hcl
@@ -540,10 +540,10 @@ database "posthog" {
type = "UInt8"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
- group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_hog_invocation_results"
+ group_name = "clickhouse_hog_invocation_results"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -565,10 +565,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"
- group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ingestion_warnings"
+ group_name = "clickhouse_ingestion_warnings_v2"
+ format = "JSONEachRow"
}
}
@@ -622,10 +622,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_message_assets'"
- group_name = "kafka_group_name = 'clickhouse_message_assets'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_message_assets"
+ group_name = "clickhouse_message_assets"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -647,10 +647,10 @@ database "posthog" {
type = "UInt64"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_property_values'"
- group_name = "kafka_group_name = 'clickhouse_property_values'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_property_values"
+ group_name = "clickhouse_property_values"
+ format = "JSONEachRow"
num_consumers = 8
thread_per_consumer = true
}
@@ -3912,10 +3912,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -3988,10 +3988,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -4082,3 +4082,39 @@ SQL
}
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-eu/batch_exports.hcl b/posthog/clickhouse/hcl/golden/prod-eu/batch_exports.hcl
index 6c82589587ae..6be4c402ec14 100644
--- a/posthog/clickhouse/hcl/golden/prod-eu/batch_exports.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-eu/batch_exports.hcl
@@ -764,10 +764,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -840,10 +840,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl b/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
index b65e0de04cac..fc037d577925 100644
--- a/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-eu/logs.hcl
@@ -61,10 +61,10 @@ database "posthog" {
type = "Nullable(Int64)"
}
engine "kafka" {
- broker_list = "warpstream_metrics"
- topic_list = "kafka_topic_list = 'clickhouse_metrics'"
- group_name = "kafka_group_name = 'clickhouse-metrics-avro-new'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_metrics"
+ topic_list = "clickhouse_metrics"
+ group_name = "clickhouse-metrics-avro-new"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -138,10 +138,10 @@ database "posthog" {
type = "Int32"
}
engine "kafka" {
- broker_list = "warpstream_traces"
- topic_list = "kafka_topic_list = 'clickhouse_traces'"
- group_name = "kafka_group_name = 'clickhouse-traces-avro'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_traces"
+ topic_list = "clickhouse_traces"
+ group_name = "clickhouse-traces-avro"
+ format = "Avro"
num_consumers = 2
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -3786,10 +3786,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -3862,10 +3862,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -3926,3 +3926,39 @@ SQL
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-eu/ops.hcl b/posthog/clickhouse/hcl/golden/prod-eu/ops.hcl
new file mode 100644
index 000000000000..00d8abded32e
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/prod-eu/ops.hcl
@@ -0,0 +1,1834 @@
+database "posthog" {
+ table "event_property_daily_stats" {
+ order_by = ["analysis_date", "team_id", "property_key"]
+ ttl = "analysis_date + toIntervalDay(30)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "analysis_date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "event_count" {
+ type = "UInt64"
+ }
+ column "distinct_event_names" {
+ type = "UInt32"
+ }
+ column "total_property_bytes" {
+ type = "UInt64"
+ }
+ column "min_property_bytes" {
+ type = "UInt64"
+ }
+ column "max_property_bytes" {
+ type = "UInt64"
+ }
+ column "avg_property_bytes" {
+ type = "Float64"
+ }
+ column "p50_property_bytes" {
+ type = "Float64"
+ }
+ column "p90_property_bytes" {
+ type = "Float64"
+ }
+ column "p95_property_bytes" {
+ type = "Float64"
+ }
+ column "p99_property_bytes" {
+ type = "Float64"
+ }
+ column "property_size_histogram" {
+ type = "Array(Tuple(Float64, Float64, UInt64))"
+ }
+ column "top_event_names" {
+ type = "Array(String)"
+ }
+ column "sample_rate" {
+ type = "Float32"
+ }
+ column "computed_at" {
+ type = "DateTime"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.event_property_daily_stats"
+ replica_name = "{replica}"
+ }
+ }
+
+ 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"
+ }
+ projection "by_label_value" {
+ query = <<SQL
+SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, label_name, label_value, id, metric_name
+SQL
+
+ }
+ projection "by_id_label" {
+ query = <<SQL
+SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, id, label_name, metric_name, label_value
+SQL
+
+ }
+ 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", "toStartOfTenMinutes(timestamp)", "id", "timestamp"]
+ partition_by = "toYYYYMMDD(timestamp)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "UInt64"
+ codec = "T64, Default"
+ }
+ column "metric_name" {
+ type = "LowCardinality(String)"
+ }
+ column "timestamp" {
+ type = "DateTime64(3, 'UTC')"
+ codec = "DoubleDelta, Default"
+ }
+ column "id" {
+ type = "UInt64"
+ }
+ column "value" {
+ type = "Float64"
+ codec = "Gorilla(8), Default"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_samples_new"
+ 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')"
+ }
+ projection "by_id" {
+ query = <<SQL
+SELECT team_id, id, metric_name, labels_json, min_time, max_time
+ORDER BY team_id, id
+SQL
+
+ }
+ 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 "query_team_daily_stats" {
+ order_by = ["analysis_date", "team_id"]
+ ttl = "analysis_date + toIntervalDay(90)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "analysis_date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "query_count" {
+ type = "UInt64"
+ }
+ column "error_count" {
+ type = "UInt64"
+ }
+ column "distinct_query_shapes" {
+ type = "UInt64"
+ }
+ column "total_duration_ms" {
+ type = "UInt64"
+ }
+ column "avg_duration_ms" {
+ type = "Float64"
+ }
+ column "p50_duration_ms" {
+ type = "Float64"
+ }
+ column "p90_duration_ms" {
+ type = "Float64"
+ }
+ column "p99_duration_ms" {
+ type = "Float64"
+ }
+ column "max_duration_ms" {
+ type = "UInt64"
+ }
+ column "total_read_rows" {
+ type = "UInt64"
+ }
+ column "total_read_bytes" {
+ type = "UInt64"
+ comment = "Uncompressed bytes scanned, coordinator-side summed across shards (is_initial_query=1). Compute/scan cost proxy, NOT stored footprint."
+ }
+ column "total_result_rows" {
+ type = "UInt64"
+ }
+ column "total_result_bytes" {
+ type = "UInt64"
+ }
+ column "total_written_rows" {
+ type = "UInt64"
+ }
+ column "total_written_bytes" {
+ type = "UInt64"
+ }
+ column "total_cpu_seconds" {
+ type = "Float64"
+ comment = "ProfileEvents OSCPUVirtualTimeMicroseconds summed across ALL QueryFinish rows (initiator + shard leaves) / 1e6. CPU is not folded onto the initiator row, so leaves must be summed."
+ }
+ column "total_memory_usage" {
+ type = "UInt64"
+ comment = "Peak memory_usage summed across all shard rows (per-node peak; not folded onto the initiator)."
+ }
+ column "max_memory_usage" {
+ type = "UInt64"
+ comment = "Largest single-node peak memory across all shard rows."
+ }
+ column "p99_memory_usage" {
+ type = "Float64"
+ }
+ column "total_s3_get_objects" {
+ type = "UInt64"
+ comment = "ProfileEvents S3GetObject summed across all shard rows: object-storage GET count."
+ }
+ column "total_s3_read_bytes" {
+ type = "UInt64"
+ comment = "ProfileEvents ReadBufferFromS3Bytes summed across all shard rows: object-storage read cost proxy."
+ }
+ column "query_kind_counts" {
+ type = "Map(String, UInt64)"
+ comment = "query_kind -> count for QueryFinish rows."
+ }
+ column "computed_at" {
+ type = "DateTime"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.query_team_daily_stats"
+ replica_name = "{replica}"
+ }
+ }
+
+ table "sharded_query_log_archive" {
+ order_by = ["team_id", "event_date", "event_time", "query_id"]
+ partition_by = "toYYYYMM(event_date)"
+ settings = {
+ index_granularity = "8192"
+ max_replicated_merges_in_queue = "6"
+ object_serialization_version = "v3"
+ object_shared_data_serialization_version = "map_with_buckets"
+ parts_to_delay_insert = "1000"
+ parts_to_throw_insert = "3000"
+ prefer_fetch_merged_part_size_threshold = "1"
+ prefer_fetch_merged_part_time_threshold = "60"
+ }
+ 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-eu/sessions.hcl b/posthog/clickhouse/hcl/golden/prod-eu/sessions.hcl
index 315b891a96c7..5f476c0f91de 100644
--- a/posthog/clickhouse/hcl/golden/prod-eu/sessions.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-eu/sessions.hcl
@@ -80,1140 +80,100 @@ database "posthog" {
column "elements_chain" {
type = "String"
}
- column "mat_$user_id" {
- type = "String"
- comment = "column_materializer::$user_id"
- }
- column "mat_$browser" {
- type = "String"
- comment = "column_materializer::$browser"
- }
- column "mat_$host" {
- type = "String"
- comment = "column_materializer::$host"
- }
- column "mat_$current_url" {
- type = "String"
- comment = "column_materializer::$current_url"
- }
- column "mat_distinct_id" {
- type = "String"
- comment = "column_materializer::distinct_id"
- }
- column "mat_action" {
- type = "String"
- comment = "column_materializer::action"
- }
- column "mat_origin" {
- type = "String"
- comment = "column_materializer::origin"
- }
- column "mat_email" {
- type = "String"
- comment = "column_materializer::email"
- }
- column "mat_key" {
- type = "String"
- comment = "column_materializer::key"
- }
- column "mat_insight" {
- type = "String"
- comment = "column_materializer::insight"
- }
- column "mat_$event_type" {
- type = "String"
- comment = "column_materializer::$event_type"
- }
- column "mat_created_by" {
- type = "String"
- comment = "column_materializer::created_by"
- }
- column "mat_total_event_actions_count" {
- type = "String"
- comment = "column_materializer::total_event_actions_count"
- }
- column "mat_is_demo_project" {
- type = "String"
- comment = "column_materializer::is_demo_project"
- }
- column "mat_$active_feature_flags" {
- type = "String"
- comment = "column_materializer::$active_feature_flags"
- }
- column "mat_filters_count" {
- type = "String"
- comment = "column_materializer::filters_count"
- }
- column "mat_utm_source" {
- type = "String"
- comment = "column_materializer::utm_source"
- }
- column "mat_apiErrorMessage" {
- type = "String"
- comment = "column_materializer::apiErrorMessage"
- }
- column "mat_$referring_domain" {
- type = "String"
- comment = "column_materializer::$referring_domain"
- }
- column "mat_statusCode" {
- type = "String"
- comment = "column_materializer::statusCode"
- }
- column "mat_deal_id" {
- type = "String"
- comment = "column_materializer::deal_id"
- }
- column "mat_realm" {
- type = "String"
- comment = "column_materializer::realm"
- }
- column "$group_0" {
- type = "String"
- comment = "column_materializer::$group_0"
- }
- column "$group_1" {
- type = "String"
- comment = "column_materializer::$group_1"
- }
- column "$group_2" {
- type = "String"
- comment = "column_materializer::$group_2"
- }
- column "$group_3" {
- type = "String"
- comment = "column_materializer::$group_3"
- }
- column "$group_4" {
- type = "String"
- comment = "column_materializer::$group_4"
- }
- column "mat_$lib" {
- type = "String"
- comment = "column_materializer::$lib"
- }
- column "mat_$os" {
- type = "String"
- comment = "column_materializer::$os"
- }
- column "mat_$initial_referrer" {
- type = "String"
- comment = "column_materializer::$initial_referrer"
- }
- column "mat_$app_version" {
- type = "String"
- comment = "column_materializer::$app_version"
- }
- column "mat_$initial_referring_domain" {
- type = "String"
- comment = "column_materializer::$initial_referring_domain"
- }
- column "mat_symbol" {
- type = "String"
- comment = "column_materializer::symbol"
- }
- column "mat_page" {
- type = "String"
- comment = "column_materializer::page"
- }
- column "mat_type" {
- type = "String"
- comment = "column_materializer::type"
- }
- column "mat_currentScreen" {
- type = "String"
- comment = "column_materializer::currentScreen"
- }
- column "mat_utm_campaign" {
- type = "String"
- comment = "column_materializer::utm_campaign"
- }
- column "mat_is_organization_first_user" {
- type = "String"
- comment = "column_materializer::is_organization_first_user"
- }
- column "mat_is_first_component_load" {
- type = "String"
- comment = "column_materializer::is_first_component_load"
- }
- column "mat_team" {
- type = "String"
- comment = "column_materializer::team"
- }
- column "mat_context" {
- type = "String"
- comment = "column_materializer::context"
- }
- column "mat_sdk" {
- type = "String"
- comment = "column_materializer::sdk"
- }
- column "mat_created_by_system" {
- type = "String"
- comment = "column_materializer::created_by_system"
- }
- column "mat_item_count" {
- type = "String"
- comment = "column_materializer::item_count"
- }
- column "mat_$ip" {
- type = "String"
- comment = "column_materializer::$ip"
- }
- column "mat_$referrer" {
- type = "String"
- comment = "column_materializer::$referrer"
- }
- column "mat_action_name" {
- type = "String"
- comment = "column_materializer::action_name"
- }
- column "mat_$geoip_country_name" {
- type = "String"
- comment = "column_materializer::$geoip_country_name"
- }
- column "mat_$device_model" {
- type = "String"
- comment = "column_materializer::$device_model"
- }
- column "mat_progress" {
- type = "String"
- comment = "column_materializer::progress"
- }
- column "mat_chain" {
- type = "String"
- comment = "column_materializer::chain"
- }
- column "mat_$device_type" {
- type = "String"
- comment = "column_materializer::$device_type"
- }
- column "mat_usd" {
- type = "String"
- comment = "column_materializer::usd"
- }
- column "mat_app_name" {
- type = "String"
- comment = "column_materializer::app_name"
- }
- column "mat_$screen_name" {
- type = "String"
- comment = "column_materializer::$screen_name"
- }
- column "mat_index" {
- type = "String"
- comment = "column_materializer::index"
- }
- column "mat_token" {
- type = "String"
- comment = "column_materializer::token"
- }
- column "mat_method" {
- type = "String"
- comment = "column_materializer::method"
- }
- column "mat_address" {
- type = "String"
- comment = "column_materializer::address"
- }
- column "mat_name" {
- type = "String"
- comment = "column_materializer::name"
- }
- column "mat_inviteCode" {
- type = "String"
- comment = "column_materializer::inviteCode"
- }
- column "$window_id" {
- type = "String"
- comment = "column_materializer::$window_id"
- }
- column "$session_id" {
- type = "String"
- comment = "column_materializer::$session_id"
- }
- column "mat_osName" {
- type = "String"
- comment = "column_materializer::osName"
- }
- column "mat_nativeBuildVersion" {
- type = "String"
- comment = "column_materializer::nativeBuildVersion"
- }
- column "mat_revenue" {
- type = "String"
- comment = "column_materializer::revenue"
- }
- column "group_0" {
- type = "String"
- alias = "`$group_0`"
- }
- column "group_1" {
- type = "String"
- alias = "`$group_1`"
- }
- column "group_2" {
- type = "String"
- alias = "`$group_2`"
- }
- column "group_3" {
- type = "String"
- alias = "`$group_3`"
- }
- column "group_4" {
- type = "String"
- alias = "`$group_4`"
- }
- column "alias_mat__user_id" {
- type = "String"
- alias = "`mat_$user_id`"
- }
- column "alias_mat__browser" {
- type = "String"
- alias = "`mat_$browser`"
- }
- column "alias_mat__host" {
- type = "String"
- alias = "`mat_$host`"
- }
- column "alias_mat__current_url" {
- type = "String"
- alias = "`mat_$current_url`"
- }
- column "alias_mat__event_type" {
- type = "String"
- alias = "`mat_$event_type`"
- }
- column "alias_mat__active_feature_flags" {
- type = "String"
- alias = "`mat_$active_feature_flags`"
- }
- column "alias_mat__referring_domain" {
- type = "String"
- alias = "`mat_$referring_domain`"
- }
- column "alias_mat__lib" {
- type = "String"
- alias = "`mat_$lib`"
- }
- column "alias_mat__os" {
- type = "String"
- alias = "`mat_$os`"
- }
- column "alias_mat__initial_referrer" {
- type = "String"
- alias = "`mat_$initial_referrer`"
- }
- column "alias_mat__app_version" {
- type = "String"
- alias = "`mat_$app_version`"
- }
- column "alias_mat__initial_referring_domain" {
- type = "String"
- alias = "`mat_$initial_referring_domain`"
- }
- column "alias_mat__ip" {
- type = "String"
- alias = "`mat_$ip`"
- }
- column "alias_mat__referrer" {
- type = "String"
- alias = "`mat_$referrer`"
- }
- column "alias_mat__geoip_country_name" {
- type = "String"
- alias = "`mat_$geoip_country_name`"
- }
- column "alias_mat__device_model" {
- type = "String"
- alias = "`mat_$device_model`"
- }
- column "alias_mat__device_type" {
- type = "String"
- alias = "`mat_$device_type`"
- }
- column "alias_mat__screen_name" {
- type = "String"
- alias = "`mat_$screen_name`"
- }
- column "person_id" {
- type = "UUID"
- }
- 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 "person_created_at" {
- type = "DateTime64(3)"
- }
- column "group0_created_at" {
- type = "DateTime64(3)"
- }
- column "group1_created_at" {
- type = "DateTime64(3)"
- }
- column "group2_created_at" {
- type = "DateTime64(3)"
- }
- column "group3_created_at" {
- type = "DateTime64(3)"
- }
- column "group4_created_at" {
- type = "DateTime64(3)"
- }
- column "mat_arguments" {
- type = "String"
- comment = "column_materializer::properties::arguments"
- }
- column "mat_source" {
- type = "String"
- comment = "column_materializer::properties::source"
- }
- column "mat_pp_email" {
- type = "String"
- comment = "column_materializer::person_properties::email"
- }
- column "mat_$time" {
- type = "String"
- comment = "column_materializer::properties::$time"
- }
- column "mat_$pathname" {
- type = "String"
- comment = "column_materializer::properties::$pathname"
- }
- column "mat_$geoip_city_name" {
- type = "String"
- comment = "column_materializer::properties::$geoip_city_name"
- }
- column "mat_community_id" {
- type = "String"
- comment = "column_materializer::properties::community_id"
- }
- column "mat_thread_id" {
- type = "String"
- comment = "column_materializer::properties::thread_id"
- }
- column "mat_Event_productCode" {
- type = "String"
- comment = "column_materializer::properties::Event.productCode"
- }
- column "mat_env" {
- type = "String"
- comment = "column_materializer::properties::env"
- }
- column "mat_target" {
- type = "String"
- comment = "column_materializer::properties::target"
- }
- column "mat_Subscription_plan_amount" {
- type = "String"
- comment = "column_materializer::properties::Subscription.plan.amount"
- }
- column "mat_title" {
- type = "String"
- comment = "column_materializer::properties::title"
- }
- column "mat_Connection_app_name" {
- type = "String"
- comment = "column_materializer::properties::Connection.app.name"
- }
- column "mat_utm_medium" {
- type = "String"
- comment = "column_materializer::properties::utm_medium"
- }
- column "mat_Account_client_id" {
- type = "String"
- comment = "column_materializer::properties::Account.client_id"
- }
- column "mat_HTTP_Method" {
- type = "String"
- comment = "column_materializer::properties::HTTP Method"
- }
- column "mat_audio_duration" {
- type = "String"
- comment = "column_materializer::properties::audio_duration"
- }
- column "mat_duration" {
- type = "String"
- comment = "column_materializer::properties::duration"
- }
- column "mat_url" {
- type = "String"
- comment = "column_materializer::properties::url"
- }
- column "mat_group_id" {
- type = "String"
- comment = "column_materializer::properties::group_id"
- }
- column "mat_platform" {
- type = "String"
- comment = "column_materializer::properties::platform"
- }
- column "mat_pp_$browser" {
- type = "String"
- comment = "column_materializer::person_properties::$browser"
- }
- column "mat_payment_status" {
- type = "String"
- comment = "column_materializer::properties::payment_status"
- }
- column "mat_testSessionId" {
- type = "String"
- comment = "column_materializer::properties::testSessionId"
- }
- column "inserted_at" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- default = "now64()"
- }
- column "mat_$sent_at" {
- type = "String"
- comment = "column_materializer::properties::$sent_at"
- }
- column "mat_pp_companyName" {
- type = "String"
- comment = "column_materializer::person_properties::companyName"
- }
- column "mat_function" {
- type = "String"
- comment = "column_materializer::properties::function"
- }
- column "mat_store_url" {
- type = "String"
- comment = "column_materializer::properties::store_url"
- }
- column "mat_email_domain" {
- type = "String"
- comment = "column_materializer::properties::email_domain"
- }
- column "mat_institution_name" {
- type = "String"
- comment = "column_materializer::properties::institution_name"
- }
- column "mat_authentication_method" {
- type = "String"
- comment = "column_materializer::properties::authentication_method"
- }
- column "mat_initial_step" {
- type = "String"
- comment = "column_materializer::properties::initial_step"
- }
- column "mat_status_message" {
- type = "String"
- comment = "column_materializer::properties::status_message"
- }
- column "mat_mode" {
- type = "String"
- comment = "column_materializer::properties::mode"
- }
- column "mat_protocol" {
- type = "String"
- comment = "column_materializer::properties::protocol"
- }
- column "mat_job_type" {
- type = "String"
- comment = "column_materializer::properties::job_type"
- }
- column "mat_is_oauth" {
- type = "String"
- comment = "column_materializer::properties::is_oauth"
- }
- column "mat_is_initial_aggregation" {
- type = "String"
- comment = "column_materializer::properties::is_initial_aggregation"
- }
- column "mat_search_term" {
- type = "String"
- comment = "column_materializer::properties::search_term"
- }
- column "mat_valid_ach_accounts" {
- type = "String"
- comment = "column_materializer::properties::valid_ach_accounts"
- }
- column "mat_gross" {
- type = "String"
- comment = "column_materializer::properties::gross"
- }
- column "mat_orderType" {
- type = "String"
- comment = "column_materializer::properties::orderType"
- }
- column "mat_sku" {
- type = "String"
- comment = "column_materializer::properties::sku"
- }
- column "mat_dual_channel" {
- type = "String"
- comment = "column_materializer::properties::dual_channel"
- }
- column "mat_channel" {
- type = "String"
- comment = "column_materializer::properties::channel"
- }
- column "mat_workspaceId" {
- type = "String"
- comment = "column_materializer::properties::workspaceId"
- }
- column "mat_numberOfSecrets" {
- type = "String"
- comment = "column_materializer::properties::numberOfSecrets"
- }
- column "mat_organizations" {
- type = "String"
- comment = "column_materializer::properties::organizations"
- }
- column "mat_organization" {
- type = "String"
- comment = "column_materializer::properties::organization"
- }
- column "mat_contributionError" {
- type = "String"
- comment = "column_materializer::properties::contributionError"
- }
- column "mat_phone" {
- type = "String"
- comment = "column_materializer::properties::phone"
- }
- column "mat_$initial_pathname" {
- type = "String"
- comment = "column_materializer::properties::$initial_pathname"
- }
- column "mat_organization_name" {
- type = "String"
- comment = "column_materializer::properties::organization_name"
- }
- column "mat_category" {
- type = "String"
- comment = "column_materializer::properties::category"
- }
- column "mat_$lib_version" {
- type = "String"
- comment = "column_materializer::properties::$lib_version"
- }
- column "mat_pp_$initial_utm_campaign" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_campaign"
- }
- column "mat_pp_$initial_utm_medium" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_medium"
- }
- column "mat_pp_$initial_gclid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_gclid"
- }
- column "mat_pp_$initial_gad_source" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_gad_source"
- }
- column "mat_pp_$initial_utm_source" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_source"
- }
- column "mat_pp_$initial_referring_domain" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_referring_domain"
- }
- column "mat_pp_$initial_utm_term" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_term"
- }
- column "mat_pp_$initial_utm_content" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_content"
- }
- column "mat_pp_$initial_gbraid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_gbraid::disabled"
- }
- column "mat_pp_$initial_wbraid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_wbraid::disabled"
- }
- column "mat_pp_$initial_msclkid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_msclkid"
- }
- column "mat_pp_$initial_fbclid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_fbclid"
- }
- column "mat_$geoip_subdivision_1_code" {
- type = "String"
- comment = "column_materializer::properties::$geoip_subdivision_1_code"
- }
- column "mat_wlo_enabled" {
- type = "String"
- comment = "column_materializer::properties::wlo_enabled"
- }
- column "mat_$prev_pageview_max_scroll_percentage" {
- type = "String"
- comment = "column_materializer::properties::$prev_pageview_max_scroll_percentage"
- }
- column "mat_$prev_pageview_max_content_percentage" {
- type = "String"
- comment = "column_materializer::properties::$prev_pageview_max_content_percentage"
- }
- column "mat_$prev_pageview_pathname" {
- type = "String"
- comment = "column_materializer::properties::$prev_pageview_pathname"
- }
- column "mat_pp_$initial_pathname" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_pathname"
- }
- column "mat_pp_$geoip_country_code" {
- type = "String"
- comment = "column_materializer::person_properties::$geoip_country_code"
- }
- column "mat_pp_username" {
- type = "String"
- comment = "column_materializer::person_properties::username"
- }
- column "mat_pp_serverMasterclass" {
- type = "String"
- comment = "column_materializer::person_properties::serverMasterclass"
- }
- column "mat_content_length" {
- type = "String"
- comment = "column_materializer::properties::content_length"
- }
- column "mat_pp_serverMarketing" {
- type = "String"
- comment = "column_materializer::person_properties::serverMarketing"
- }
- column "mat_$browser_version" {
- type = "String"
- comment = "column_materializer::properties::$browser_version"
- }
- column "mat_pp_role" {
- type = "String"
- comment = "column_materializer::person_properties::role"
- }
- column "mat_pp_customer" {
- type = "String"
- comment = "column_materializer::person_properties::customer"
- }
- column "mat_event" {
- type = "String"
- comment = "column_materializer::properties::event"
- }
- column "mat_disable_institution_search" {
- type = "String"
- comment = "column_materializer::properties::disable_institution_search"
- }
- column "mat_is_first_event_for_user" {
- type = "String"
- comment = "column_materializer::properties::is_first_event_for_user"
- }
- column "mat_current_member_guid" {
- type = "String"
- comment = "column_materializer::properties::current_member_guid"
- }
- column "mat_user_agent" {
- type = "String"
- comment = "column_materializer::properties::user_agent"
- }
- column "mat_is_test_user" {
- type = "String"
- comment = "column_materializer::properties::is_test_user"
- }
- column "mat_referrer" {
- type = "String"
- comment = "column_materializer::properties::referrer"
- }
- column "mat_pp_$initial_current_url" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_current_url"
- }
- column "mat_most_recent_app_os" {
- type = "String"
- comment = "column_materializer::properties::most_recent_app_os"
- }
- column "mat_pp_hubspot_score" {
- type = "String"
- comment = "column_materializer::person_properties::hubspot_score"
- }
- column "mat_pp_id" {
- type = "String"
- comment = "column_materializer::person_properties::id"
- }
- column "mat_pp_$current_url" {
- type = "String"
- comment = "column_materializer::person_properties::$current_url"
- }
- column "mat_product_key" {
- type = "String"
- comment = "column_materializer::properties::product_key"
- }
- column "mat_Plan_type_and_filter" {
- type = "String"
- comment = "column_materializer::properties::Plan type and filter"
- }
- column "mat_$app_namespace" {
- type = "String"
- comment = "column_materializer::properties::$app_namespace"
- }
- column "mat_$os_name" {
- type = "String"
- comment = "column_materializer::properties::$os_name"
- }
- column "mat_pp_$os_name" {
- type = "String"
- comment = "column_materializer::person_properties::$os_name::disabled"
- }
- column "mat_pp_$app_version" {
- type = "String"
- comment = "column_materializer::person_properties::$app_version"
- }
- column "mat_subscriptionStatus" {
- type = "String"
- comment = "column_materializer::properties::subscriptionStatus"
- }
- column "mat_$screen_height" {
- type = "String"
- comment = "column_materializer::properties::$screen_height"
- }
- column "mat_$screen_width" {
- type = "String"
- comment = "column_materializer::properties::$screen_width"
- }
- column "mat_tag" {
- type = "String"
- comment = "column_materializer::properties::tag"
- }
- column "mat_$app_build" {
- type = "String"
- comment = "column_materializer::properties::$app_build"
- }
- column "mat_surface_tag" {
- type = "String"
- comment = "column_materializer::properties::surface_tag"
- }
- column "mat_survey_responses_count_in_period" {
- type = "String"
- comment = "column_materializer::properties::survey_responses_count_in_period"
- }
- column "mat_event_count_in_month" {
- type = "String"
- comment = "column_materializer::properties::event_count_in_month"
- }
- column "mat_ramp" {
- type = "String"
- comment = "column_materializer::properties::ramp"
- }
- column "mat_auto_chapters" {
- type = "String"
- comment = "column_materializer::properties::auto_chapters"
- }
- column "mat_sentiment_analysis" {
- type = "String"
- comment = "column_materializer::properties::sentiment_analysis"
- }
- column "mat_redact_pii" {
- type = "String"
- comment = "column_materializer::properties::redact_pii"
- }
- column "mat_content_safety" {
- type = "String"
- comment = "column_materializer::properties::content_safety"
- }
- column "mat_iab_categories" {
- type = "String"
- comment = "column_materializer::properties::iab_categories"
- }
- column "mat_auto_highlights" {
- type = "String"
- comment = "column_materializer::properties::auto_highlights"
- }
- column "mat_entity_detection" {
- type = "String"
- comment = "column_materializer::properties::entity_detection"
- }
- column "mat_summarization" {
- type = "String"
- comment = "column_materializer::properties::summarization"
- }
- column "mat_pp_val_region" {
- type = "String"
- comment = "column_materializer::person_properties::val_region"
- }
- column "mat_client_id" {
- type = "String"
- comment = "column_materializer::properties::client_id"
- }
- column "mat_$geoip_country_code" {
- type = "String"
- comment = "column_materializer::properties::$geoip_country_code"
- }
- column "mat_disfluencies" {
- type = "String"
- comment = "column_materializer::properties::disfluencies"
- }
- column "mat_filter_profanity" {
- type = "String"
- comment = "column_materializer::properties::filter_profanity"
- }
- column "mat_speaker_labels" {
- type = "String"
- comment = "column_materializer::properties::speaker_labels"
- }
- column "mat_language_detection" {
- type = "String"
- comment = "column_materializer::properties::language_detection"
- }
- column "mat_product_analytics_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::product_analytics_projected_amount"
- }
- column "mat_recordings_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::recordings_projected_amount"
- }
- column "mat_events_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::events_projected_amount"
- }
- column "mat_session_replay_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::session_replay_projected_amount"
- }
- column "mat_total_usd" {
- type = "String"
- comment = "column_materializer::properties::total_usd"
- }
- column "mat_stripe_amount_paid" {
- type = "String"
- comment = "column_materializer::properties::stripe_amount_paid"
- }
- column "mat_workspace" {
- type = "String"
- comment = "column_materializer::properties::workspace"
- }
- column "mat_created_at" {
- type = "String"
- comment = "column_materializer::properties::created_at"
- }
- column "mat_kind" {
- type = "String"
- comment = "column_materializer::properties::kind"
- }
- column "mat_product" {
- type = "String"
- comment = "column_materializer::properties::product"
- }
- column "mat_message" {
- type = "String"
- comment = "column_materializer::properties::message"
- }
- column "mat_initiator" {
- type = "String"
- comment = "column_materializer::properties::initiator"
- }
- column "mat_query" {
- type = "String"
- comment = "column_materializer::properties::query"
- }
- column "mat_$survey_id" {
- type = "String"
- comment = "column_materializer::properties::$survey_id"
- }
- column "mat_$survey_response_1" {
- type = "String"
- comment = "column_materializer::properties::$survey_response_1"
- }
- column "mat_ticketId" {
- type = "String"
- comment = "column_materializer::properties::ticketId"
- }
- column "mat_$survey_response" {
- type = "String"
- comment = "column_materializer::properties::$survey_response"
- }
- column "mat_conceptName" {
- type = "String"
- comment = "column_materializer::properties::conceptName"
- }
- column "mat_apiName" {
- type = "String"
- comment = "column_materializer::properties::apiName"
- }
- column "mat_workplace_billing_plan" {
- type = "String"
- comment = "column_materializer::properties::workplace_billing_plan"
- }
- column "mat_$el_text" {
- type = "String"
- comment = "column_materializer::properties::$el_text"
- }
- column "mat_recording_count_in_period" {
- type = "String"
- comment = "column_materializer::properties::recording_count_in_period"
- }
- column "mat_$os_version" {
- type = "String"
- comment = "column_materializer::properties::$os_version"
- }
- column "mat_orderId" {
- type = "String"
- comment = "column_materializer::properties::orderId"
- }
- column "mat_commit_sha" {
- type = "String"
- comment = "column_materializer::properties::commit_sha"
- }
- column "mat_$feature_flag_payloads" {
- type = "String"
- comment = "column_materializer::properties::$feature_flag_payloads"
- }
- column "mat_event_count_in_period" {
+ column "$group_0" {
type = "String"
- comment = "column_materializer::properties::event_count_in_period"
+ comment = "column_materializer::$group_0"
}
- column "mat_$groups" {
+ column "$group_1" {
type = "String"
- comment = "column_materializer::properties::$groups"
+ comment = "column_materializer::$group_1"
}
- column "mat_$feature_flag" {
+ column "$group_2" {
type = "String"
- comment = "column_materializer::properties::$feature_flag"
+ comment = "column_materializer::$group_2"
}
- column "mat_utm_content" {
+ column "$group_3" {
type = "String"
- comment = "column_materializer::properties::utm_content"
+ comment = "column_materializer::$group_3"
}
- column "mat_gclid" {
+ column "$group_4" {
type = "String"
- comment = "column_materializer::properties::gclid"
+ comment = "column_materializer::$group_4"
}
- column "mat_gad_source" {
+ column "$window_id" {
type = "String"
- comment = "column_materializer::properties::gad_source"
+ comment = "column_materializer::$window_id"
}
- column "mat_gbraid" {
+ column "$session_id" {
type = "String"
- comment = "column_materializer::properties::gbraid"
+ comment = "column_materializer::$session_id"
}
- column "mat_wbraid" {
- type = "String"
- comment = "column_materializer::properties::wbraid"
+ column "group_0" {
+ type = "String"
+ alias = "`$group_0`"
}
- column "mat_fbclid" {
- type = "String"
- comment = "column_materializer::properties::fbclid"
+ column "group_1" {
+ type = "String"
+ alias = "`$group_1`"
}
- column "mat_msclkid" {
- type = "String"
- comment = "column_materializer::properties::msclkid"
+ column "group_2" {
+ type = "String"
+ alias = "`$group_2`"
}
- column "mat_organization_id" {
- type = "String"
- comment = "column_materializer::properties::organization_id"
+ column "group_3" {
+ type = "String"
+ alias = "`$group_3`"
}
- column "mat_owner_type" {
- type = "String"
- comment = "column_materializer::properties::owner_type"
+ column "group_4" {
+ type = "String"
+ alias = "`$group_4`"
}
- column "mat_device_type" {
- type = "String"
- comment = "column_materializer::properties::device_type"
+ column "person_id" {
+ type = "UUID"
}
- column "mat_$device_id" {
- type = "String"
- comment = "column_materializer::properties::$device_id"
+ column "person_properties" {
+ type = "String"
}
- column "mat_pp_$geoip_continent_name" {
- type = "String"
- comment = "column_materializer::person_properties::$geoip_continent_name"
+ column "group0_properties" {
+ type = "String"
}
- column "mat_$feature_flag_response" {
- type = "String"
- comment = "column_materializer::properties::$feature_flag_response"
+ column "group1_properties" {
+ type = "String"
}
- column "mat_pp_utm_source" {
- type = "String"
- comment = "column_materializer::person_properties::utm_source"
+ column "group2_properties" {
+ type = "String"
}
- column "mat_pp_$referring_domain" {
- type = "String"
- comment = "column_materializer::person_properties::$referring_domain"
+ column "group3_properties" {
+ type = "String"
}
- column "mat_pp_Email_Domain" {
- type = "String"
- comment = "column_materializer::person_properties::Email Domain"
+ column "group4_properties" {
+ type = "String"
}
- column "mat_machine_id" {
- type = "String"
- comment = "column_materializer::properties::machine_id"
+ column "person_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_user_email_domain" {
- type = "String"
- comment = "column_materializer::properties::user_email_domain"
+ column "group0_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_$lib_version__minor" {
- type = "String"
- comment = "column_materializer::properties::$lib_version__minor"
+ column "group1_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_region" {
- type = "String"
- comment = "column_materializer::properties::region"
+ column "group2_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_pp_user_email_domain" {
- type = "String"
- comment = "column_materializer::person_properties::user_email_domain"
+ column "group3_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_url_promotion_id" {
- type = "String"
- comment = "column_materializer::properties::url_promotion_id"
+ column "group4_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_$lib_custom_api_host" {
- type = "String"
- comment = "column_materializer::properties::$lib_custom_api_host"
+ column "inserted_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ default = "now64()"
}
column "person_mode" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
- column "mat_user_platform" {
- type = "String"
- comment = "column_materializer::properties::user_platform"
- }
- column "mat_pp_$geoip_country_name" {
- type = "String"
- comment = "column_materializer::person_properties::$geoip_country_name"
- }
- column "mat_environment" {
- type = "String"
- comment = "column_materializer::properties::environment"
- }
- column "mat_customer_email" {
- type = "String"
- comment = "column_materializer::properties::customer_email"
- }
- column "mat_client_name" {
- type = "String"
- comment = "column_materializer::properties::client_name"
- }
- column "mat_screen_name" {
- type = "String"
- comment = "column_materializer::properties::screen_name"
- }
- column "mat_app_version" {
- type = "String"
- comment = "column_materializer::properties::app_version"
- }
column "elements_chain_href" {
type = "String"
comment = "column_materializer::elements_chain::href"
@@ -1239,62 +199,6 @@ database "posthog" {
column "is_deleted" {
type = "Bool"
}
- column "mat_subdomain" {
- type = "String"
- comment = "column_materializer::properties::subdomain"
- }
- column "mat_$device" {
- type = "String"
- comment = "column_materializer::properties::$device"
- }
- column "mat_id" {
- type = "String"
- comment = "column_materializer::properties::id"
- }
- column "mat_record_id" {
- type = "String"
- comment = "column_materializer::properties::record_id"
- }
- column "mat_referrer_id" {
- type = "String"
- comment = "column_materializer::properties::record_id"
- }
- column "mat_$exception_issue_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_issue_id"
- }
- column "mat_$exception_fingerprint" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_fingerprint"
- }
- column "mat_$web_vitals_LCP_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_LCP_value"
- }
- column "mat_$web_vitals_FCP_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_FCP_value"
- }
- column "mat_$web_vitals_CLS_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_CLS_value"
- }
- column "mat_$web_vitals_INP_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_INP_value"
- }
- column "mat_$viewport_width" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$viewport_width"
- }
- column "mat_$viewport_height" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$viewport_height"
- }
- column "mat_$anon_distinct_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$anon_distinct_id"
- }
column "person_properties_map_custom" {
type = "Map(String, String)"
}
@@ -1302,59 +206,15 @@ database "posthog" {
type = "Nullable(String)"
comment = "column_materializer::properties::$ai_trace_id"
}
- column "mat_$ai_model" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_model"
- }
- column "mat_$ai_provider" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_provider"
- }
- column "mat_$ai_parent_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_parent_id"
- }
- column "mat_$ai_span_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_span_id"
- }
- column "mat_$ai_http_status" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_http_status"
- }
- column "mat_$exception_types" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_types"
- }
- column "mat_$exception_values" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_values"
- }
- column "mat_$exception_sources" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_sources"
- }
- column "mat_$exception_functions" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_functions"
- }
column "$session_id_uuid" {
type = "Nullable(UInt128)"
}
- column "mat_$process_person_profile" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$process_person_profile"
- }
column "consumer_breadcrumbs" {
type = "Array(String)"
}
column "properties_group_ai" {
type = "Map(String, String)"
}
- column "mat_$is_identified" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$is_identified"
- }
column "mat_historical_migration" {
type = "Nullable(String)"
comment = "column_materializer::properties::historical_migration"
@@ -1397,103 +257,9 @@ database "posthog" {
column "dmat_string_9" {
type = "Nullable(String)"
}
- column "dmat_numeric_0" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_1" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_2" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_3" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_4" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_5" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_6" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_7" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_8" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_9" {
- type = "Nullable(Float64)"
- }
- column "dmat_bool_0" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_1" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_2" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_3" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_4" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_5" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_6" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_7" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_8" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_9" {
- type = "Nullable(UInt8)"
- }
- column "dmat_datetime_0" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_1" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_2" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_3" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_4" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_5" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_6" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_7" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_8" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_9" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
column "historical_migration" {
type = "Bool"
}
- column "mat_$ai_total_cost_usd" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_total_cost_usd"
- }
column "properties_group_ai_large" {
type = "Map(String, String)"
}
@@ -1505,34 +271,6 @@ database "posthog" {
type = "Nullable(String)"
comment = "column_materializer::properties::$ai_experiment_id"
}
- column "mat_$survey_submission_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$survey_submission_id"
- }
- column "mat_$geoip_subdivision_1_name" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$geoip_subdivision_1_name"
- }
- column "mat_$raw_user_agent" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$raw_user_agent"
- }
- column "mat_$prev_pageview_duration" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$prev_pageview_duration"
- }
- column "mat_pp_$initial_host" {
- type = "Nullable(String)"
- comment = "column_materializer::person_properties::$initial_host"
- }
- column "mat_pp_$initial_url" {
- type = "Nullable(String)"
- comment = "column_materializer::person_properties::$initial_url"
- }
- column "mat_pp_$initial_geoip_country_name" {
- type = "Nullable(String)"
- comment = "column_materializer::person_properties::$initial_geoip_country_name"
- }
engine "distributed" {
cluster_name = "posthog"
remote_database = "posthog"
@@ -2124,6 +862,7 @@ database "posthog" {
partition_by = "toYYYYMM(session_timestamp)"
settings = {
index_granularity = "8192"
+ storage_policy = "s3_tiered"
}
column "team_id" {
type = "Int64"
@@ -2649,10 +1388,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -2725,10 +1464,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/golden/prod-us/ai_events.hcl b/posthog/clickhouse/hcl/golden/prod-us/ai_events.hcl
index 96281ceca5a0..8c12d55e1506 100644
--- a/posthog/clickhouse/hcl/golden/prod-us/ai_events.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-us/ai_events.hcl
@@ -283,10 +283,10 @@ database "posthog" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ai_events_json'"
- group_name = "kafka_group_name = 'clickhouse_ai_events_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ai_events_json"
+ group_name = "clickhouse_ai_events_ws"
+ format = "JSONEachRow"
num_consumers = 16
max_block_size = 5000
skip_broken_messages = 100
@@ -1268,10 +1268,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -1344,10 +1344,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -1408,3 +1408,39 @@ SQL
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl b/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl
index cd3c6c862c07..21e68205200d 100644
--- a/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-us/auxiliary.hcl
@@ -574,10 +574,10 @@ database "posthog" {
type = "UInt8"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
- group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_hog_invocation_results"
+ group_name = "clickhouse_hog_invocation_results"
+ format = "JSONEachRow"
num_consumers = 1
max_block_size = 100000
skip_broken_messages = 100
@@ -603,10 +603,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"
- group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ingestion_warnings"
+ group_name = "clickhouse_ingestion_warnings_v2"
+ format = "JSONEachRow"
}
}
@@ -660,10 +660,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_message_assets'"
- group_name = "kafka_group_name = 'clickhouse_message_assets'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_message_assets"
+ group_name = "clickhouse_message_assets"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -685,10 +685,10 @@ database "posthog" {
type = "UInt64"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_property_values'"
- group_name = "kafka_group_name = 'clickhouse_property_values'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_property_values"
+ group_name = "clickhouse_property_values"
+ format = "JSONEachRow"
num_consumers = 8
thread_per_consumer = true
}
@@ -3950,10 +3950,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -4026,10 +4026,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -4120,3 +4120,39 @@ SQL
}
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-us/batch_exports.hcl b/posthog/clickhouse/hcl/golden/prod-us/batch_exports.hcl
index f83e323db06b..000e5af18adc 100644
--- a/posthog/clickhouse/hcl/golden/prod-us/batch_exports.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-us/batch_exports.hcl
@@ -756,10 +756,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -832,10 +832,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl b/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
index 063678d6baab..42e50dd549da 100644
--- a/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-us/logs.hcl
@@ -61,10 +61,10 @@ database "posthog" {
type = "Nullable(Int64)"
}
engine "kafka" {
- broker_list = "warpstream_metrics"
- topic_list = "kafka_topic_list = 'clickhouse_metrics'"
- group_name = "kafka_group_name = 'clickhouse-metrics-avro-new'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_metrics"
+ topic_list = "clickhouse_metrics"
+ group_name = "clickhouse-metrics-avro-new"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -138,10 +138,10 @@ database "posthog" {
type = "Int32"
}
engine "kafka" {
- broker_list = "warpstream_traces"
- topic_list = "kafka_topic_list = 'clickhouse_traces'"
- group_name = "kafka_group_name = 'clickhouse-traces-avro'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_traces"
+ topic_list = "clickhouse_traces"
+ group_name = "clickhouse-traces-avro"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
@@ -3768,10 +3768,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -3844,10 +3844,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
@@ -3908,3 +3908,39 @@ SQL
}
}
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/golden/prod-us/ops.hcl b/posthog/clickhouse/hcl/golden/prod-us/ops.hcl
new file mode 100644
index 000000000000..5c9a4d65b33f
--- /dev/null
+++ b/posthog/clickhouse/hcl/golden/prod-us/ops.hcl
@@ -0,0 +1,1918 @@
+database "posthog" {
+ table "event_property_daily_stats" {
+ order_by = ["analysis_date", "team_id", "property_key"]
+ ttl = "analysis_date + toIntervalDay(30)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "analysis_date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "event_count" {
+ type = "UInt64"
+ }
+ column "distinct_event_names" {
+ type = "UInt32"
+ }
+ column "total_property_bytes" {
+ type = "UInt64"
+ }
+ column "min_property_bytes" {
+ type = "UInt64"
+ }
+ column "max_property_bytes" {
+ type = "UInt64"
+ }
+ column "avg_property_bytes" {
+ type = "Float64"
+ }
+ column "p50_property_bytes" {
+ type = "Float64"
+ }
+ column "p90_property_bytes" {
+ type = "Float64"
+ }
+ column "p95_property_bytes" {
+ type = "Float64"
+ }
+ column "p99_property_bytes" {
+ type = "Float64"
+ }
+ column "property_size_histogram" {
+ type = "Array(Tuple(Float64, Float64, UInt64))"
+ }
+ column "top_event_names" {
+ type = "Array(String)"
+ }
+ column "sample_rate" {
+ type = "Float32"
+ }
+ column "computed_at" {
+ type = "DateTime"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.event_property_daily_stats"
+ replica_name = "{replica}"
+ }
+ }
+
+ 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"
+ }
+ projection "by_label_value" {
+ query = <<SQL
+SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, label_name, label_value, id, metric_name
+SQL
+
+ }
+ projection "by_id_label" {
+ query = <<SQL
+SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, id, label_name, metric_name, label_value
+SQL
+
+ }
+ 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", "toStartOfTenMinutes(timestamp)", "id", "timestamp"]
+ partition_by = "toYYYYMMDD(timestamp)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "UInt64"
+ codec = "T64, Default"
+ }
+ column "metric_name" {
+ type = "LowCardinality(String)"
+ }
+ column "timestamp" {
+ type = "DateTime64(3, 'UTC')"
+ codec = "DoubleDelta, Default"
+ }
+ column "id" {
+ type = "UInt64"
+ }
+ column "value" {
+ type = "Float64"
+ codec = "Gorilla(8), Default"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_samples_new"
+ 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')"
+ }
+ projection "by_id" {
+ query = <<SQL
+SELECT team_id, id, metric_name, labels_json, min_time, max_time
+ORDER BY team_id, id
+SQL
+
+ }
+ 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 "query_team_daily_stats" {
+ order_by = ["analysis_date", "team_id"]
+ partition_by = "analysis_date"
+ ttl = "analysis_date + toIntervalDay(90)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "analysis_date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "query_count" {
+ type = "UInt64"
+ }
+ column "error_count" {
+ type = "UInt64"
+ }
+ column "distinct_query_shapes" {
+ type = "UInt64"
+ }
+ column "total_duration_ms" {
+ type = "UInt64"
+ }
+ column "avg_duration_ms" {
+ type = "Float64"
+ }
+ column "p50_duration_ms" {
+ type = "Float64"
+ }
+ column "p90_duration_ms" {
+ type = "Float64"
+ }
+ column "p99_duration_ms" {
+ type = "Float64"
+ }
+ column "max_duration_ms" {
+ type = "UInt64"
+ }
+ column "total_read_rows" {
+ type = "UInt64"
+ }
+ column "total_read_bytes" {
+ type = "UInt64"
+ comment = "Uncompressed bytes scanned, coordinator-side summed across shards (is_initial_query=1). Compute/scan cost proxy, NOT stored footprint."
+ }
+ column "total_result_rows" {
+ type = "UInt64"
+ }
+ column "total_result_bytes" {
+ type = "UInt64"
+ }
+ column "total_written_rows" {
+ type = "UInt64"
+ }
+ column "total_written_bytes" {
+ type = "UInt64"
+ }
+ column "total_cpu_seconds" {
+ type = "Float64"
+ comment = "ProfileEvents OSCPUVirtualTimeMicroseconds summed across ALL QueryFinish rows (initiator + shard leaves) / 1e6. CPU is not folded onto the initiator row, so leaves must be summed."
+ }
+ column "total_memory_usage" {
+ type = "UInt64"
+ comment = "Peak memory_usage summed across all shard rows (per-node peak; not folded onto the initiator)."
+ }
+ column "max_memory_usage" {
+ type = "UInt64"
+ comment = "Largest single-node peak memory across all shard rows."
+ }
+ column "p99_memory_usage" {
+ type = "Float64"
+ }
+ column "total_s3_get_objects" {
+ type = "UInt64"
+ comment = "ProfileEvents S3GetObject summed across all shard rows: object-storage GET count."
+ }
+ column "total_s3_read_bytes" {
+ type = "UInt64"
+ comment = "ProfileEvents ReadBufferFromS3Bytes summed across all shard rows: object-storage read cost proxy."
+ }
+ column "query_kind_counts" {
+ type = "Map(String, UInt64)"
+ comment = "query_kind -> count for QueryFinish rows."
+ }
+ column "computed_at" {
+ type = "DateTime"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.query_team_daily_stats"
+ replica_name = "{replica}"
+ }
+ }
+
+ 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"
+ storage_policy = "s3_tiered"
+ }
+ 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/golden/prod-us/sessions.hcl b/posthog/clickhouse/hcl/golden/prod-us/sessions.hcl
index b11da14cb38e..27ec5381379e 100644
--- a/posthog/clickhouse/hcl/golden/prod-us/sessions.hcl
+++ b/posthog/clickhouse/hcl/golden/prod-us/sessions.hcl
@@ -84,1140 +84,100 @@ database "posthog" {
column "elements_chain" {
type = "String"
}
- column "mat_$user_id" {
- type = "String"
- comment = "column_materializer::$user_id"
- }
- column "mat_$browser" {
- type = "String"
- comment = "column_materializer::$browser"
- }
- column "mat_$host" {
- type = "String"
- comment = "column_materializer::$host"
- }
- column "mat_$current_url" {
- type = "String"
- comment = "column_materializer::$current_url"
- }
- column "mat_distinct_id" {
- type = "String"
- comment = "column_materializer::distinct_id"
- }
- column "mat_action" {
- type = "String"
- comment = "column_materializer::action"
- }
- column "mat_origin" {
- type = "String"
- comment = "column_materializer::origin"
- }
- column "mat_email" {
- type = "String"
- comment = "column_materializer::email"
- }
- column "mat_key" {
- type = "String"
- comment = "column_materializer::key"
- }
- column "mat_insight" {
- type = "String"
- comment = "column_materializer::insight"
- }
- column "mat_$event_type" {
- type = "String"
- comment = "column_materializer::$event_type"
- }
- column "mat_created_by" {
- type = "String"
- comment = "column_materializer::created_by"
- }
- column "mat_total_event_actions_count" {
- type = "String"
- comment = "column_materializer::total_event_actions_count"
- }
- column "mat_is_demo_project" {
- type = "String"
- comment = "column_materializer::is_demo_project"
- }
- column "mat_$active_feature_flags" {
- type = "String"
- comment = "column_materializer::$active_feature_flags"
- }
- column "mat_filters_count" {
- type = "String"
- comment = "column_materializer::filters_count"
- }
- column "mat_utm_source" {
- type = "String"
- comment = "column_materializer::utm_source"
- }
- column "mat_apiErrorMessage" {
- type = "String"
- comment = "column_materializer::apiErrorMessage"
- }
- column "mat_$referring_domain" {
- type = "String"
- comment = "column_materializer::$referring_domain"
- }
- column "mat_statusCode" {
- type = "String"
- comment = "column_materializer::statusCode"
- }
- column "mat_deal_id" {
- type = "String"
- comment = "column_materializer::deal_id"
- }
- column "mat_realm" {
- type = "String"
- comment = "column_materializer::realm"
- }
- column "$group_0" {
- type = "String"
- comment = "column_materializer::$group_0"
- }
- column "$group_1" {
- type = "String"
- comment = "column_materializer::$group_1"
- }
- column "$group_2" {
- type = "String"
- comment = "column_materializer::$group_2"
- }
- column "$group_3" {
- type = "String"
- comment = "column_materializer::$group_3"
- }
- column "$group_4" {
- type = "String"
- comment = "column_materializer::$group_4"
- }
- column "mat_$lib" {
- type = "String"
- comment = "column_materializer::$lib"
- }
- column "mat_$os" {
- type = "String"
- comment = "column_materializer::$os"
- }
- column "mat_$initial_referrer" {
- type = "String"
- comment = "column_materializer::$initial_referrer"
- }
- column "mat_$app_version" {
- type = "String"
- comment = "column_materializer::$app_version"
- }
- column "mat_$initial_referring_domain" {
- type = "String"
- comment = "column_materializer::$initial_referring_domain"
- }
- column "mat_symbol" {
- type = "String"
- comment = "column_materializer::symbol"
- }
- column "mat_page" {
- type = "String"
- comment = "column_materializer::page"
- }
- column "mat_type" {
- type = "String"
- comment = "column_materializer::type"
- }
- column "mat_currentScreen" {
- type = "String"
- comment = "column_materializer::currentScreen"
- }
- column "mat_utm_campaign" {
- type = "String"
- comment = "column_materializer::utm_campaign"
- }
- column "mat_is_organization_first_user" {
- type = "String"
- comment = "column_materializer::is_organization_first_user"
- }
- column "mat_is_first_component_load" {
- type = "String"
- comment = "column_materializer::is_first_component_load"
- }
- column "mat_team" {
- type = "String"
- comment = "column_materializer::team"
- }
- column "mat_context" {
- type = "String"
- comment = "column_materializer::context"
- }
- column "mat_sdk" {
- type = "String"
- comment = "column_materializer::sdk"
- }
- column "mat_created_by_system" {
- type = "String"
- comment = "column_materializer::created_by_system"
- }
- column "mat_item_count" {
- type = "String"
- comment = "column_materializer::item_count"
- }
- column "mat_$ip" {
- type = "String"
- comment = "column_materializer::$ip"
- }
- column "mat_$referrer" {
- type = "String"
- comment = "column_materializer::$referrer"
- }
- column "mat_action_name" {
- type = "String"
- comment = "column_materializer::action_name"
- }
- column "mat_$geoip_country_name" {
- type = "String"
- comment = "column_materializer::$geoip_country_name"
- }
- column "mat_$device_model" {
- type = "String"
- comment = "column_materializer::$device_model"
- }
- column "mat_progress" {
- type = "String"
- comment = "column_materializer::progress"
- }
- column "mat_chain" {
- type = "String"
- comment = "column_materializer::chain"
- }
- column "mat_$device_type" {
- type = "String"
- comment = "column_materializer::$device_type"
- }
- column "mat_usd" {
- type = "String"
- comment = "column_materializer::usd"
- }
- column "mat_app_name" {
- type = "String"
- comment = "column_materializer::app_name"
- }
- column "mat_$screen_name" {
- type = "String"
- comment = "column_materializer::$screen_name"
- }
- column "mat_index" {
- type = "String"
- comment = "column_materializer::index"
- }
- column "mat_token" {
- type = "String"
- comment = "column_materializer::token"
- }
- column "mat_method" {
- type = "String"
- comment = "column_materializer::method"
- }
- column "mat_address" {
- type = "String"
- comment = "column_materializer::address"
- }
- column "mat_name" {
- type = "String"
- comment = "column_materializer::name"
- }
- column "mat_inviteCode" {
- type = "String"
- comment = "column_materializer::inviteCode"
- }
- column "$window_id" {
- type = "String"
- comment = "column_materializer::$window_id"
- }
- column "$session_id" {
- type = "String"
- comment = "column_materializer::$session_id"
- }
- column "mat_osName" {
- type = "String"
- comment = "column_materializer::osName"
- }
- column "mat_nativeBuildVersion" {
- type = "String"
- comment = "column_materializer::nativeBuildVersion"
- }
- column "mat_revenue" {
- type = "String"
- comment = "column_materializer::revenue"
- }
- column "group_0" {
- type = "String"
- alias = "`$group_0`"
- }
- column "group_1" {
- type = "String"
- alias = "`$group_1`"
- }
- column "group_2" {
- type = "String"
- alias = "`$group_2`"
- }
- column "group_3" {
- type = "String"
- alias = "`$group_3`"
- }
- column "group_4" {
- type = "String"
- alias = "`$group_4`"
- }
- column "alias_mat__user_id" {
- type = "String"
- alias = "`mat_$user_id`"
- }
- column "alias_mat__browser" {
- type = "String"
- alias = "`mat_$browser`"
- }
- column "alias_mat__host" {
- type = "String"
- alias = "`mat_$host`"
- }
- column "alias_mat__current_url" {
- type = "String"
- alias = "`mat_$current_url`"
- }
- column "alias_mat__event_type" {
- type = "String"
- alias = "`mat_$event_type`"
- }
- column "alias_mat__active_feature_flags" {
- type = "String"
- alias = "`mat_$active_feature_flags`"
- }
- column "alias_mat__referring_domain" {
- type = "String"
- alias = "`mat_$referring_domain`"
- }
- column "alias_mat__lib" {
- type = "String"
- alias = "`mat_$lib`"
- }
- column "alias_mat__os" {
- type = "String"
- alias = "`mat_$os`"
- }
- column "alias_mat__initial_referrer" {
- type = "String"
- alias = "`mat_$initial_referrer`"
- }
- column "alias_mat__app_version" {
- type = "String"
- alias = "`mat_$app_version`"
- }
- column "alias_mat__initial_referring_domain" {
- type = "String"
- alias = "`mat_$initial_referring_domain`"
- }
- column "alias_mat__ip" {
- type = "String"
- alias = "`mat_$ip`"
- }
- column "alias_mat__referrer" {
- type = "String"
- alias = "`mat_$referrer`"
- }
- column "alias_mat__geoip_country_name" {
- type = "String"
- alias = "`mat_$geoip_country_name`"
- }
- column "alias_mat__device_model" {
- type = "String"
- alias = "`mat_$device_model`"
- }
- column "alias_mat__device_type" {
- type = "String"
- alias = "`mat_$device_type`"
- }
- column "alias_mat__screen_name" {
- type = "String"
- alias = "`mat_$screen_name`"
- }
- column "person_id" {
- type = "UUID"
- }
- 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 "person_created_at" {
- type = "DateTime64(3)"
- }
- column "group0_created_at" {
- type = "DateTime64(3)"
- }
- column "group1_created_at" {
- type = "DateTime64(3)"
- }
- column "group2_created_at" {
- type = "DateTime64(3)"
- }
- column "group3_created_at" {
- type = "DateTime64(3)"
- }
- column "group4_created_at" {
- type = "DateTime64(3)"
- }
- column "mat_arguments" {
- type = "String"
- comment = "column_materializer::properties::arguments"
- }
- column "mat_source" {
- type = "String"
- comment = "column_materializer::properties::source"
- }
- column "mat_pp_email" {
- type = "String"
- comment = "column_materializer::person_properties::email"
- }
- column "mat_$time" {
- type = "String"
- comment = "column_materializer::properties::$time"
- }
- column "mat_$pathname" {
- type = "String"
- comment = "column_materializer::properties::$pathname"
- }
- column "mat_$geoip_city_name" {
- type = "String"
- comment = "column_materializer::properties::$geoip_city_name"
- }
- column "mat_community_id" {
- type = "String"
- comment = "column_materializer::properties::community_id"
- }
- column "mat_thread_id" {
- type = "String"
- comment = "column_materializer::properties::thread_id"
- }
- column "mat_Event_productCode" {
- type = "String"
- comment = "column_materializer::properties::Event.productCode"
- }
- column "mat_env" {
- type = "String"
- comment = "column_materializer::properties::env"
- }
- column "mat_target" {
- type = "String"
- comment = "column_materializer::properties::target"
- }
- column "mat_Subscription_plan_amount" {
- type = "String"
- comment = "column_materializer::properties::Subscription.plan.amount"
- }
- column "mat_title" {
- type = "String"
- comment = "column_materializer::properties::title"
- }
- column "mat_Connection_app_name" {
- type = "String"
- comment = "column_materializer::properties::Connection.app.name"
- }
- column "mat_utm_medium" {
- type = "String"
- comment = "column_materializer::properties::utm_medium"
- }
- column "mat_Account_client_id" {
- type = "String"
- comment = "column_materializer::properties::Account.client_id"
- }
- column "mat_HTTP_Method" {
- type = "String"
- comment = "column_materializer::properties::HTTP Method"
- }
- column "mat_audio_duration" {
- type = "String"
- comment = "column_materializer::properties::audio_duration"
- }
- column "mat_duration" {
- type = "String"
- comment = "column_materializer::properties::duration"
- }
- column "mat_url" {
- type = "String"
- comment = "column_materializer::properties::url"
- }
- column "mat_group_id" {
- type = "String"
- comment = "column_materializer::properties::group_id"
- }
- column "mat_platform" {
- type = "String"
- comment = "column_materializer::properties::platform"
- }
- column "mat_pp_$browser" {
- type = "String"
- comment = "column_materializer::person_properties::$browser"
- }
- column "mat_payment_status" {
- type = "String"
- comment = "column_materializer::properties::payment_status"
- }
- column "mat_testSessionId" {
- type = "String"
- comment = "column_materializer::properties::testSessionId"
- }
- column "inserted_at" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- default = "now64()"
- }
- column "mat_$sent_at" {
- type = "String"
- comment = "column_materializer::properties::$sent_at"
- }
- column "mat_pp_companyName" {
- type = "String"
- comment = "column_materializer::person_properties::companyName"
- }
- column "mat_function" {
- type = "String"
- comment = "column_materializer::properties::function"
- }
- column "mat_store_url" {
- type = "String"
- comment = "column_materializer::properties::store_url"
- }
- column "mat_email_domain" {
- type = "String"
- comment = "column_materializer::properties::email_domain"
- }
- column "mat_institution_name" {
- type = "String"
- comment = "column_materializer::properties::institution_name"
- }
- column "mat_authentication_method" {
- type = "String"
- comment = "column_materializer::properties::authentication_method"
- }
- column "mat_initial_step" {
- type = "String"
- comment = "column_materializer::properties::initial_step"
- }
- column "mat_status_message" {
- type = "String"
- comment = "column_materializer::properties::status_message"
- }
- column "mat_mode" {
- type = "String"
- comment = "column_materializer::properties::mode"
- }
- column "mat_protocol" {
- type = "String"
- comment = "column_materializer::properties::protocol"
- }
- column "mat_job_type" {
- type = "String"
- comment = "column_materializer::properties::job_type"
- }
- column "mat_is_oauth" {
- type = "String"
- comment = "column_materializer::properties::is_oauth"
- }
- column "mat_is_initial_aggregation" {
- type = "String"
- comment = "column_materializer::properties::is_initial_aggregation"
- }
- column "mat_search_term" {
- type = "String"
- comment = "column_materializer::properties::search_term"
- }
- column "mat_valid_ach_accounts" {
- type = "String"
- comment = "column_materializer::properties::valid_ach_accounts"
- }
- column "mat_gross" {
- type = "String"
- comment = "column_materializer::properties::gross"
- }
- column "mat_orderType" {
- type = "String"
- comment = "column_materializer::properties::orderType"
- }
- column "mat_sku" {
- type = "String"
- comment = "column_materializer::properties::sku"
- }
- column "mat_dual_channel" {
- type = "String"
- comment = "column_materializer::properties::dual_channel"
- }
- column "mat_channel" {
- type = "String"
- comment = "column_materializer::properties::channel"
- }
- column "mat_workspaceId" {
- type = "String"
- comment = "column_materializer::properties::workspaceId"
- }
- column "mat_numberOfSecrets" {
- type = "String"
- comment = "column_materializer::properties::numberOfSecrets"
- }
- column "mat_organizations" {
- type = "String"
- comment = "column_materializer::properties::organizations"
- }
- column "mat_organization" {
- type = "String"
- comment = "column_materializer::properties::organization"
- }
- column "mat_contributionError" {
- type = "String"
- comment = "column_materializer::properties::contributionError"
- }
- column "mat_phone" {
- type = "String"
- comment = "column_materializer::properties::phone"
- }
- column "mat_$initial_pathname" {
- type = "String"
- comment = "column_materializer::properties::$initial_pathname"
- }
- column "mat_organization_name" {
- type = "String"
- comment = "column_materializer::properties::organization_name"
- }
- column "mat_category" {
- type = "String"
- comment = "column_materializer::properties::category"
- }
- column "mat_$lib_version" {
- type = "String"
- comment = "column_materializer::properties::$lib_version"
- }
- column "mat_pp_$initial_utm_campaign" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_campaign"
- }
- column "mat_pp_$initial_utm_medium" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_medium"
- }
- column "mat_pp_$initial_gclid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_gclid"
- }
- column "mat_pp_$initial_gad_source" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_gad_source"
- }
- column "mat_pp_$initial_utm_source" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_source"
- }
- column "mat_pp_$initial_referring_domain" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_referring_domain"
- }
- column "mat_pp_$initial_utm_term" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_term"
- }
- column "mat_pp_$initial_utm_content" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_content"
- }
- column "mat_pp_$initial_gbraid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_gbraid::disabled"
- }
- column "mat_pp_$initial_wbraid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_wbraid::disabled"
- }
- column "mat_pp_$initial_msclkid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_msclkid"
- }
- column "mat_pp_$initial_fbclid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_fbclid"
- }
- column "mat_$geoip_subdivision_1_code" {
- type = "String"
- comment = "column_materializer::properties::$geoip_subdivision_1_code"
- }
- column "mat_wlo_enabled" {
- type = "String"
- comment = "column_materializer::properties::wlo_enabled"
- }
- column "mat_$prev_pageview_max_scroll_percentage" {
- type = "String"
- comment = "column_materializer::properties::$prev_pageview_max_scroll_percentage"
- }
- column "mat_$prev_pageview_max_content_percentage" {
- type = "String"
- comment = "column_materializer::properties::$prev_pageview_max_content_percentage"
- }
- column "mat_$prev_pageview_pathname" {
- type = "String"
- comment = "column_materializer::properties::$prev_pageview_pathname"
- }
- column "mat_pp_$initial_pathname" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_pathname"
- }
- column "mat_pp_$geoip_country_code" {
- type = "String"
- comment = "column_materializer::person_properties::$geoip_country_code"
- }
- column "mat_pp_username" {
- type = "String"
- comment = "column_materializer::person_properties::username"
- }
- column "mat_pp_serverMasterclass" {
- type = "String"
- comment = "column_materializer::person_properties::serverMasterclass"
- }
- column "mat_content_length" {
- type = "String"
- comment = "column_materializer::properties::content_length"
- }
- column "mat_pp_serverMarketing" {
- type = "String"
- comment = "column_materializer::person_properties::serverMarketing"
- }
- column "mat_$browser_version" {
- type = "String"
- comment = "column_materializer::properties::$browser_version"
- }
- column "mat_pp_role" {
- type = "String"
- comment = "column_materializer::person_properties::role"
- }
- column "mat_pp_customer" {
- type = "String"
- comment = "column_materializer::person_properties::customer"
- }
- column "mat_event" {
- type = "String"
- comment = "column_materializer::properties::event"
- }
- column "mat_disable_institution_search" {
- type = "String"
- comment = "column_materializer::properties::disable_institution_search"
- }
- column "mat_is_first_event_for_user" {
- type = "String"
- comment = "column_materializer::properties::is_first_event_for_user"
- }
- column "mat_current_member_guid" {
- type = "String"
- comment = "column_materializer::properties::current_member_guid"
- }
- column "mat_user_agent" {
- type = "String"
- comment = "column_materializer::properties::user_agent"
- }
- column "mat_is_test_user" {
- type = "String"
- comment = "column_materializer::properties::is_test_user"
- }
- column "mat_referrer" {
- type = "String"
- comment = "column_materializer::properties::referrer"
- }
- column "mat_pp_$initial_current_url" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_current_url"
- }
- column "mat_most_recent_app_os" {
- type = "String"
- comment = "column_materializer::properties::most_recent_app_os"
- }
- column "mat_pp_hubspot_score" {
- type = "String"
- comment = "column_materializer::person_properties::hubspot_score"
- }
- column "mat_pp_id" {
- type = "String"
- comment = "column_materializer::person_properties::id"
- }
- column "mat_pp_$current_url" {
- type = "String"
- comment = "column_materializer::person_properties::$current_url"
- }
- column "mat_product_key" {
- type = "String"
- comment = "column_materializer::properties::product_key"
- }
- column "mat_Plan_type_and_filter" {
- type = "String"
- comment = "column_materializer::properties::Plan type and filter"
- }
- column "mat_$app_namespace" {
- type = "String"
- comment = "column_materializer::properties::$app_namespace"
- }
- column "mat_$os_name" {
- type = "String"
- comment = "column_materializer::properties::$os_name"
- }
- column "mat_pp_$os_name" {
- type = "String"
- comment = "column_materializer::person_properties::$os_name::disabled"
- }
- column "mat_pp_$app_version" {
- type = "String"
- comment = "column_materializer::person_properties::$app_version"
- }
- column "mat_subscriptionStatus" {
- type = "String"
- comment = "column_materializer::properties::subscriptionStatus"
- }
- column "mat_$screen_height" {
- type = "String"
- comment = "column_materializer::properties::$screen_height"
- }
- column "mat_$screen_width" {
- type = "String"
- comment = "column_materializer::properties::$screen_width"
- }
- column "mat_tag" {
- type = "String"
- comment = "column_materializer::properties::tag"
- }
- column "mat_$app_build" {
- type = "String"
- comment = "column_materializer::properties::$app_build"
- }
- column "mat_surface_tag" {
- type = "String"
- comment = "column_materializer::properties::surface_tag"
- }
- column "mat_survey_responses_count_in_period" {
- type = "String"
- comment = "column_materializer::properties::survey_responses_count_in_period"
- }
- column "mat_event_count_in_month" {
- type = "String"
- comment = "column_materializer::properties::event_count_in_month"
- }
- column "mat_ramp" {
- type = "String"
- comment = "column_materializer::properties::ramp"
- }
- column "mat_auto_chapters" {
- type = "String"
- comment = "column_materializer::properties::auto_chapters"
- }
- column "mat_sentiment_analysis" {
- type = "String"
- comment = "column_materializer::properties::sentiment_analysis"
- }
- column "mat_redact_pii" {
- type = "String"
- comment = "column_materializer::properties::redact_pii"
- }
- column "mat_content_safety" {
- type = "String"
- comment = "column_materializer::properties::content_safety"
- }
- column "mat_iab_categories" {
- type = "String"
- comment = "column_materializer::properties::iab_categories"
- }
- column "mat_auto_highlights" {
- type = "String"
- comment = "column_materializer::properties::auto_highlights"
- }
- column "mat_entity_detection" {
- type = "String"
- comment = "column_materializer::properties::entity_detection"
- }
- column "mat_summarization" {
- type = "String"
- comment = "column_materializer::properties::summarization"
- }
- column "mat_pp_val_region" {
- type = "String"
- comment = "column_materializer::person_properties::val_region"
- }
- column "mat_client_id" {
- type = "String"
- comment = "column_materializer::properties::client_id"
- }
- column "mat_$geoip_country_code" {
- type = "String"
- comment = "column_materializer::properties::$geoip_country_code"
- }
- column "mat_disfluencies" {
- type = "String"
- comment = "column_materializer::properties::disfluencies"
- }
- column "mat_filter_profanity" {
- type = "String"
- comment = "column_materializer::properties::filter_profanity"
- }
- column "mat_speaker_labels" {
- type = "String"
- comment = "column_materializer::properties::speaker_labels"
- }
- column "mat_language_detection" {
- type = "String"
- comment = "column_materializer::properties::language_detection"
- }
- column "mat_product_analytics_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::product_analytics_projected_amount"
- }
- column "mat_recordings_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::recordings_projected_amount"
- }
- column "mat_events_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::events_projected_amount"
- }
- column "mat_session_replay_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::session_replay_projected_amount"
- }
- column "mat_total_usd" {
- type = "String"
- comment = "column_materializer::properties::total_usd"
- }
- column "mat_stripe_amount_paid" {
- type = "String"
- comment = "column_materializer::properties::stripe_amount_paid"
- }
- column "mat_workspace" {
- type = "String"
- comment = "column_materializer::properties::workspace"
- }
- column "mat_created_at" {
- type = "String"
- comment = "column_materializer::properties::created_at"
- }
- column "mat_kind" {
- type = "String"
- comment = "column_materializer::properties::kind"
- }
- column "mat_product" {
- type = "String"
- comment = "column_materializer::properties::product"
- }
- column "mat_message" {
- type = "String"
- comment = "column_materializer::properties::message"
- }
- column "mat_initiator" {
- type = "String"
- comment = "column_materializer::properties::initiator"
- }
- column "mat_query" {
- type = "String"
- comment = "column_materializer::properties::query"
- }
- column "mat_$survey_id" {
- type = "String"
- comment = "column_materializer::properties::$survey_id"
- }
- column "mat_$survey_response_1" {
- type = "String"
- comment = "column_materializer::properties::$survey_response_1"
- }
- column "mat_ticketId" {
- type = "String"
- comment = "column_materializer::properties::ticketId"
- }
- column "mat_$survey_response" {
- type = "String"
- comment = "column_materializer::properties::$survey_response"
- }
- column "mat_conceptName" {
- type = "String"
- comment = "column_materializer::properties::conceptName"
- }
- column "mat_apiName" {
- type = "String"
- comment = "column_materializer::properties::apiName"
- }
- column "mat_workplace_billing_plan" {
- type = "String"
- comment = "column_materializer::properties::workplace_billing_plan"
- }
- column "mat_$el_text" {
- type = "String"
- comment = "column_materializer::properties::$el_text"
- }
- column "mat_recording_count_in_period" {
- type = "String"
- comment = "column_materializer::properties::recording_count_in_period"
- }
- column "mat_$os_version" {
- type = "String"
- comment = "column_materializer::properties::$os_version"
- }
- column "mat_orderId" {
- type = "String"
- comment = "column_materializer::properties::orderId"
- }
- column "mat_commit_sha" {
- type = "String"
- comment = "column_materializer::properties::commit_sha"
- }
- column "mat_$feature_flag_payloads" {
- type = "String"
- comment = "column_materializer::properties::$feature_flag_payloads"
- }
- column "mat_event_count_in_period" {
+ column "$group_0" {
type = "String"
- comment = "column_materializer::properties::event_count_in_period"
+ comment = "column_materializer::$group_0"
}
- column "mat_$groups" {
+ column "$group_1" {
type = "String"
- comment = "column_materializer::properties::$groups"
+ comment = "column_materializer::$group_1"
}
- column "mat_$feature_flag" {
+ column "$group_2" {
type = "String"
- comment = "column_materializer::properties::$feature_flag"
+ comment = "column_materializer::$group_2"
}
- column "mat_utm_content" {
+ column "$group_3" {
type = "String"
- comment = "column_materializer::properties::utm_content"
+ comment = "column_materializer::$group_3"
}
- column "mat_gclid" {
+ column "$group_4" {
type = "String"
- comment = "column_materializer::properties::gclid"
+ comment = "column_materializer::$group_4"
}
- column "mat_gad_source" {
+ column "$window_id" {
type = "String"
- comment = "column_materializer::properties::gad_source"
+ comment = "column_materializer::$window_id"
}
- column "mat_gbraid" {
+ column "$session_id" {
type = "String"
- comment = "column_materializer::properties::gbraid"
+ comment = "column_materializer::$session_id"
}
- column "mat_wbraid" {
- type = "String"
- comment = "column_materializer::properties::wbraid"
+ column "group_0" {
+ type = "String"
+ alias = "`$group_0`"
}
- column "mat_fbclid" {
- type = "String"
- comment = "column_materializer::properties::fbclid"
+ column "group_1" {
+ type = "String"
+ alias = "`$group_1`"
}
- column "mat_msclkid" {
- type = "String"
- comment = "column_materializer::properties::msclkid"
+ column "group_2" {
+ type = "String"
+ alias = "`$group_2`"
}
- column "mat_organization_id" {
- type = "String"
- comment = "column_materializer::properties::organization_id"
+ column "group_3" {
+ type = "String"
+ alias = "`$group_3`"
}
- column "mat_owner_type" {
- type = "String"
- comment = "column_materializer::properties::owner_type"
+ column "group_4" {
+ type = "String"
+ alias = "`$group_4`"
}
- column "mat_device_type" {
- type = "String"
- comment = "column_materializer::properties::device_type"
+ column "person_id" {
+ type = "UUID"
}
- column "mat_$device_id" {
- type = "String"
- comment = "column_materializer::properties::$device_id"
+ column "person_properties" {
+ type = "String"
}
- column "mat_pp_$geoip_continent_name" {
- type = "String"
- comment = "column_materializer::person_properties::$geoip_continent_name"
+ column "group0_properties" {
+ type = "String"
}
- column "mat_$feature_flag_response" {
- type = "String"
- comment = "column_materializer::properties::$feature_flag_response"
+ column "group1_properties" {
+ type = "String"
}
- column "mat_pp_utm_source" {
- type = "String"
- comment = "column_materializer::person_properties::utm_source"
+ column "group2_properties" {
+ type = "String"
}
- column "mat_pp_$referring_domain" {
- type = "String"
- comment = "column_materializer::person_properties::$referring_domain"
+ column "group3_properties" {
+ type = "String"
}
- column "mat_pp_Email_Domain" {
- type = "String"
- comment = "column_materializer::person_properties::Email Domain"
+ column "group4_properties" {
+ type = "String"
}
- column "mat_machine_id" {
- type = "String"
- comment = "column_materializer::properties::machine_id"
+ column "person_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_user_email_domain" {
- type = "String"
- comment = "column_materializer::properties::user_email_domain"
+ column "group0_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_$lib_version__minor" {
- type = "String"
- comment = "column_materializer::properties::$lib_version__minor"
+ column "group1_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_region" {
- type = "String"
- comment = "column_materializer::properties::region"
+ column "group2_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_pp_user_email_domain" {
- type = "String"
- comment = "column_materializer::person_properties::user_email_domain"
+ column "group3_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_url_promotion_id" {
- type = "String"
- comment = "column_materializer::properties::url_promotion_id"
+ column "group4_created_at" {
+ type = "DateTime64(3)"
}
- column "mat_$lib_custom_api_host" {
- type = "String"
- comment = "column_materializer::properties::$lib_custom_api_host"
+ column "inserted_at" {
+ type = "Nullable(DateTime64(6, 'UTC'))"
+ default = "now64()"
}
column "person_mode" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
- column "mat_user_platform" {
- type = "String"
- comment = "column_materializer::properties::user_platform"
- }
- column "mat_pp_$geoip_country_name" {
- type = "String"
- comment = "column_materializer::person_properties::$geoip_country_name"
- }
- column "mat_environment" {
- type = "String"
- comment = "column_materializer::properties::environment"
- }
- column "mat_customer_email" {
- type = "String"
- comment = "column_materializer::properties::customer_email"
- }
- column "mat_client_name" {
- type = "String"
- comment = "column_materializer::properties::client_name"
- }
- column "mat_screen_name" {
- type = "String"
- comment = "column_materializer::properties::screen_name"
- }
- column "mat_app_version" {
- type = "String"
- comment = "column_materializer::properties::app_version"
- }
column "elements_chain_href" {
type = "String"
comment = "column_materializer::elements_chain::href"
@@ -1243,62 +203,6 @@ database "posthog" {
column "is_deleted" {
type = "Bool"
}
- column "mat_subdomain" {
- type = "String"
- comment = "column_materializer::properties::subdomain"
- }
- column "mat_$device" {
- type = "String"
- comment = "column_materializer::properties::$device"
- }
- column "mat_id" {
- type = "String"
- comment = "column_materializer::properties::id"
- }
- column "mat_record_id" {
- type = "String"
- comment = "column_materializer::properties::record_id"
- }
- column "mat_referrer_id" {
- type = "String"
- comment = "column_materializer::properties::record_id"
- }
- column "mat_$exception_issue_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_issue_id"
- }
- column "mat_$exception_fingerprint" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_fingerprint"
- }
- column "mat_$web_vitals_LCP_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_LCP_value"
- }
- column "mat_$web_vitals_FCP_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_FCP_value"
- }
- column "mat_$web_vitals_CLS_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_CLS_value"
- }
- column "mat_$web_vitals_INP_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_INP_value"
- }
- column "mat_$viewport_width" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$viewport_width"
- }
- column "mat_$viewport_height" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$viewport_height"
- }
- column "mat_$anon_distinct_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$anon_distinct_id"
- }
column "person_properties_map_custom" {
type = "Map(String, String)"
}
@@ -1306,59 +210,15 @@ database "posthog" {
type = "Nullable(String)"
comment = "column_materializer::properties::$ai_trace_id"
}
- column "mat_$ai_model" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_model"
- }
- column "mat_$ai_provider" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_provider"
- }
- column "mat_$ai_parent_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_parent_id"
- }
- column "mat_$ai_span_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_span_id"
- }
- column "mat_$ai_http_status" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_http_status"
- }
- column "mat_$exception_types" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_types"
- }
- column "mat_$exception_values" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_values"
- }
- column "mat_$exception_sources" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_sources"
- }
- column "mat_$exception_functions" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_functions"
- }
column "$session_id_uuid" {
type = "Nullable(UInt128)"
}
- column "mat_$process_person_profile" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$process_person_profile"
- }
column "consumer_breadcrumbs" {
type = "Array(String)"
}
column "properties_group_ai" {
type = "Map(String, String)"
}
- column "mat_$is_identified" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$is_identified"
- }
column "mat_historical_migration" {
type = "Nullable(String)"
comment = "column_materializer::properties::historical_migration"
@@ -1401,103 +261,9 @@ database "posthog" {
column "dmat_string_9" {
type = "Nullable(String)"
}
- column "dmat_numeric_0" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_1" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_2" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_3" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_4" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_5" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_6" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_7" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_8" {
- type = "Nullable(Float64)"
- }
- column "dmat_numeric_9" {
- type = "Nullable(Float64)"
- }
- column "dmat_bool_0" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_1" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_2" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_3" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_4" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_5" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_6" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_7" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_8" {
- type = "Nullable(UInt8)"
- }
- column "dmat_bool_9" {
- type = "Nullable(UInt8)"
- }
- column "dmat_datetime_0" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_1" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_2" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_3" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_4" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_5" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_6" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_7" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_8" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
- column "dmat_datetime_9" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- }
column "historical_migration" {
type = "Bool"
}
- column "mat_$ai_total_cost_usd" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_total_cost_usd"
- }
column "properties_group_ai_large" {
type = "Map(String, String)"
}
@@ -2096,8 +862,14 @@ database "posthog" {
partition_by = "toYYYYMM(session_timestamp)"
settings = {
index_granularity = "8192"
+ max_replicated_merges_in_queue = "5"
+ parts_to_delay_insert = "1500"
+ parts_to_throw_insert = "2000"
+ prefer_fetch_merged_part_size_threshold = "1"
+ prefer_fetch_merged_part_time_threshold = "0"
replicated_deduplication_window = "0"
replicated_deduplication_window_for_async_inserts = "0"
+ storage_policy = "s3_tiered"
}
column "team_id" {
type = "Int64"
@@ -2714,10 +1486,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -2790,10 +1562,10 @@ SQL
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/manifest.hcl b/posthog/clickhouse/hcl/manifest.hcl
index 4f902dfd4e85..c3715ab7e8cd 100644
--- a/posthog/clickhouse/hcl/manifest.hcl
+++ b/posthog/clickhouse/hcl/manifest.hcl
@@ -15,10 +15,9 @@
# `shared` = all envs of that role and `prod` = both prod envs (e.g. the OPS metrics
# suite is prod-only but env-identical).
#
-# 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
+# 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
# 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.
#
@@ -27,6 +26,9 @@
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/cloud", "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/cloud", "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/cloud", "roles/ops/prod", "roles/ops/prod-eu"] }
}
# Every logs node composes the trace suite and the metrics ingest chain
@@ -34,10 +36,10 @@ role "ops" {
# self-contained roles/logs/local (extracted from the live node) for the legacy
# logs32 family it still runs.
role "logs" {
- env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/local"] }
- env "dev" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/shared", "roles/logs/dev"] }
- env "prod-us" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/shared", "roles/logs/prod", "roles/logs/prod-us"] }
- env "prod-eu" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/shared", "roles/logs/prod", "roles/logs/prod-eu"] }
+ env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/coshared/named_collections", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/local"] }
+ env "dev" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/shared", "roles/logs/dev"] }
+ env "prod-us" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/shared", "roles/logs/prod", "roles/logs/prod-us"] }
+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/shared", "roles/logs/prod", "roles/logs/prod-eu"] }
}
# AI_EVENTS satellite (LLM analytics). local/hobby run the MSK variant
@@ -49,10 +51,10 @@ role "logs" {
# same WarpStream pipeline as the prod envs; roles/ai_events/dev downsizes the
# Kafka consumer for dev volume.
role "ai_events" {
- env "local-multi" { layers = ["roles/shared", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/local"] }
- env "dev" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod", "roles/ai_events/dev"] }
- env "prod-us" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod"] }
- env "prod-eu" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod"] }
+ env "local-multi" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/local"] }
+ env "dev" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod", "roles/ai_events/dev"] }
+ env "prod-us" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod"] }
+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/prod"] }
}
# AUX satellite: auxiliary tables (error tracking, hog invocations, message assets,
@@ -62,24 +64,28 @@ role "ai_events" {
# hosts the ingestion_warnings store; prod-us adds the Distributed proxy onto the data
# cluster. prod goldens are dump-baselined (not live-verifiable here).
role "aux" {
- env "local-multi" { layers = ["roles/shared", "roles/coshared/aux_data", "roles/coshared/aux_small", "roles/auxiliary/shared", "roles/auxiliary/local"] }
- env "dev" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/dev"] }
- env "prod-us" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-us"] }
- env "prod-eu" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-eu"] }
+ env "local-multi" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/aux_data", "roles/coshared/aux_small", "roles/auxiliary/shared", "roles/auxiliary/local"] }
+ env "dev" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/dev"] }
+ env "prod-us" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-us"] }
+ env "prod-eu" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/coshared/aux_data", "roles/coshared/aux_small", "roles/coshared/ingestion_warnings_store", "roles/auxiliary/shared", "roles/auxiliary/prod", "roles/auxiliary/prod-eu"] }
}
# SESSIONS satellite: the local node runs only the shared query_log_archive path
-# (session tables are prod-only), so it composes roles/shared alone. prod nodes host
-# the session tables (sessions, raw_sessions, raw_sessions_v3), the events replica,
-# channel_definition + web_pre_aggregated_teams (+ their dictionaries), and person
-# join tables. roles/sessions/shared holds the env-uniform objects; prod-us/prod-eu
-# carry the env-specific channel_definition / events / raw_sessions_v3 (prod-us also
-# has writable_events_recent). prod goldens are dump-baselined (not live-verifiable here).
-# dev carries the channel_definition / web_pre_aggregated_teams objects + dictionaries,
-# but raw_sessions_v3 intentionally skips prod's tuning settings and the sessions-family
-# relocation is still converging — model a dev env block after it settles.
+# (session tables are prod-only), so it composes roles/shared alone. The cloud nodes
+# host the session tables (sessions, raw_sessions, raw_sessions_v3), the events
+# replica, channel_definition + web_pre_aggregated_teams (+ their dictionaries), and
+# person join tables. roles/sessions/shared holds the env-uniform objects; prod-us
+# tunes raw_sessions_v3 merges and prod-eu overrides channel_definition, which reads
+# from the data cluster there rather than storing it. dev runs roles/sessions/shared
+# unmodified. Cloud goldens are dump-baselined (not live-verifiable here).
+#
+# The events replica here carries several hundred materialized columns the
+# materialization engine adds at runtime. Those are not declared: they churn per env
+# and per customer, so posthog-cloud-infra layers them on top of these goldens. The
+# shape below is what migrations produce.
role "sessions" {
env "local-multi" { layers = ["roles/shared"] }
+ env "dev" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/coshared/sessions_data", "roles/sessions/shared"] }
env "prod-us" { layers = ["roles/shared", "roles/coshared/sessions_data", "roles/coshared/events_recent_write", "roles/sessions/shared", "roles/sessions/prod-us"] }
env "prod-eu" { layers = ["roles/shared", "roles/coshared/sessions_data", "roles/sessions/shared", "roles/sessions/prod-eu"] }
}
@@ -102,7 +108,7 @@ role "batch_exports" {
# columns per env that are added out-of-band and churn constantly, so their goldens
# live in PostHog/posthog-cloud-infra (clickhouse/hcl/), not the OSS gate.
role "data" {
- env "local-multi" { layers = ["roles/shared", "roles/coshared/aux_data", "roles/coshared/sessions_data", "roles/coshared/ai_events_data", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/coshared/events_json_write", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/data/shared", "roles/data/local"] }
+ env "local-multi" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/aux_data", "roles/coshared/sessions_data", "roles/coshared/ai_events_data", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/coshared/events_json_write", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/data/shared", "roles/data/local"] }
}
# INGESTION satellites: the Kafka consumer layer. Each node carries the kafka_* engine
@@ -111,15 +117,15 @@ role "data" {
# Beyond that they carry only the shared query_log_archive path. Role names are the
# hostClusterRole macros migrations target: events, small, medium.
role "events" {
- env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/coshared/events_json_write", "roles/ingestion_events/local"] }
+ env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/coshared/named_collections", "roles/coshared/events_json_write", "roles/ingestion_events/local"] }
}
role "small" {
- env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/coshared/aux_small", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/ingestion_small/local"] }
+ env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/coshared/named_collections", "roles/coshared/aux_small", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/ingestion_small/local"] }
}
role "medium" {
- env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/ingestion_medium/local"] }
+ env "local-multi" { layers = ["roles/shared/qla.hcl", "roles/coshared/named_collections", "roles/ingestion_medium/local"] }
}
# The plain dev/hobby stack (docker-compose.dev.yml): ONE ClickHouse server hosting every
@@ -127,7 +133,7 @@ role "medium" {
# and not MULTINODE_CLICKHOUSE. Composed as the deduped union of the local-multi stacks it
# hosts, so any name two of those roles declare fails this load instead of drifting.
role "all" {
- env "local-single" { layers = ["roles/shared", "roles/coshared/custom_metrics", "roles/ops/shared", "roles/ops/local", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/local", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/local", "roles/coshared/aux_data", "roles/coshared/aux_small", "roles/auxiliary/shared", "roles/auxiliary/local", "roles/coshared/sessions_data", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/coshared/events_json_write", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/data/shared", "roles/data/local", "roles/ingestion_events/local", "roles/ingestion_events/local-single", "roles/ingestion_small/local", "roles/ingestion_medium/local"] }
+ env "local-single" { layers = ["roles/shared", "roles/coshared/named_collections", "roles/coshared/custom_metrics", "roles/ops/shared", "roles/ops/local", "roles/logs/base", "roles/logs/traces", "roles/logs/traces_kafka_metrics", "roles/logs/metrics", "roles/logs/local", "roles/coshared/ai_events_data", "roles/ai_events/shared", "roles/ai_events/local", "roles/coshared/aux_data", "roles/coshared/aux_small", "roles/auxiliary/shared", "roles/auxiliary/local", "roles/coshared/sessions_data", "roles/coshared/tophog", "roles/coshared/events_recent", "roles/coshared/events_recent_write", "roles/coshared/batch_exports_data", "roles/coshared/ingestion_warnings_store", "roles/coshared/events_json_write", "roles/coshared/log_entries_write", "roles/coshared/session_replay_write", "roles/data/shared", "roles/data/local", "roles/ingestion_events/local", "roles/ingestion_events/local-single", "roles/ingestion_small/local", "roles/ingestion_medium/local"] }
}
# role "endpoints" {
diff --git a/posthog/clickhouse/hcl/roles/ai_events/dev/patches.hcl b/posthog/clickhouse/hcl/roles/ai_events/dev/patches.hcl
index b02fa94ecb73..94f083de87bc 100644
--- a/posthog/clickhouse/hcl/roles/ai_events/dev/patches.hcl
+++ b/posthog/clickhouse/hcl/roles/ai_events/dev/patches.hcl
@@ -3,10 +3,10 @@
database "posthog" {
patch_table "kafka_ai_events_json_ws" {
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ai_events_json'"
- group_name = "kafka_group_name = 'clickhouse_ai_events_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ai_events_json"
+ group_name = "clickhouse_ai_events_ws"
+ format = "JSONEachRow"
num_consumers = 1
max_block_size = 5000
skip_broken_messages = 100
diff --git a/posthog/clickhouse/hcl/roles/ai_events/local/tables.hcl b/posthog/clickhouse/hcl/roles/ai_events/local/tables.hcl
index b01881da5cfb..f209dfceae11 100644
--- a/posthog/clickhouse/hcl/roles/ai_events/local/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/ai_events/local/tables.hcl
@@ -37,10 +37,10 @@ database "posthog" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_ai_events_json'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_ai_events_json"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
table "sharded_ai_events" {
diff --git a/posthog/clickhouse/hcl/roles/ai_events/prod/tables.hcl b/posthog/clickhouse/hcl/roles/ai_events/prod/tables.hcl
index 342ab6d0a7b7..ceee6258d5b9 100644
--- a/posthog/clickhouse/hcl/roles/ai_events/prod/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/ai_events/prod/tables.hcl
@@ -37,10 +37,10 @@ database "posthog" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ai_events_json'"
- group_name = "kafka_group_name = 'clickhouse_ai_events_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ai_events_json"
+ group_name = "clickhouse_ai_events_ws"
+ format = "JSONEachRow"
num_consumers = 16
max_block_size = 5000
skip_broken_messages = 100
diff --git a/posthog/clickhouse/hcl/roles/auxiliary/dev/patches.hcl b/posthog/clickhouse/hcl/roles/auxiliary/dev/patches.hcl
index 7872dc5fd804..f5e20b3ef6b9 100644
--- a/posthog/clickhouse/hcl/roles/auxiliary/dev/patches.hcl
+++ b/posthog/clickhouse/hcl/roles/auxiliary/dev/patches.hcl
@@ -3,10 +3,10 @@
database "posthog" {
patch_table "kafka_property_values" {
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_property_values'"
- group_name = "kafka_group_name = 'clickhouse_property_values'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_property_values"
+ group_name = "clickhouse_property_values"
+ format = "JSONEachRow"
num_consumers = 1
thread_per_consumer = true
}
diff --git a/posthog/clickhouse/hcl/roles/auxiliary/local/tables.hcl b/posthog/clickhouse/hcl/roles/auxiliary/local/tables.hcl
index 94cdd057e81b..2e5944367cdb 100644
--- a/posthog/clickhouse/hcl/roles/auxiliary/local/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/auxiliary/local/tables.hcl
@@ -37,10 +37,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_error_tracking_fingerprint_issue_state'"
- group_name = "kafka_group_name = 'clickhouse-error-tracking-fingerprint-issue-state'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_error_tracking_fingerprint_issue_state"
+ group_name = "clickhouse-error-tracking-fingerprint-issue-state"
+ format = "JSONEachRow"
}
}
materialized_view "error_tracking_fingerprint_issue_state_mv" {
diff --git a/posthog/clickhouse/hcl/roles/auxiliary/prod-us/patches.hcl b/posthog/clickhouse/hcl/roles/auxiliary/prod-us/patches.hcl
index 1a443fb644bb..34f889dd637b 100644
--- a/posthog/clickhouse/hcl/roles/auxiliary/prod-us/patches.hcl
+++ b/posthog/clickhouse/hcl/roles/auxiliary/prod-us/patches.hcl
@@ -2,10 +2,10 @@
database "posthog" {
patch_table "kafka_hog_invocation_results" {
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
- group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_hog_invocation_results"
+ group_name = "clickhouse_hog_invocation_results"
+ format = "JSONEachRow"
num_consumers = 1
max_block_size = 100000
skip_broken_messages = 100
diff --git a/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl b/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl
index 10f11062a97d..4b642b4fca2b 100644
--- a/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/auxiliary/shared/tables.hcl
@@ -29,10 +29,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"
- group_name = "kafka_group_name = 'clickhouse_ingestion_warnings_v2'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_ingestion_warnings"
+ group_name = "clickhouse_ingestion_warnings_v2"
+ format = "JSONEachRow"
}
}
table "kafka_message_assets" {
@@ -85,10 +85,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_message_assets'"
- group_name = "kafka_group_name = 'clickhouse_message_assets'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_message_assets"
+ group_name = "clickhouse_message_assets"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -109,10 +109,10 @@ database "posthog" {
type = "UInt64"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_property_values'"
- group_name = "kafka_group_name = 'clickhouse_property_values'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_property_values"
+ group_name = "clickhouse_property_values"
+ format = "JSONEachRow"
num_consumers = 8
thread_per_consumer = true
}
@@ -1029,10 +1029,10 @@ database "posthog" {
type = "UInt8"
}
engine "kafka" {
- broker_list = "warpstream_cyclotron"
- topic_list = "kafka_topic_list = 'clickhouse_hog_invocation_results'"
- group_name = "kafka_group_name = 'clickhouse_hog_invocation_results'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_cyclotron"
+ topic_list = "clickhouse_hog_invocation_results"
+ group_name = "clickhouse_hog_invocation_results"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
diff --git a/posthog/clickhouse/hcl/roles/coshared/named_collections/collections.hcl b/posthog/clickhouse/hcl/roles/coshared/named_collections/collections.hcl
new file mode 100644
index 000000000000..11ddef412efc
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/coshared/named_collections/collections.hcl
@@ -0,0 +1,42 @@
+# The Kafka named collections ClickHouse server config defines (posthog-cloud-infra
+# ansible/roles/clickhouse/templates/config.d/named_collections.xml, mirrored for the
+# local stack in docker/clickhouse/config.d/). Every kafka_* table names one as its
+# engine's `collection`, and the resolver rejects a reference it cannot bind, so they
+# are declared here once. `external` says the definition — brokers, credentials —
+# lives in that server config and never in the schema.
+
+named_collection "msk_cluster" {
+ external = true
+}
+
+named_collection "warpstream_calculated_events" {
+ external = true
+}
+
+named_collection "warpstream_cyclotron" {
+ external = true
+}
+
+named_collection "warpstream_ingestion" {
+ external = true
+}
+
+named_collection "warpstream_logs" {
+ external = true
+}
+
+named_collection "warpstream_metrics" {
+ external = true
+}
+
+named_collection "warpstream_replay" {
+ external = true
+}
+
+named_collection "warpstream_shared" {
+ external = true
+}
+
+named_collection "warpstream_traces" {
+ external = true
+}
diff --git a/posthog/clickhouse/hcl/roles/data/local/tables.hcl b/posthog/clickhouse/hcl/roles/data/local/tables.hcl
index 1c5ba0162867..9bbd76968120 100644
--- a/posthog/clickhouse/hcl/roles/data/local/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/data/local/tables.hcl
@@ -1,103 +1,4 @@
database "posthog" {
- # Mirrors the events column set minus events' materialized property columns, with
- # the full properties JSON kept as the source of truth. The typed property columns
- # below carry their DEFAULT expression only on sharded_flag_evaluations; the
- # Distributed proxy repeats them plain, because a Distributed engine computes
- # nothing.
- table "_flag_evaluations_columns" {
- abstract = true
- column "uuid" {
- type = "UUID"
- }
- column "event" {
- type = "LowCardinality(String)"
- }
- column "properties" {
- type = "String"
- }
- column "timestamp" {
- type = "DateTime64(6, 'UTC')"
- }
- column "team_id" {
- type = "Int64"
- }
- column "distinct_id" {
- type = "String"
- }
- column "created_at" {
- type = "DateTime64(6, 'UTC')"
- }
- column "person_id" {
- type = "UUID"
- }
- 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 "inserted_at" {
- type = "DateTime64(6, 'UTC')"
- default = "timestamp"
- }
- column "$group_0" {
- type = "String"
- comment = "column_materializer::$group_0"
- }
- column "$group_1" {
- type = "String"
- comment = "column_materializer::$group_1"
- }
- column "$group_2" {
- type = "String"
- comment = "column_materializer::$group_2"
- }
- column "$group_3" {
- type = "String"
- comment = "column_materializer::$group_3"
- }
- column "$group_4" {
- type = "String"
- comment = "column_materializer::$group_4"
- }
- column "flag_key" {
- type = "String"
- comment = "column_materializer::properties::$feature_flag"
- }
- column "response" {
- type = "LowCardinality(String)"
- comment = "column_materializer::properties::$feature_flag_response"
- }
- column "session_id" {
- type = "String"
- comment = "column_materializer::properties::$session_id"
- }
- column "request_id" {
- type = "String"
- comment = "column_materializer::properties::$feature_flag_request_id"
- }
- column "_timestamp" {
- type = "DateTime"
- }
- column "_offset" {
- type = "UInt64"
- }
- column "_partition" {
- type = "UInt64"
- }
- }
table "adhoc_events_deletion" {
order_by = ["team_id", "uuid"]
ttl = "deleted_at + toIntervalMonth(3) WHERE is_deleted = 1"
@@ -1826,15 +1727,6 @@ database "posthog" {
sharding_key = "cityHash64(entity_id)"
}
}
- table "flag_evaluations" {
- extend = "_flag_evaluations_columns"
- engine "distributed" {
- cluster_name = "posthog"
- remote_database = "posthog"
- remote_table = "sharded_flag_evaluations"
- sharding_key = "sipHash64(distinct_id)"
- }
- }
table "groups" {
order_by = ["team_id", "group_type_index", "group_key"]
settings = {
@@ -2069,10 +1961,10 @@ database "posthog" {
type = "Nullable(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_events_json'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_events_json"
+ group_name = "group1"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -2219,10 +2111,10 @@ database "posthog" {
type = "Float64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_performance_events'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_performance_events"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
table "kafka_person_distinct_id" {
@@ -2242,10 +2134,10 @@ database "posthog" {
type = "Nullable(Int8)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person_unique_id'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person_unique_id"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
table "kafka_person_overrides" {
@@ -3585,72 +3477,6 @@ database "posthog" {
version_column = "computed_at"
}
}
- table "sharded_flag_evaluations" {
- order_by = ["team_id", "flag_key", "toDate(timestamp)", "cityHash64(distinct_id)"]
- partition_by = "toYYYYMM(timestamp)"
- ttl = "toDate(timestamp) + toIntervalDay(90)"
- settings = {
- index_granularity = "8192"
- ttl_only_drop_parts = "1"
- }
- extend = "_flag_evaluations_columns"
- patch_column "$group_0" {
- default = "replaceRegexpAll(JSONExtractRaw(properties, '$group_0'), '^\"|\"$', '')"
- }
- patch_column "$group_1" {
- default = "replaceRegexpAll(JSONExtractRaw(properties, '$group_1'), '^\"|\"$', '')"
- }
- patch_column "$group_2" {
- default = "replaceRegexpAll(JSONExtractRaw(properties, '$group_2'), '^\"|\"$', '')"
- }
- patch_column "$group_3" {
- default = "replaceRegexpAll(JSONExtractRaw(properties, '$group_3'), '^\"|\"$', '')"
- }
- patch_column "$group_4" {
- default = "replaceRegexpAll(JSONExtractRaw(properties, '$group_4'), '^\"|\"$', '')"
- }
- patch_column "flag_key" {
- default = "replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag'), '^\"|\"$', '')"
- }
- patch_column "response" {
- default = "replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag_response'), '^\"|\"$', '')"
- }
- patch_column "session_id" {
- default = "replaceRegexpAll(JSONExtractRaw(properties, '$session_id'), '^\"|\"$', '')"
- }
- patch_column "request_id" {
- default = "replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag_request_id'), '^\"|\"$', '')"
- }
- index "distinct_id_idx" {
- expr = "distinct_id"
- type = "bloom_filter(0.01)"
- granularity = 1
- }
- index "person_id_idx" {
- expr = "person_id"
- type = "bloom_filter(0.01)"
- granularity = 1
- }
- index "session_id_idx" {
- expr = "session_id"
- type = "bloom_filter(0.01)"
- granularity = 1
- }
- index "request_id_idx" {
- expr = "request_id"
- type = "bloom_filter(0.01)"
- granularity = 1
- }
- index "inserted_at_idx" {
- expr = "inserted_at"
- type = "minmax"
- granularity = 1
- }
- engine "replicated_merge_tree" {
- zoo_path = "/clickhouse/tables/{shard}/posthog.flag_evaluations"
- replica_name = "{replica}"
- }
- }
table "sharded_heatmaps" {
order_by = ["type", "team_id", "toDate(timestamp)", "current_url", "viewport_width"]
partition_by = "toYYYYMM(timestamp)"
diff --git a/posthog/clickhouse/hcl/roles/data/shared/flag_evaluations.hcl b/posthog/clickhouse/hcl/roles/data/shared/flag_evaluations.hcl
new file mode 100644
index 000000000000..97b76cfe58ba
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/data/shared/flag_evaluations.hcl
@@ -0,0 +1,181 @@
+# Feature flag evaluation events. Every data node runs these, cloud included, so
+# they sit in the shared layer rather than roles/data/local: a layer only the local
+# node composes cannot describe a table the cloud nodes also have.
+database "posthog" {
+ # Mirrors the events column set minus events' materialized property columns, with
+ # the full properties JSON kept as the source of truth. The typed property columns
+ # below carry their DEFAULT expression only on sharded_flag_evaluations; the
+ # Distributed proxy repeats them plain, because a Distributed engine computes
+ # nothing.
+ table "_flag_evaluations_columns" {
+ abstract = true
+ column "uuid" {
+ type = "UUID"
+ }
+ column "event" {
+ type = "LowCardinality(String)"
+ }
+ column "properties" {
+ type = "String"
+ }
+ column "timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "created_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ 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 "inserted_at" {
+ type = "DateTime64(6, 'UTC')"
+ default = "timestamp"
+ }
+ column "$group_0" {
+ type = "String"
+ comment = "column_materializer::$group_0"
+ }
+ column "$group_1" {
+ type = "String"
+ comment = "column_materializer::$group_1"
+ }
+ column "$group_2" {
+ type = "String"
+ comment = "column_materializer::$group_2"
+ }
+ column "$group_3" {
+ type = "String"
+ comment = "column_materializer::$group_3"
+ }
+ column "$group_4" {
+ type = "String"
+ comment = "column_materializer::$group_4"
+ }
+ column "flag_key" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag"
+ }
+ column "response" {
+ type = "LowCardinality(String)"
+ comment = "column_materializer::properties::$feature_flag_response"
+ }
+ column "session_id" {
+ type = "String"
+ comment = "column_materializer::properties::$session_id"
+ }
+ column "request_id" {
+ type = "String"
+ comment = "column_materializer::properties::$feature_flag_request_id"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "_partition" {
+ type = "UInt64"
+ }
+ }
+
+ table "flag_evaluations" {
+ extend = "_flag_evaluations_columns"
+ engine "distributed" {
+ cluster_name = "posthog"
+ remote_database = "posthog"
+ remote_table = "sharded_flag_evaluations"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+
+ table "sharded_flag_evaluations" {
+ order_by = ["team_id", "flag_key", "toDate(timestamp)", "cityHash64(distinct_id)"]
+ partition_by = "toYYYYMM(timestamp)"
+ ttl = "toDate(timestamp) + toIntervalDay(90)"
+ settings = {
+ index_granularity = "8192"
+ ttl_only_drop_parts = "1"
+ }
+ extend = "_flag_evaluations_columns"
+ patch_column "$group_0" {
+ default = "replaceRegexpAll(JSONExtractRaw(properties, '$group_0'), '^\"|\"$', '')"
+ }
+ patch_column "$group_1" {
+ default = "replaceRegexpAll(JSONExtractRaw(properties, '$group_1'), '^\"|\"$', '')"
+ }
+ patch_column "$group_2" {
+ default = "replaceRegexpAll(JSONExtractRaw(properties, '$group_2'), '^\"|\"$', '')"
+ }
+ patch_column "$group_3" {
+ default = "replaceRegexpAll(JSONExtractRaw(properties, '$group_3'), '^\"|\"$', '')"
+ }
+ patch_column "$group_4" {
+ default = "replaceRegexpAll(JSONExtractRaw(properties, '$group_4'), '^\"|\"$', '')"
+ }
+ patch_column "flag_key" {
+ default = "replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag'), '^\"|\"$', '')"
+ }
+ patch_column "response" {
+ default = "replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag_response'), '^\"|\"$', '')"
+ }
+ patch_column "session_id" {
+ default = "replaceRegexpAll(JSONExtractRaw(properties, '$session_id'), '^\"|\"$', '')"
+ }
+ patch_column "request_id" {
+ default = "replaceRegexpAll(JSONExtractRaw(properties, '$feature_flag_request_id'), '^\"|\"$', '')"
+ }
+ index "distinct_id_idx" {
+ expr = "distinct_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "person_id_idx" {
+ expr = "person_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "session_id_idx" {
+ expr = "session_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "request_id_idx" {
+ expr = "request_id"
+ type = "bloom_filter(0.01)"
+ granularity = 1
+ }
+ index "inserted_at_idx" {
+ expr = "inserted_at"
+ type = "minmax"
+ granularity = 1
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/tables/{shard}/posthog.flag_evaluations"
+ replica_name = "{replica}"
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hcl b/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hcl
index ad782a77062c..c7e1d69ffd87 100644
--- a/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/ingestion_events/local/tables.hcl
@@ -116,10 +116,10 @@ database "posthog" {
type = "Nullable(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_events_json'"
- group_name = "kafka_group_name = 'clickhouse_events_json_native_json'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_events_json"
+ group_name = "clickhouse_events_json_native_json"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -423,10 +423,10 @@ SQL
type = "Nullable(Int32)"
}
engine "kafka" {
- broker_list = "warpstream_logs"
- topic_list = "kafka_topic_list = 'clickhouse_logs'"
- group_name = "kafka_group_name = 'clickhouse-logs-avro-new'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_logs"
+ topic_list = "clickhouse_logs"
+ group_name = "clickhouse-logs-avro-new"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
diff --git a/posthog/clickhouse/hcl/roles/ingestion_medium/local/tables.hcl b/posthog/clickhouse/hcl/roles/ingestion_medium/local/tables.hcl
index d9f24bcd9eaa..545fb214d4b4 100644
--- a/posthog/clickhouse/hcl/roles/ingestion_medium/local/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/ingestion_medium/local/tables.hcl
@@ -34,10 +34,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_app_metrics2"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -67,10 +67,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_app_metrics2'"
- group_name = "kafka_group_name = 'clickhouse_app_metrics2_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_app_metrics2"
+ group_name = "clickhouse_app_metrics2_ws"
+ format = "JSONEachRow"
}
}
@@ -91,10 +91,10 @@ database "posthog" {
type = "DateTime64(6)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'cohort_membership_changed'"
- group_name = "kafka_group_name = 'clickhouse_cohort_membership_changed'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "cohort_membership_changed"
+ group_name = "clickhouse_cohort_membership_changed"
+ format = "JSONEachRow"
}
}
@@ -109,10 +109,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'distinct_id_usage_events_json'"
- group_name = "kafka_group_name = 'clickhouse_distinct_id_usage'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "distinct_id_usage_events_json"
+ group_name = "clickhouse_distinct_id_usage"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -164,10 +164,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_flag_evaluations'"
- group_name = "kafka_group_name = 'clickhouse_flag_evaluations'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_flag_evaluations"
+ group_name = "clickhouse_flag_evaluations"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -210,10 +210,10 @@ database "posthog" {
type = "LowCardinality(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_heatmap_events'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_heatmap_events"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -240,10 +240,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_prefiltered_events'"
- group_name = "kafka_group_name = 'clickhouse_prefiltered_events'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_prefiltered_events"
+ group_name = "clickhouse_prefiltered_events"
+ format = "JSONEachRow"
num_consumers = 1
max_block_size = 1000000
skip_broken_messages = 100
@@ -273,10 +273,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_precalculated_person_properties'"
- group_name = "kafka_group_name = 'clickhouse_precalculated_person_properties'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_precalculated_person_properties"
+ group_name = "clickhouse_precalculated_person_properties"
+ format = "JSONEachRow"
num_consumers = 1
max_block_size = 1000000
skip_broken_messages = 100
@@ -495,10 +495,10 @@ database "posthog" {
type = "UInt8"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_session_replay_features'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_session_replay_features"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -534,10 +534,10 @@ database "posthog" {
type = "Map(LowCardinality(String), String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_tophog'"
- group_name = "kafka_group_name = 'clickhouse_tophog'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_tophog"
+ group_name = "clickhouse_tophog"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -574,10 +574,10 @@ database "posthog" {
type = "Map(LowCardinality(String), String)"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_tophog'"
- group_name = "kafka_group_name = 'clickhouse_tophog_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_tophog"
+ group_name = "clickhouse_tophog_ws"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
diff --git a/posthog/clickhouse/hcl/roles/ingestion_small/local/tables.hcl b/posthog/clickhouse/hcl/roles/ingestion_small/local/tables.hcl
index 0367a207eb68..e8eea5383e5b 100644
--- a/posthog/clickhouse/hcl/roles/ingestion_small/local/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/ingestion_small/local/tables.hcl
@@ -44,10 +44,10 @@ database "posthog" {
codec = "ZSTD(3)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_app_metrics'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_app_metrics"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -101,10 +101,10 @@ database "posthog" {
type = "DateTime64(3, 'UTC')"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_events_duplicates'"
- group_name = "kafka_group_name = 'clickhouse_duplicate_events'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_ingestion_events_duplicates"
+ group_name = "clickhouse_duplicate_events"
+ format = "JSONEachRow"
}
}
@@ -128,10 +128,10 @@ database "posthog" {
type = "Array(Float64)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint_embeddings'"
- group_name = "kafka_group_name = 'clickhouse_error_tracking_fingerprint_embeddings'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_error_tracking_issue_fingerprint_embeddings"
+ group_name = "clickhouse_error_tracking_fingerprint_embeddings"
+ format = "JSONEachRow"
}
}
@@ -152,10 +152,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint'"
- group_name = "kafka_group_name = 'clickhouse-error-tracking-issue-fingerprint-overrides'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_error_tracking_issue_fingerprint"
+ group_name = "clickhouse-error-tracking-issue-fingerprint-overrides"
+ format = "JSONEachRow"
}
}
@@ -209,10 +209,10 @@ database "posthog" {
type = "Array(String)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'events_dead_letter_queue'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "events_dead_letter_queue"
+ group_name = "group1"
+ format = "JSONEachRow"
skip_broken_messages = 1000
}
}
@@ -234,10 +234,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_groups'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_groups"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -259,10 +259,10 @@ database "posthog" {
type = "DateTime64(6, 'UTC')"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_ingestion_warnings'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_ingestion_warnings"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -289,10 +289,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'log_entries'"
- group_name = "kafka_group_name = 'clickhouse_log_entries'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "log_entries"
+ group_name = "clickhouse_log_entries"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -320,10 +320,10 @@ database "posthog" {
type = "String"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'log_entries'"
- group_name = "kafka_group_name = 'clickhouse_log_entries_ws'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "log_entries"
+ group_name = "clickhouse_log_entries_ws"
+ format = "JSONEachRow"
skip_broken_messages = 100
}
}
@@ -354,10 +354,10 @@ database "posthog" {
type = "Nullable(DateTime64(3))"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -378,10 +378,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person_distinct_id"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -402,10 +402,10 @@ database "posthog" {
type = "Int64"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_person_distinct_id'"
- group_name = "kafka_group_name = 'clickhouse-person-distinct-id-overrides'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_person_distinct_id"
+ group_name = "clickhouse-person-distinct-id-overrides"
+ format = "JSONEachRow"
}
}
@@ -438,10 +438,10 @@ database "posthog" {
type = "UUID"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'plugin_log_entries'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "plugin_log_entries"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -480,10 +480,10 @@ database "posthog" {
type = "Array(Float64)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_document_embeddings'"
- group_name = "kafka_group_name = 'clickhouse_document_embeddings'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_document_embeddings"
+ group_name = "clickhouse_document_embeddings"
+ format = "JSONEachRow"
}
}
@@ -567,10 +567,10 @@ database "posthog" {
type = "Nullable(Float32)"
}
engine "kafka" {
- broker_list = "msk_cluster"
- topic_list = "kafka_topic_list = 'clickhouse_session_replay_events'"
- group_name = "kafka_group_name = 'group1'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "msk_cluster"
+ topic_list = "clickhouse_session_replay_events"
+ group_name = "group1"
+ format = "JSONEachRow"
}
}
@@ -598,10 +598,10 @@ database "posthog" {
type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
}
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_events_json'"
- group_name = "kafka_group_name = 'clickhouse_usage_report_events_preagg'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_events_json"
+ group_name = "clickhouse_usage_report_events_preagg"
+ format = "JSONEachRow"
num_consumers = 1
skip_broken_messages = 100
thread_per_consumer = true
@@ -2140,10 +2140,10 @@ SQL
column "timestamp" { type = "DateTime64(6, 'UTC')" }
column "inserted_at" { type = "DateTime64(6, 'UTC')" }
engine "kafka" {
- broker_list = "warpstream_ingestion"
- topic_list = "kafka_topic_list = 'clickhouse_billing_usage_records'"
- group_name = "kafka_group_name = 'clickhouse_billing_usage_records'"
- format = "kafka_format = 'JSONEachRow'"
+ collection = "warpstream_ingestion"
+ topic_list = "clickhouse_billing_usage_records"
+ group_name = "clickhouse_billing_usage_records"
+ format = "JSONEachRow"
}
}
diff --git a/posthog/clickhouse/hcl/roles/logs/dev/patches.hcl b/posthog/clickhouse/hcl/roles/logs/dev/patches.hcl
index 6a4620fe433d..bc5de0715382 100644
--- a/posthog/clickhouse/hcl/roles/logs/dev/patches.hcl
+++ b/posthog/clickhouse/hcl/roles/logs/dev/patches.hcl
@@ -14,19 +14,20 @@ database "posthog" {
}
}
- # dev batches metrics ingest harder than the prods do.
+ # dev runs the metrics consumer small: a fraction of prod volume arrives here,
+ # so it waits longer for smaller batches on fewer threads.
patch_table "kafka_metrics_avro" {
engine "kafka" {
- broker_list = "warpstream_metrics"
- topic_list = "kafka_topic_list = 'clickhouse_metrics'"
- group_name = "kafka_group_name = 'clickhouse-metrics-avro-new'"
- format = "kafka_format = 'Avro'"
- num_consumers = 8
- max_block_size = 65536
+ collection = "warpstream_metrics"
+ topic_list = "clickhouse_metrics"
+ group_name = "clickhouse-metrics-avro-new"
+ format = "Avro"
+ num_consumers = 2
+ max_block_size = 4096
skip_broken_messages = 100
- poll_timeout_ms = 3000
- poll_max_batch_size = 65536
- flush_interval_ms = 7500
+ poll_timeout_ms = 10000
+ poll_max_batch_size = 4096
+ flush_interval_ms = 10000
thread_per_consumer = true
}
}
diff --git a/posthog/clickhouse/hcl/roles/logs/metrics/tables.hcl b/posthog/clickhouse/hcl/roles/logs/metrics/tables.hcl
index 091b1bc65807..8aa1e5cbef00 100644
--- a/posthog/clickhouse/hcl/roles/logs/metrics/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/logs/metrics/tables.hcl
@@ -68,10 +68,10 @@ database "posthog" {
type = "Nullable(Int64)"
}
engine "kafka" {
- broker_list = "warpstream_metrics"
- topic_list = "kafka_topic_list = 'clickhouse_metrics'"
- group_name = "kafka_group_name = 'clickhouse-metrics-avro-new'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_metrics"
+ topic_list = "clickhouse_metrics"
+ group_name = "clickhouse-metrics-avro-new"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
diff --git a/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hcl b/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hcl
index 8b2a24ca7101..c310cf0cedb8 100644
--- a/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hcl
+++ b/posthog/clickhouse/hcl/roles/logs/prod-eu/patches.hcl
@@ -14,10 +14,10 @@ database "posthog" {
}
patch_table "kafka_trace_spans_avro" {
engine "kafka" {
- broker_list = "warpstream_traces"
- topic_list = "kafka_topic_list = 'clickhouse_traces'"
- group_name = "kafka_group_name = 'clickhouse-traces-avro'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_traces"
+ topic_list = "clickhouse_traces"
+ group_name = "clickhouse-traces-avro"
+ format = "Avro"
num_consumers = 2
skip_broken_messages = 100
poll_timeout_ms = 3000
diff --git a/posthog/clickhouse/hcl/roles/logs/traces/tables.hcl b/posthog/clickhouse/hcl/roles/logs/traces/tables.hcl
index bdbd78b27925..d49bcd0919c8 100644
--- a/posthog/clickhouse/hcl/roles/logs/traces/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/logs/traces/tables.hcl
@@ -226,10 +226,10 @@ database "posthog" {
type = "Int32"
}
engine "kafka" {
- broker_list = "warpstream_traces"
- topic_list = "kafka_topic_list = 'clickhouse_traces'"
- group_name = "kafka_group_name = 'clickhouse-traces-avro'"
- format = "kafka_format = 'Avro'"
+ collection = "warpstream_traces"
+ topic_list = "clickhouse_traces"
+ group_name = "clickhouse-traces-avro"
+ format = "Avro"
num_consumers = 8
skip_broken_messages = 100
poll_timeout_ms = 3000
diff --git a/posthog/clickhouse/hcl/roles/ops/cloud/metrics.hcl b/posthog/clickhouse/hcl/roles/ops/cloud/metrics.hcl
new file mode 100644
index 000000000000..c92f992fe909
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/ops/cloud/metrics.hcl
@@ -0,0 +1,276 @@
+# OPS role, cloud envs — the Prometheus-style metrics suite and the
+# event-property daily rollup. dev, prod-us and prod-eu run it identically.
+
+database "posthog" {
+ table "event_property_daily_stats" {
+ order_by = ["analysis_date", "team_id", "property_key"]
+ ttl = "analysis_date + toIntervalDay(30)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "analysis_date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "property_key" {
+ type = "String"
+ }
+ column "event_count" {
+ type = "UInt64"
+ }
+ column "distinct_event_names" {
+ type = "UInt32"
+ }
+ column "total_property_bytes" {
+ type = "UInt64"
+ }
+ column "min_property_bytes" {
+ type = "UInt64"
+ }
+ column "max_property_bytes" {
+ type = "UInt64"
+ }
+ column "avg_property_bytes" {
+ type = "Float64"
+ }
+ column "p50_property_bytes" {
+ type = "Float64"
+ }
+ column "p90_property_bytes" {
+ type = "Float64"
+ }
+ column "p95_property_bytes" {
+ type = "Float64"
+ }
+ column "p99_property_bytes" {
+ type = "Float64"
+ }
+ column "property_size_histogram" {
+ type = "Array(Tuple(Float64, Float64, UInt64))"
+ }
+ column "top_event_names" {
+ type = "Array(String)"
+ }
+ column "sample_rate" {
+ type = "Float32"
+ }
+ column "computed_at" {
+ type = "DateTime"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.event_property_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"
+ }
+ projection "by_label_value" {
+ query = <<SQL
+SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, label_name, label_value, id, metric_name
+SQL
+
+ }
+ projection "by_id_label" {
+ query = <<SQL
+SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, id, label_name, metric_name, label_value
+SQL
+
+ }
+ 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", "toStartOfTenMinutes(timestamp)", "id", "timestamp"]
+ partition_by = "toYYYYMMDD(timestamp)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "team_id" {
+ type = "UInt64"
+ codec = "T64, Default"
+ }
+ column "metric_name" {
+ type = "LowCardinality(String)"
+ }
+ column "timestamp" {
+ type = "DateTime64(3, 'UTC')"
+ codec = "DoubleDelta, Default"
+ }
+ column "id" {
+ type = "UInt64"
+ }
+ column "value" {
+ type = "Float64"
+ codec = "Gorilla(8), Default"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.metrics_samples_new"
+ 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')"
+ }
+ projection "by_id" {
+ query = <<SQL
+SELECT team_id, id, metric_name, labels_json, min_time, max_time
+ORDER BY team_id, id
+SQL
+
+ }
+ 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/cloud/sql/metrics_label_index_from_series_mv.sql b/posthog/clickhouse/hcl/roles/ops/cloud/sql/metrics_label_index_from_series_mv.sql
new file mode 100644
index 000000000000..3f54275a8019
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/ops/cloud/sql/metrics_label_index_from_series_mv.sql
@@ -0,0 +1,8 @@
+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
diff --git a/posthog/clickhouse/hcl/roles/ops/dev/ops.hcl b/posthog/clickhouse/hcl/roles/ops/dev/ops.hcl
new file mode 100644
index 000000000000..34766296bd46
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/ops/dev/ops.hcl
@@ -0,0 +1,256 @@
+# 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/dev/patches.hcl b/posthog/clickhouse/hcl/roles/ops/dev/patches.hcl
new file mode 100644
index 000000000000..9da6f996b0b6
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/ops/dev/patches.hcl
@@ -0,0 +1,19 @@
+# dev deltas to base objects. dev tracks prod-us on all three: it is where the
+# prod-us experiments are tried first.
+database "posthog" {
+ 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)"
+ }
+ settings = {
+ storage_policy = "s3_tiered"
+ }
+ }
+
+ 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-eu/ops.hcl b/posthog/clickhouse/hcl/roles/ops/prod-eu/ops.hcl
new file mode 100644
index 000000000000..602092f25475
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/ops/prod-eu/ops.hcl
@@ -0,0 +1,10 @@
+# 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.hcl
new file mode 100644
index 000000000000..14475b3b75b0
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/ops/prod-eu/patches.hcl
@@ -0,0 +1,21 @@
+# prod-eu deltas to base objects.
+database "posthog" {
+ # No tiered storage here, unlike dev and prod-us; the archive is kept in check
+ # with merge and insert throttling instead.
+ patch_table "sharded_query_log_archive" {
+ settings = {
+ max_replicated_merges_in_queue = "6"
+ parts_to_delay_insert = "1000"
+ parts_to_throw_insert = "3000"
+ prefer_fetch_merged_part_size_threshold = "1"
+ prefer_fetch_merged_part_time_threshold = "60"
+ }
+ }
+
+ 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.hcl
new file mode 100644
index 000000000000..b75bb8d87f79
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/ops/prod-us/ops.hcl
@@ -0,0 +1,18 @@
+# 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" {
+ # An extra ProfileEvents2 JSON column on the base sharded_query_log_archive
+ # table, running on dev and prod-us. Additive patch so the shared base stays
+ # region-agnostic; fold it in once it reaches prod-eu, drop it if it ends.
+ 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)"
+ }
+ settings = {
+ storage_policy = "s3_tiered"
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/ops/prod-us/patches.hcl b/posthog/clickhouse/hcl/roles/ops/prod-us/patches.hcl
new file mode 100644
index 000000000000..323fc4a73edd
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/ops/prod-us/patches.hcl
@@ -0,0 +1,15 @@
+# prod-us deltas to base objects.
+database "posthog" {
+ # prod-eu dropped the partition when the table was rebuilt there; prod-us has
+ # not been rebuilt yet.
+ patch_table "query_team_daily_stats" {
+ partition_by = "analysis_date"
+ }
+
+ 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.hcl
new file mode 100644
index 000000000000..1751a120aebf
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/ops/prod/events.hcl
@@ -0,0 +1,86 @@
+# The events_main reader, identical on both prod OPS envs.
+database "posthog" {
+ table "events_main" {
+ column "uuid" {
+ type = "UUID"
+ }
+ column "event" {
+ type = "String"
+ }
+ column "properties" {
+ type = "String"
+ }
+ column "timestamp" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "distinct_id" {
+ type = "String"
+ }
+ column "elements_chain" {
+ type = "String"
+ }
+ column "created_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ column "person_id" {
+ type = "UUID"
+ }
+ column "person_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "person_properties" {
+ type = "String"
+ }
+ column "group0_properties" {
+ type = "String"
+ }
+ column "group1_properties" {
+ type = "String"
+ }
+ column "group2_properties" {
+ type = "String"
+ }
+ column "group3_properties" {
+ type = "String"
+ }
+ column "group4_properties" {
+ type = "String"
+ }
+ column "group0_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group1_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group2_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group3_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "group4_created_at" {
+ type = "DateTime64(3)"
+ }
+ column "person_mode" {
+ type = "Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)"
+ }
+ column "_timestamp" {
+ type = "DateTime"
+ }
+ column "_offset" {
+ type = "UInt64"
+ }
+ column "inserted_at" {
+ type = "DateTime64(6, 'UTC')"
+ }
+ engine "distributed" {
+ cluster_name = "posthog"
+ remote_database = "posthog"
+ remote_table = "sharded_events"
+ sharding_key = "sipHash64(distinct_id)"
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/ops/prod/stats.hcl b/posthog/clickhouse/hcl/roles/ops/prod/stats.hcl
new file mode 100644
index 000000000000..10e6d7a5ee6e
--- /dev/null
+++ b/posthog/clickhouse/hcl/roles/ops/prod/stats.hcl
@@ -0,0 +1,96 @@
+# Ops analytics rollups, prod only. dev does not run the job that fills them.
+database "posthog" {
+ table "query_team_daily_stats" {
+ order_by = ["analysis_date", "team_id"]
+ ttl = "analysis_date + toIntervalDay(90)"
+ settings = {
+ index_granularity = "8192"
+ }
+ column "analysis_date" {
+ type = "Date"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "query_count" {
+ type = "UInt64"
+ }
+ column "error_count" {
+ type = "UInt64"
+ }
+ column "distinct_query_shapes" {
+ type = "UInt64"
+ }
+ column "total_duration_ms" {
+ type = "UInt64"
+ }
+ column "avg_duration_ms" {
+ type = "Float64"
+ }
+ column "p50_duration_ms" {
+ type = "Float64"
+ }
+ column "p90_duration_ms" {
+ type = "Float64"
+ }
+ column "p99_duration_ms" {
+ type = "Float64"
+ }
+ column "max_duration_ms" {
+ type = "UInt64"
+ }
+ column "total_read_rows" {
+ type = "UInt64"
+ }
+ column "total_read_bytes" {
+ type = "UInt64"
+ comment = "Uncompressed bytes scanned, coordinator-side summed across shards (is_initial_query=1). Compute/scan cost proxy, NOT stored footprint."
+ }
+ column "total_result_rows" {
+ type = "UInt64"
+ }
+ column "total_result_bytes" {
+ type = "UInt64"
+ }
+ column "total_written_rows" {
+ type = "UInt64"
+ }
+ column "total_written_bytes" {
+ type = "UInt64"
+ }
+ column "total_cpu_seconds" {
+ type = "Float64"
+ comment = "ProfileEvents OSCPUVirtualTimeMicroseconds summed across ALL QueryFinish rows (initiator + shard leaves) / 1e6. CPU is not folded onto the initiator row, so leaves must be summed."
+ }
+ column "total_memory_usage" {
+ type = "UInt64"
+ comment = "Peak memory_usage summed across all shard rows (per-node peak; not folded onto the initiator)."
+ }
+ column "max_memory_usage" {
+ type = "UInt64"
+ comment = "Largest single-node peak memory across all shard rows."
+ }
+ column "p99_memory_usage" {
+ type = "Float64"
+ }
+ column "total_s3_get_objects" {
+ type = "UInt64"
+ comment = "ProfileEvents S3GetObject summed across all shard rows: object-storage GET count."
+ }
+ column "total_s3_read_bytes" {
+ type = "UInt64"
+ comment = "ProfileEvents ReadBufferFromS3Bytes summed across all shard rows: object-storage read cost proxy."
+ }
+ column "query_kind_counts" {
+ type = "Map(String, UInt64)"
+ comment = "query_kind -> count for QueryFinish rows."
+ }
+ column "computed_at" {
+ type = "DateTime"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/ops/tables/{shard}/posthog.query_team_daily_stats"
+ replica_name = "{replica}"
+ }
+ }
+}
diff --git a/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hcl b/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hcl
index 792108a48f16..99ab55ffd13b 100644
--- a/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/sessions/prod-eu/tables.hcl
@@ -1,5 +1,6 @@
database "posthog" {
table "channel_definition" {
+ override = true
column "domain" {
type = "String"
}
@@ -28,209 +29,5 @@ database "posthog" {
comment = "column_materializer::properties::$ai_experiment_id"
after = "mat_$ai_prompt_name"
}
- column "mat_$survey_submission_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$survey_submission_id"
- after = "mat_$ai_experiment_id"
- }
- column "mat_$geoip_subdivision_1_name" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$geoip_subdivision_1_name"
- after = "mat_$survey_submission_id"
- }
- column "mat_$raw_user_agent" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$raw_user_agent"
- after = "mat_$geoip_subdivision_1_name"
- }
- column "mat_$prev_pageview_duration" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$prev_pageview_duration"
- after = "mat_$raw_user_agent"
- }
- column "mat_pp_$initial_host" {
- type = "Nullable(String)"
- comment = "column_materializer::person_properties::$initial_host"
- after = "mat_$prev_pageview_duration"
- }
- column "mat_pp_$initial_url" {
- type = "Nullable(String)"
- comment = "column_materializer::person_properties::$initial_url"
- after = "mat_pp_$initial_host"
- }
- column "mat_pp_$initial_geoip_country_name" {
- type = "Nullable(String)"
- comment = "column_materializer::person_properties::$initial_geoip_country_name"
- after = "mat_pp_$initial_url"
- }
- }
- table "raw_sessions_v3" {
- order_by = ["team_id", "session_timestamp", "session_id_v7"]
- partition_by = "toYYYYMM(session_timestamp)"
- settings = {
- index_granularity = "8192"
- }
- column "team_id" {
- type = "Int64"
- }
- column "session_id_v7" {
- type = "UInt128"
- }
- column "session_timestamp" {
- type = "DateTime64(3)"
- default = "fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80)))"
- }
- column "distinct_id" {
- type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"
- }
- column "distinct_ids" {
- type = "AggregateFunction(groupUniqArray, String)"
- }
- column "min_timestamp" {
- type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"
- }
- column "max_timestamp" {
- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
- }
- column "max_inserted_at" {
- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
- }
- column "urls" {
- type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"
- }
- column "entry_url" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "end_url" {
- type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "last_external_click_url" {
- type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "browser" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "browser_version" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "os" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "os_version" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "device_type" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "viewport_width" {
- type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"
- }
- column "viewport_height" {
- type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"
- }
- column "geoip_country_code" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "geoip_subdivision_1_code" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "geoip_subdivision_1_name" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "geoip_subdivision_city_name" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "geoip_time_zone" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_referring_domain" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_utm_source" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_utm_campaign" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_utm_medium" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_utm_term" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_utm_content" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_gclid" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_gad_source" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_fbclid" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_has_gclid" {
- type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"
- }
- column "entry_has_fbclid" {
- type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"
- }
- column "entry_ad_ids_map" {
- type = "AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC'))"
- }
- column "entry_ad_ids_set" {
- type = "AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC'))"
- }
- column "entry_channel_type_properties" {
- type = "AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC'))"
- }
- column "pageview_uniq" {
- type = "AggregateFunction(uniqExact, Nullable(UUID))"
- }
- column "autocapture_uniq" {
- type = "AggregateFunction(uniqExact, Nullable(UUID))"
- }
- column "screen_uniq" {
- type = "AggregateFunction(uniqExact, Nullable(UUID))"
- }
- column "page_screen_uniq_up_to" {
- type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"
- }
- column "has_autocapture" {
- type = "SimpleAggregateFunction(max, Bool)"
- }
- column "flag_values" {
- type = "AggregateFunction(groupUniqArrayMap, Map(String, String))"
- }
- column "flag_keys" {
- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"
- }
- column "event_names" {
- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"
- }
- column "hosts" {
- type = "SimpleAggregateFunction(groupUniqArrayArray(100), Array(String))"
- }
- column "emails" {
- type = "SimpleAggregateFunction(groupUniqArrayArray(10), Array(String))"
- }
- column "has_replay_events" {
- type = "SimpleAggregateFunction(max, Bool)"
- }
- index "event_names_bloom_filter" {
- expr = "event_names"
- type = "bloom_filter()"
- granularity = 1
- }
- index "flag_keys_bloom_filter" {
- expr = "flag_keys"
- type = "bloom_filter()"
- granularity = 1
- }
- engine "replicated_aggregating_merge_tree" {
- zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3"
- replica_name = "{shard}-{replica}"
- }
}
}
diff --git a/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hcl b/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hcl
index 42be3931ffcc..9bab46fbacae 100644
--- a/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/sessions/prod-us/tables.hcl
@@ -1,199 +1,16 @@
+# prod-us sessions deltas.
database "posthog" {
- table "channel_definition" {
- order_by = ["domain", "kind"]
+ # prod-us runs this table hot: it throttles inserts and merges, and turns off
+ # replicated deduplication.
+ patch_table "raw_sessions_v3" {
settings = {
- default_compression_codec = "lz4"
- index_granularity = "8192"
- }
- column "domain" {
- type = "String"
- }
- column "kind" {
- type = "String"
- }
- column "domain_type" {
- type = "Nullable(String)"
- }
- column "type_if_paid" {
- type = "Nullable(String)"
- }
- column "type_if_organic" {
- type = "Nullable(String)"
- }
- engine "replicated_merge_tree" {
- zoo_path = "/clickhouse/tables/sessions/noshard/posthog.channel_definition"
- replica_name = "{replica}-{shard}"
- }
- }
- table "raw_sessions_v3" {
- order_by = ["team_id", "session_timestamp", "session_id_v7"]
- partition_by = "toYYYYMM(session_timestamp)"
- settings = {
- index_granularity = "8192"
+ max_replicated_merges_in_queue = "5"
+ parts_to_delay_insert = "1500"
+ parts_to_throw_insert = "2000"
+ prefer_fetch_merged_part_size_threshold = "1"
+ prefer_fetch_merged_part_time_threshold = "0"
replicated_deduplication_window = "0"
replicated_deduplication_window_for_async_inserts = "0"
}
- column "team_id" {
- type = "Int64"
- }
- column "session_id_v7" {
- type = "UInt128"
- }
- column "session_timestamp" {
- type = "DateTime64(3)"
- default = "fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80)))"
- }
- column "distinct_id" {
- type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"
- }
- column "distinct_ids" {
- type = "AggregateFunction(groupUniqArray, String)"
- }
- column "min_timestamp" {
- type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"
- }
- column "max_timestamp" {
- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
- }
- column "max_inserted_at" {
- type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
- }
- column "urls" {
- type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"
- }
- column "entry_url" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "end_url" {
- type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "last_external_click_url" {
- type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "browser" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "browser_version" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "os" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "os_version" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "device_type" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "viewport_width" {
- type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"
- }
- column "viewport_height" {
- type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"
- }
- column "geoip_country_code" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "geoip_subdivision_1_code" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "geoip_subdivision_1_name" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "geoip_subdivision_city_name" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "geoip_time_zone" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_referring_domain" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_utm_source" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_utm_campaign" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_utm_medium" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_utm_term" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_utm_content" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_gclid" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_gad_source" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_fbclid" {
- type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
- }
- column "entry_has_gclid" {
- type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"
- }
- column "entry_has_fbclid" {
- type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"
- }
- column "entry_ad_ids_map" {
- type = "AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC'))"
- }
- column "entry_ad_ids_set" {
- type = "AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC'))"
- }
- column "entry_channel_type_properties" {
- type = "AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC'))"
- }
- column "pageview_uniq" {
- type = "AggregateFunction(uniqExact, Nullable(UUID))"
- }
- column "autocapture_uniq" {
- type = "AggregateFunction(uniqExact, Nullable(UUID))"
- }
- column "screen_uniq" {
- type = "AggregateFunction(uniqExact, Nullable(UUID))"
- }
- column "page_screen_uniq_up_to" {
- type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"
- }
- column "has_autocapture" {
- type = "SimpleAggregateFunction(max, Bool)"
- }
- column "flag_values" {
- type = "AggregateFunction(groupUniqArrayMap, Map(String, String))"
- }
- column "flag_keys" {
- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"
- }
- column "event_names" {
- type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"
- }
- column "hosts" {
- type = "SimpleAggregateFunction(groupUniqArrayArray(100), Array(String))"
- }
- column "emails" {
- type = "SimpleAggregateFunction(groupUniqArrayArray(10), Array(String))"
- }
- column "has_replay_events" {
- type = "SimpleAggregateFunction(max, Bool)"
- }
- index "event_names_bloom_filter" {
- expr = "event_names"
- type = "bloom_filter()"
- granularity = 1
- }
- index "flag_keys_bloom_filter" {
- expr = "flag_keys"
- type = "bloom_filter()"
- granularity = 1
- }
- engine "replicated_aggregating_merge_tree" {
- zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3"
- replica_name = "{shard}-{replica}"
- }
}
}
diff --git a/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl b/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl
index a6dc083961fb..f009bbe506b3 100644
--- a/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl
+++ b/posthog/clickhouse/hcl/roles/sessions/shared/tables.hcl
@@ -273,6 +273,208 @@ database "posthog" {
# The sessions nodes read events through the same Distributed proxy the data
# node carries, so the column core is the shared abstract.
+ # The v3 session store, on every sessions node. prod-us tunes merges and
+ # deduplication on top; dev and prod-eu run it as declared here.
+ table "raw_sessions_v3" {
+ order_by = ["team_id", "session_timestamp", "session_id_v7"]
+ partition_by = "toYYYYMM(session_timestamp)"
+ settings = {
+ index_granularity = "8192"
+ storage_policy = "s3_tiered"
+ }
+ column "team_id" {
+ type = "Int64"
+ }
+ column "session_id_v7" {
+ type = "UInt128"
+ }
+ column "session_timestamp" {
+ type = "DateTime64(3)"
+ default = "fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80)))"
+ }
+ column "distinct_id" {
+ type = "AggregateFunction(argMax, String, DateTime64(6, 'UTC'))"
+ }
+ column "distinct_ids" {
+ type = "AggregateFunction(groupUniqArray, String)"
+ }
+ column "min_timestamp" {
+ type = "SimpleAggregateFunction(min, DateTime64(6, 'UTC'))"
+ }
+ column "max_timestamp" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "max_inserted_at" {
+ type = "SimpleAggregateFunction(max, DateTime64(6, 'UTC'))"
+ }
+ column "urls" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String))"
+ }
+ column "entry_url" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "end_url" {
+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "last_external_click_url" {
+ type = "AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "browser" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "browser_version" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "os" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "os_version" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "device_type" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "viewport_width" {
+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"
+ }
+ column "viewport_height" {
+ type = "AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC'))"
+ }
+ column "geoip_country_code" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "geoip_subdivision_1_code" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "geoip_subdivision_1_name" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "geoip_subdivision_city_name" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "geoip_time_zone" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_referring_domain" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_utm_source" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_utm_campaign" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_utm_medium" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_utm_term" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_utm_content" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_gclid" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_gad_source" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_fbclid" {
+ type = "AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_has_gclid" {
+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"
+ }
+ column "entry_has_fbclid" {
+ type = "AggregateFunction(argMin, Bool, DateTime64(6, 'UTC'))"
+ }
+ column "entry_ad_ids_map" {
+ type = "AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_ad_ids_set" {
+ type = "AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC'))"
+ }
+ column "entry_channel_type_properties" {
+ type = "AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC'))"
+ }
+ column "pageview_uniq" {
+ type = "AggregateFunction(uniqExact, Nullable(UUID))"
+ }
+ column "autocapture_uniq" {
+ type = "AggregateFunction(uniqExact, Nullable(UUID))"
+ }
+ column "screen_uniq" {
+ type = "AggregateFunction(uniqExact, Nullable(UUID))"
+ }
+ column "page_screen_uniq_up_to" {
+ type = "AggregateFunction(uniqUpTo(1), Nullable(UUID))"
+ }
+ column "has_autocapture" {
+ type = "SimpleAggregateFunction(max, Bool)"
+ }
+ column "flag_values" {
+ type = "AggregateFunction(groupUniqArrayMap, Map(String, String))"
+ }
+ column "flag_keys" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"
+ }
+ column "event_names" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray, Array(String))"
+ }
+ column "hosts" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray(100), Array(String))"
+ }
+ column "emails" {
+ type = "SimpleAggregateFunction(groupUniqArrayArray(10), Array(String))"
+ }
+ column "has_replay_events" {
+ type = "SimpleAggregateFunction(max, Bool)"
+ }
+ index "event_names_bloom_filter" {
+ expr = "event_names"
+ type = "bloom_filter()"
+ granularity = 1
+ }
+ index "flag_keys_bloom_filter" {
+ expr = "flag_keys"
+ type = "bloom_filter()"
+ granularity = 1
+ }
+ engine "replicated_aggregating_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3"
+ replica_name = "{shard}-{replica}"
+ }
+ }
+
+ # The channel dictionary source. prod-eu reads it from the data cluster
+ # instead of storing it, and overrides this declaration to say so.
+ table "channel_definition" {
+ order_by = ["domain", "kind"]
+ settings = {
+ default_compression_codec = "lz4"
+ index_granularity = "8192"
+ }
+ column "domain" {
+ type = "String"
+ }
+ column "kind" {
+ type = "String"
+ }
+ column "domain_type" {
+ type = "Nullable(String)"
+ }
+ column "type_if_paid" {
+ type = "Nullable(String)"
+ }
+ column "type_if_organic" {
+ type = "Nullable(String)"
+ }
+ engine "replicated_merge_tree" {
+ zoo_path = "/clickhouse/tables/sessions/noshard/posthog.channel_definition"
+ replica_name = "{replica}-{shard}"
+ }
+ }
+
table "events" {
extend = "_event_base"
patch_column "$group_0" {
@@ -348,305 +550,10 @@ database "posthog" {
type = "String"
after = "_offset"
}
- column "mat_$user_id" {
- type = "String"
- comment = "column_materializer::$user_id"
- after = "elements_chain"
- }
- column "mat_$browser" {
- type = "String"
- comment = "column_materializer::$browser"
- after = "mat_$user_id"
- }
- column "mat_$host" {
- type = "String"
- comment = "column_materializer::$host"
- after = "mat_$browser"
- }
- column "mat_$current_url" {
- type = "String"
- comment = "column_materializer::$current_url"
- after = "mat_$host"
- }
- column "mat_distinct_id" {
- type = "String"
- comment = "column_materializer::distinct_id"
- after = "mat_$current_url"
- }
- column "mat_action" {
- type = "String"
- comment = "column_materializer::action"
- after = "mat_distinct_id"
- }
- column "mat_origin" {
- type = "String"
- comment = "column_materializer::origin"
- after = "mat_action"
- }
- column "mat_email" {
- type = "String"
- comment = "column_materializer::email"
- after = "mat_origin"
- }
- column "mat_key" {
- type = "String"
- comment = "column_materializer::key"
- after = "mat_email"
- }
- column "mat_insight" {
- type = "String"
- comment = "column_materializer::insight"
- after = "mat_key"
- }
- column "mat_$event_type" {
- type = "String"
- comment = "column_materializer::$event_type"
- after = "mat_insight"
- }
- column "mat_created_by" {
- type = "String"
- comment = "column_materializer::created_by"
- after = "mat_$event_type"
- }
- column "mat_total_event_actions_count" {
- type = "String"
- comment = "column_materializer::total_event_actions_count"
- after = "mat_created_by"
- }
- column "mat_is_demo_project" {
- type = "String"
- comment = "column_materializer::is_demo_project"
- after = "mat_total_event_actions_count"
- }
- column "mat_$active_feature_flags" {
- type = "String"
- comment = "column_materializer::$active_feature_flags"
- after = "mat_is_demo_project"
- }
- column "mat_filters_count" {
- type = "String"
- comment = "column_materializer::filters_count"
- after = "mat_$active_feature_flags"
- }
- column "mat_utm_source" {
- type = "String"
- comment = "column_materializer::utm_source"
- after = "mat_filters_count"
- }
- column "mat_apiErrorMessage" {
- type = "String"
- comment = "column_materializer::apiErrorMessage"
- after = "mat_utm_source"
- }
- column "mat_$referring_domain" {
- type = "String"
- comment = "column_materializer::$referring_domain"
- after = "mat_apiErrorMessage"
- }
- column "mat_statusCode" {
- type = "String"
- comment = "column_materializer::statusCode"
- after = "mat_$referring_domain"
- }
- column "mat_deal_id" {
- type = "String"
- comment = "column_materializer::deal_id"
- after = "mat_statusCode"
- }
- column "mat_realm" {
- type = "String"
- comment = "column_materializer::realm"
- after = "mat_deal_id"
- }
- column "mat_$lib" {
- type = "String"
- comment = "column_materializer::$lib"
- after = "$group_4"
- }
- column "mat_$os" {
- type = "String"
- comment = "column_materializer::$os"
- after = "mat_$lib"
- }
- column "mat_$initial_referrer" {
- type = "String"
- comment = "column_materializer::$initial_referrer"
- after = "mat_$os"
- }
- column "mat_$app_version" {
- type = "String"
- comment = "column_materializer::$app_version"
- after = "mat_$initial_referrer"
- }
- column "mat_$initial_referring_domain" {
- type = "String"
- comment = "column_materializer::$initial_referring_domain"
- after = "mat_$app_version"
- }
- column "mat_symbol" {
- type = "String"
- comment = "column_materializer::symbol"
- after = "mat_$initial_referring_domain"
- }
- column "mat_page" {
- type = "String"
- comment = "column_materializer::page"
- after = "mat_symbol"
- }
- column "mat_type" {
- type = "String"
- comment = "column_materializer::type"
- after = "mat_page"
- }
- column "mat_currentScreen" {
- type = "String"
- comment = "column_materializer::currentScreen"
- after = "mat_type"
- }
- column "mat_utm_campaign" {
- type = "String"
- comment = "column_materializer::utm_campaign"
- after = "mat_currentScreen"
- }
- column "mat_is_organization_first_user" {
- type = "String"
- comment = "column_materializer::is_organization_first_user"
- after = "mat_utm_campaign"
- }
- column "mat_is_first_component_load" {
- type = "String"
- comment = "column_materializer::is_first_component_load"
- after = "mat_is_organization_first_user"
- }
- column "mat_team" {
- type = "String"
- comment = "column_materializer::team"
- after = "mat_is_first_component_load"
- }
- column "mat_context" {
- type = "String"
- comment = "column_materializer::context"
- after = "mat_team"
- }
- column "mat_sdk" {
- type = "String"
- comment = "column_materializer::sdk"
- after = "mat_context"
- }
- column "mat_created_by_system" {
- type = "String"
- comment = "column_materializer::created_by_system"
- after = "mat_sdk"
- }
- column "mat_item_count" {
- type = "String"
- comment = "column_materializer::item_count"
- after = "mat_created_by_system"
- }
- column "mat_$ip" {
- type = "String"
- comment = "column_materializer::$ip"
- after = "mat_item_count"
- }
- column "mat_$referrer" {
- type = "String"
- comment = "column_materializer::$referrer"
- after = "mat_$ip"
- }
- column "mat_action_name" {
- type = "String"
- comment = "column_materializer::action_name"
- after = "mat_$referrer"
- }
- column "mat_$geoip_country_name" {
- type = "String"
- comment = "column_materializer::$geoip_country_name"
- after = "mat_action_name"
- }
- column "mat_$device_model" {
- type = "String"
- comment = "column_materializer::$device_model"
- after = "mat_$geoip_country_name"
- }
- column "mat_progress" {
- type = "String"
- comment = "column_materializer::progress"
- after = "mat_$device_model"
- }
- column "mat_chain" {
- type = "String"
- comment = "column_materializer::chain"
- after = "mat_progress"
- }
- column "mat_$device_type" {
- type = "String"
- comment = "column_materializer::$device_type"
- after = "mat_chain"
- }
- column "mat_usd" {
- type = "String"
- comment = "column_materializer::usd"
- after = "mat_$device_type"
- }
- column "mat_app_name" {
- type = "String"
- comment = "column_materializer::app_name"
- after = "mat_usd"
- }
- column "mat_$screen_name" {
- type = "String"
- comment = "column_materializer::$screen_name"
- after = "mat_app_name"
- }
- column "mat_index" {
- type = "String"
- comment = "column_materializer::index"
- after = "mat_$screen_name"
- }
- column "mat_token" {
- type = "String"
- comment = "column_materializer::token"
- after = "mat_index"
- }
- column "mat_method" {
- type = "String"
- comment = "column_materializer::method"
- after = "mat_token"
- }
- column "mat_address" {
- type = "String"
- comment = "column_materializer::address"
- after = "mat_method"
- }
- column "mat_name" {
- type = "String"
- comment = "column_materializer::name"
- after = "mat_address"
- }
- column "mat_inviteCode" {
- type = "String"
- comment = "column_materializer::inviteCode"
- after = "mat_name"
- }
- column "mat_osName" {
- type = "String"
- comment = "column_materializer::osName"
- after = "$session_id"
- }
- column "mat_nativeBuildVersion" {
- type = "String"
- comment = "column_materializer::nativeBuildVersion"
- after = "mat_osName"
- }
- column "mat_revenue" {
- type = "String"
- comment = "column_materializer::revenue"
- after = "mat_nativeBuildVersion"
- }
column "group_0" {
type = "String"
alias = "`$group_0`"
- after = "mat_revenue"
+ after = "$session_id"
}
column "group_1" {
type = "String"
@@ -668,99 +575,9 @@ database "posthog" {
alias = "`$group_4`"
after = "group_3"
}
- column "alias_mat__user_id" {
- type = "String"
- alias = "`mat_$user_id`"
- after = "group_4"
- }
- column "alias_mat__browser" {
- type = "String"
- alias = "`mat_$browser`"
- after = "alias_mat__user_id"
- }
- column "alias_mat__host" {
- type = "String"
- alias = "`mat_$host`"
- after = "alias_mat__browser"
- }
- column "alias_mat__current_url" {
- type = "String"
- alias = "`mat_$current_url`"
- after = "alias_mat__host"
- }
- column "alias_mat__event_type" {
- type = "String"
- alias = "`mat_$event_type`"
- after = "alias_mat__current_url"
- }
- column "alias_mat__active_feature_flags" {
- type = "String"
- alias = "`mat_$active_feature_flags`"
- after = "alias_mat__event_type"
- }
- column "alias_mat__referring_domain" {
- type = "String"
- alias = "`mat_$referring_domain`"
- after = "alias_mat__active_feature_flags"
- }
- column "alias_mat__lib" {
- type = "String"
- alias = "`mat_$lib`"
- after = "alias_mat__referring_domain"
- }
- column "alias_mat__os" {
- type = "String"
- alias = "`mat_$os`"
- after = "alias_mat__lib"
- }
- column "alias_mat__initial_referrer" {
- type = "String"
- alias = "`mat_$initial_referrer`"
- after = "alias_mat__os"
- }
- column "alias_mat__app_version" {
- type = "String"
- alias = "`mat_$app_version`"
- after = "alias_mat__initial_referrer"
- }
- column "alias_mat__initial_referring_domain" {
- type = "String"
- alias = "`mat_$initial_referring_domain`"
- after = "alias_mat__app_version"
- }
- column "alias_mat__ip" {
- type = "String"
- alias = "`mat_$ip`"
- after = "alias_mat__initial_referring_domain"
- }
- column "alias_mat__referrer" {
- type = "String"
- alias = "`mat_$referrer`"
- after = "alias_mat__ip"
- }
- column "alias_mat__geoip_country_name" {
- type = "String"
- alias = "`mat_$geoip_country_name`"
- after = "alias_mat__referrer"
- }
- column "alias_mat__device_model" {
- type = "String"
- alias = "`mat_$device_model`"
- after = "alias_mat__geoip_country_name"
- }
- column "alias_mat__device_type" {
- type = "String"
- alias = "`mat_$device_type`"
- after = "alias_mat__device_model"
- }
- column "alias_mat__screen_name" {
- type = "String"
- alias = "`mat_$screen_name`"
- after = "alias_mat__device_type"
- }
column "person_id" {
type = "UUID"
- after = "alias_mat__screen_name"
+ after = "group_4"
}
column "person_properties" {
type = "String"
@@ -810,1179 +627,14 @@ database "posthog" {
type = "DateTime64(3)"
after = "group3_created_at"
}
- column "mat_arguments" {
- type = "String"
- comment = "column_materializer::properties::arguments"
- after = "group4_created_at"
- }
- column "mat_source" {
- type = "String"
- comment = "column_materializer::properties::source"
- after = "mat_arguments"
- }
- column "mat_pp_email" {
- type = "String"
- comment = "column_materializer::person_properties::email"
- after = "mat_source"
- }
- column "mat_$time" {
- type = "String"
- comment = "column_materializer::properties::$time"
- after = "mat_pp_email"
- }
- column "mat_$pathname" {
- type = "String"
- comment = "column_materializer::properties::$pathname"
- after = "mat_$time"
- }
- column "mat_$geoip_city_name" {
- type = "String"
- comment = "column_materializer::properties::$geoip_city_name"
- after = "mat_$pathname"
- }
- column "mat_community_id" {
- type = "String"
- comment = "column_materializer::properties::community_id"
- after = "mat_$geoip_city_name"
- }
- column "mat_thread_id" {
- type = "String"
- comment = "column_materializer::properties::thread_id"
- after = "mat_community_id"
- }
- column "mat_Event_productCode" {
- type = "String"
- comment = "column_materializer::properties::Event.productCode"
- after = "mat_thread_id"
- }
- column "mat_env" {
- type = "String"
- comment = "column_materializer::properties::env"
- after = "mat_Event_productCode"
- }
- column "mat_target" {
- type = "String"
- comment = "column_materializer::properties::target"
- after = "mat_env"
- }
- column "mat_Subscription_plan_amount" {
- type = "String"
- comment = "column_materializer::properties::Subscription.plan.amount"
- after = "mat_target"
- }
- column "mat_title" {
- type = "String"
- comment = "column_materializer::properties::title"
- after = "mat_Subscription_plan_amount"
- }
- column "mat_Connection_app_name" {
- type = "String"
- comment = "column_materializer::properties::Connection.app.name"
- after = "mat_title"
- }
- column "mat_utm_medium" {
- type = "String"
- comment = "column_materializer::properties::utm_medium"
- after = "mat_Connection_app_name"
- }
- column "mat_Account_client_id" {
- type = "String"
- comment = "column_materializer::properties::Account.client_id"
- after = "mat_utm_medium"
- }
- column "mat_HTTP_Method" {
- type = "String"
- comment = "column_materializer::properties::HTTP Method"
- after = "mat_Account_client_id"
- }
- column "mat_audio_duration" {
- type = "String"
- comment = "column_materializer::properties::audio_duration"
- after = "mat_HTTP_Method"
- }
- column "mat_duration" {
- type = "String"
- comment = "column_materializer::properties::duration"
- after = "mat_audio_duration"
- }
- column "mat_url" {
- type = "String"
- comment = "column_materializer::properties::url"
- after = "mat_duration"
- }
- column "mat_group_id" {
- type = "String"
- comment = "column_materializer::properties::group_id"
- after = "mat_url"
- }
- column "mat_platform" {
- type = "String"
- comment = "column_materializer::properties::platform"
- after = "mat_group_id"
- }
- column "mat_pp_$browser" {
- type = "String"
- comment = "column_materializer::person_properties::$browser"
- after = "mat_platform"
- }
- column "mat_payment_status" {
- type = "String"
- comment = "column_materializer::properties::payment_status"
- after = "mat_pp_$browser"
- }
- column "mat_testSessionId" {
- type = "String"
- comment = "column_materializer::properties::testSessionId"
- after = "mat_payment_status"
- }
- column "mat_$sent_at" {
- type = "String"
- comment = "column_materializer::properties::$sent_at"
- after = "inserted_at"
- }
- column "mat_pp_companyName" {
- type = "String"
- comment = "column_materializer::person_properties::companyName"
- after = "mat_$sent_at"
- }
- column "mat_function" {
- type = "String"
- comment = "column_materializer::properties::function"
- after = "mat_pp_companyName"
- }
- column "mat_store_url" {
- type = "String"
- comment = "column_materializer::properties::store_url"
- after = "mat_function"
- }
- column "mat_email_domain" {
- type = "String"
- comment = "column_materializer::properties::email_domain"
- after = "mat_store_url"
- }
- column "mat_institution_name" {
- type = "String"
- comment = "column_materializer::properties::institution_name"
- after = "mat_email_domain"
- }
- column "mat_authentication_method" {
- type = "String"
- comment = "column_materializer::properties::authentication_method"
- after = "mat_institution_name"
- }
- column "mat_initial_step" {
- type = "String"
- comment = "column_materializer::properties::initial_step"
- after = "mat_authentication_method"
- }
- column "mat_status_message" {
- type = "String"
- comment = "column_materializer::properties::status_message"
- after = "mat_initial_step"
- }
- column "mat_mode" {
- type = "String"
- comment = "column_materializer::properties::mode"
- after = "mat_status_message"
- }
- column "mat_protocol" {
- type = "String"
- comment = "column_materializer::properties::protocol"
- after = "mat_mode"
- }
- column "mat_job_type" {
- type = "String"
- comment = "column_materializer::properties::job_type"
- after = "mat_protocol"
- }
- column "mat_is_oauth" {
- type = "String"
- comment = "column_materializer::properties::is_oauth"
- after = "mat_job_type"
- }
- column "mat_is_initial_aggregation" {
- type = "String"
- comment = "column_materializer::properties::is_initial_aggregation"
- after = "mat_is_oauth"
- }
- column "mat_search_term" {
- type = "String"
- comment = "column_materializer::properties::search_term"
- after = "mat_is_initial_aggregation"
- }
- column "mat_valid_ach_accounts" {
- type = "String"
- comment = "column_materializer::properties::valid_ach_accounts"
- after = "mat_search_term"
- }
- column "mat_gross" {
- type = "String"
- comment = "column_materializer::properties::gross"
- after = "mat_valid_ach_accounts"
- }
- column "mat_orderType" {
- type = "String"
- comment = "column_materializer::properties::orderType"
- after = "mat_gross"
- }
- column "mat_sku" {
- type = "String"
- comment = "column_materializer::properties::sku"
- after = "mat_orderType"
- }
- column "mat_dual_channel" {
- type = "String"
- comment = "column_materializer::properties::dual_channel"
- after = "mat_sku"
- }
- column "mat_channel" {
- type = "String"
- comment = "column_materializer::properties::channel"
- after = "mat_dual_channel"
- }
- column "mat_workspaceId" {
- type = "String"
- comment = "column_materializer::properties::workspaceId"
- after = "mat_channel"
- }
- column "mat_numberOfSecrets" {
- type = "String"
- comment = "column_materializer::properties::numberOfSecrets"
- after = "mat_workspaceId"
- }
- column "mat_organizations" {
- type = "String"
- comment = "column_materializer::properties::organizations"
- after = "mat_numberOfSecrets"
- }
- column "mat_organization" {
- type = "String"
- comment = "column_materializer::properties::organization"
- after = "mat_organizations"
- }
- column "mat_contributionError" {
- type = "String"
- comment = "column_materializer::properties::contributionError"
- after = "mat_organization"
- }
- column "mat_phone" {
- type = "String"
- comment = "column_materializer::properties::phone"
- after = "mat_contributionError"
- }
- column "mat_$initial_pathname" {
- type = "String"
- comment = "column_materializer::properties::$initial_pathname"
- after = "mat_phone"
- }
- column "mat_organization_name" {
- type = "String"
- comment = "column_materializer::properties::organization_name"
- after = "mat_$initial_pathname"
- }
- column "mat_category" {
- type = "String"
- comment = "column_materializer::properties::category"
- after = "mat_organization_name"
- }
- column "mat_$lib_version" {
- type = "String"
- comment = "column_materializer::properties::$lib_version"
- after = "mat_category"
- }
- column "mat_pp_$initial_utm_campaign" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_campaign"
- after = "mat_$lib_version"
- }
- column "mat_pp_$initial_utm_medium" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_medium"
- after = "mat_pp_$initial_utm_campaign"
- }
- column "mat_pp_$initial_gclid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_gclid"
- after = "mat_pp_$initial_utm_medium"
- }
- column "mat_pp_$initial_gad_source" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_gad_source"
- after = "mat_pp_$initial_gclid"
- }
- column "mat_pp_$initial_utm_source" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_source"
- after = "mat_pp_$initial_gad_source"
- }
- column "mat_pp_$initial_referring_domain" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_referring_domain"
- after = "mat_pp_$initial_utm_source"
- }
- column "mat_pp_$initial_utm_term" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_term"
- after = "mat_pp_$initial_referring_domain"
- }
- column "mat_pp_$initial_utm_content" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_utm_content"
- after = "mat_pp_$initial_utm_term"
- }
- column "mat_pp_$initial_gbraid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_gbraid::disabled"
- after = "mat_pp_$initial_utm_content"
- }
- column "mat_pp_$initial_wbraid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_wbraid::disabled"
- after = "mat_pp_$initial_gbraid"
- }
- column "mat_pp_$initial_msclkid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_msclkid"
- after = "mat_pp_$initial_wbraid"
- }
- column "mat_pp_$initial_fbclid" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_fbclid"
- after = "mat_pp_$initial_msclkid"
- }
- column "mat_$geoip_subdivision_1_code" {
- type = "String"
- comment = "column_materializer::properties::$geoip_subdivision_1_code"
- after = "mat_pp_$initial_fbclid"
- }
- column "mat_wlo_enabled" {
- type = "String"
- comment = "column_materializer::properties::wlo_enabled"
- after = "mat_$geoip_subdivision_1_code"
- }
- column "mat_$prev_pageview_max_scroll_percentage" {
- type = "String"
- comment = "column_materializer::properties::$prev_pageview_max_scroll_percentage"
- after = "mat_wlo_enabled"
- }
- column "mat_$prev_pageview_max_content_percentage" {
- type = "String"
- comment = "column_materializer::properties::$prev_pageview_max_content_percentage"
- after = "mat_$prev_pageview_max_scroll_percentage"
- }
- column "mat_$prev_pageview_pathname" {
- type = "String"
- comment = "column_materializer::properties::$prev_pageview_pathname"
- after = "mat_$prev_pageview_max_content_percentage"
- }
- column "mat_pp_$initial_pathname" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_pathname"
- after = "mat_$prev_pageview_pathname"
- }
- column "mat_pp_$geoip_country_code" {
- type = "String"
- comment = "column_materializer::person_properties::$geoip_country_code"
- after = "mat_pp_$initial_pathname"
- }
- column "mat_pp_username" {
- type = "String"
- comment = "column_materializer::person_properties::username"
- after = "mat_pp_$geoip_country_code"
- }
- column "mat_pp_serverMasterclass" {
- type = "String"
- comment = "column_materializer::person_properties::serverMasterclass"
- after = "mat_pp_username"
- }
- column "mat_content_length" {
- type = "String"
- comment = "column_materializer::properties::content_length"
- after = "mat_pp_serverMasterclass"
- }
- column "mat_pp_serverMarketing" {
- type = "String"
- comment = "column_materializer::person_properties::serverMarketing"
- after = "mat_content_length"
- }
- column "mat_$browser_version" {
- type = "String"
- comment = "column_materializer::properties::$browser_version"
- after = "mat_pp_serverMarketing"
- }
- column "mat_pp_role" {
- type = "String"
- comment = "column_materializer::person_properties::role"
- after = "mat_$browser_version"
- }
- column "mat_pp_customer" {
- type = "String"
- comment = "column_materializer::person_properties::customer"
- after = "mat_pp_role"
- }
- column "mat_event" {
- type = "String"
- comment = "column_materializer::properties::event"
- after = "mat_pp_customer"
- }
- column "mat_disable_institution_search" {
- type = "String"
- comment = "column_materializer::properties::disable_institution_search"
- after = "mat_event"
- }
- column "mat_is_first_event_for_user" {
- type = "String"
- comment = "column_materializer::properties::is_first_event_for_user"
- after = "mat_disable_institution_search"
- }
- column "mat_current_member_guid" {
- type = "String"
- comment = "column_materializer::properties::current_member_guid"
- after = "mat_is_first_event_for_user"
- }
- column "mat_user_agent" {
- type = "String"
- comment = "column_materializer::properties::user_agent"
- after = "mat_current_member_guid"
- }
- column "mat_is_test_user" {
- type = "String"
- comment = "column_materializer::properties::is_test_user"
- after = "mat_user_agent"
- }
- column "mat_referrer" {
- type = "String"
- comment = "column_materializer::properties::referrer"
- after = "mat_is_test_user"
- }
- column "mat_pp_$initial_current_url" {
- type = "String"
- comment = "column_materializer::person_properties::$initial_current_url"
- after = "mat_referrer"
- }
- column "mat_most_recent_app_os" {
- type = "String"
- comment = "column_materializer::properties::most_recent_app_os"
- after = "mat_pp_$initial_current_url"
- }
- column "mat_pp_hubspot_score" {
- type = "String"
- comment = "column_materializer::person_properties::hubspot_score"
- after = "mat_most_recent_app_os"
- }
- column "mat_pp_id" {
- type = "String"
- comment = "column_materializer::person_properties::id"
- after = "mat_pp_hubspot_score"
- }
- column "mat_pp_$current_url" {
- type = "String"
- comment = "column_materializer::person_properties::$current_url"
- after = "mat_pp_id"
- }
- column "mat_product_key" {
- type = "String"
- comment = "column_materializer::properties::product_key"
- after = "mat_pp_$current_url"
- }
- column "mat_Plan_type_and_filter" {
- type = "String"
- comment = "column_materializer::properties::Plan type and filter"
- after = "mat_product_key"
- }
- column "mat_$app_namespace" {
- type = "String"
- comment = "column_materializer::properties::$app_namespace"
- after = "mat_Plan_type_and_filter"
- }
- column "mat_$os_name" {
- type = "String"
- comment = "column_materializer::properties::$os_name"
- after = "mat_$app_namespace"
- }
- column "mat_pp_$os_name" {
- type = "String"
- comment = "column_materializer::person_properties::$os_name::disabled"
- after = "mat_$os_name"
- }
- column "mat_pp_$app_version" {
- type = "String"
- comment = "column_materializer::person_properties::$app_version"
- after = "mat_pp_$os_name"
- }
- column "mat_subscriptionStatus" {
- type = "String"
- comment = "column_materializer::properties::subscriptionStatus"
- after = "mat_pp_$app_version"
- }
- column "mat_$screen_height" {
- type = "String"
- comment = "column_materializer::properties::$screen_height"
- after = "mat_subscriptionStatus"
- }
- column "mat_$screen_width" {
- type = "String"
- comment = "column_materializer::properties::$screen_width"
- after = "mat_$screen_height"
- }
- column "mat_tag" {
- type = "String"
- comment = "column_materializer::properties::tag"
- after = "mat_$screen_width"
- }
- column "mat_$app_build" {
- type = "String"
- comment = "column_materializer::properties::$app_build"
- after = "mat_tag"
- }
- column "mat_surface_tag" {
- type = "String"
- comment = "column_materializer::properties::surface_tag"
- after = "mat_$app_build"
- }
- column "mat_survey_responses_count_in_period" {
- type = "String"
- comment = "column_materializer::properties::survey_responses_count_in_period"
- after = "mat_surface_tag"
- }
- column "mat_event_count_in_month" {
- type = "String"
- comment = "column_materializer::properties::event_count_in_month"
- after = "mat_survey_responses_count_in_period"
- }
- column "mat_ramp" {
- type = "String"
- comment = "column_materializer::properties::ramp"
- after = "mat_event_count_in_month"
- }
- column "mat_auto_chapters" {
- type = "String"
- comment = "column_materializer::properties::auto_chapters"
- after = "mat_ramp"
- }
- column "mat_sentiment_analysis" {
- type = "String"
- comment = "column_materializer::properties::sentiment_analysis"
- after = "mat_auto_chapters"
- }
- column "mat_redact_pii" {
- type = "String"
- comment = "column_materializer::properties::redact_pii"
- after = "mat_sentiment_analysis"
- }
- column "mat_content_safety" {
- type = "String"
- comment = "column_materializer::properties::content_safety"
- after = "mat_redact_pii"
- }
- column "mat_iab_categories" {
- type = "String"
- comment = "column_materializer::properties::iab_categories"
- after = "mat_content_safety"
- }
- column "mat_auto_highlights" {
- type = "String"
- comment = "column_materializer::properties::auto_highlights"
- after = "mat_iab_categories"
- }
- column "mat_entity_detection" {
- type = "String"
- comment = "column_materializer::properties::entity_detection"
- after = "mat_auto_highlights"
- }
- column "mat_summarization" {
- type = "String"
- comment = "column_materializer::properties::summarization"
- after = "mat_entity_detection"
- }
- column "mat_pp_val_region" {
- type = "String"
- comment = "column_materializer::person_properties::val_region"
- after = "mat_summarization"
- }
- column "mat_client_id" {
- type = "String"
- comment = "column_materializer::properties::client_id"
- after = "mat_pp_val_region"
- }
- column "mat_$geoip_country_code" {
- type = "String"
- comment = "column_materializer::properties::$geoip_country_code"
- after = "mat_client_id"
- }
- column "mat_disfluencies" {
- type = "String"
- comment = "column_materializer::properties::disfluencies"
- after = "mat_$geoip_country_code"
- }
- column "mat_filter_profanity" {
- type = "String"
- comment = "column_materializer::properties::filter_profanity"
- after = "mat_disfluencies"
- }
- column "mat_speaker_labels" {
- type = "String"
- comment = "column_materializer::properties::speaker_labels"
- after = "mat_filter_profanity"
- }
- column "mat_language_detection" {
- type = "String"
- comment = "column_materializer::properties::language_detection"
- after = "mat_speaker_labels"
- }
- column "mat_product_analytics_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::product_analytics_projected_amount"
- after = "mat_language_detection"
- }
- column "mat_recordings_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::recordings_projected_amount"
- after = "mat_product_analytics_projected_amount"
- }
- column "mat_events_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::events_projected_amount"
- after = "mat_recordings_projected_amount"
- }
- column "mat_session_replay_projected_amount" {
- type = "String"
- comment = "column_materializer::properties::session_replay_projected_amount"
- after = "mat_events_projected_amount"
- }
- column "mat_total_usd" {
- type = "String"
- comment = "column_materializer::properties::total_usd"
- after = "mat_session_replay_projected_amount"
- }
- column "mat_stripe_amount_paid" {
- type = "String"
- comment = "column_materializer::properties::stripe_amount_paid"
- after = "mat_total_usd"
- }
- column "mat_workspace" {
- type = "String"
- comment = "column_materializer::properties::workspace"
- after = "mat_stripe_amount_paid"
- }
- column "mat_created_at" {
- type = "String"
- comment = "column_materializer::properties::created_at"
- after = "mat_workspace"
- }
- column "mat_kind" {
- type = "String"
- comment = "column_materializer::properties::kind"
- after = "mat_created_at"
- }
- column "mat_product" {
- type = "String"
- comment = "column_materializer::properties::product"
- after = "mat_kind"
- }
- column "mat_message" {
- type = "String"
- comment = "column_materializer::properties::message"
- after = "mat_product"
- }
- column "mat_initiator" {
- type = "String"
- comment = "column_materializer::properties::initiator"
- after = "mat_message"
- }
- column "mat_query" {
- type = "String"
- comment = "column_materializer::properties::query"
- after = "mat_initiator"
- }
- column "mat_$survey_id" {
- type = "String"
- comment = "column_materializer::properties::$survey_id"
- after = "mat_query"
- }
- column "mat_$survey_response_1" {
- type = "String"
- comment = "column_materializer::properties::$survey_response_1"
- after = "mat_$survey_id"
- }
- column "mat_ticketId" {
- type = "String"
- comment = "column_materializer::properties::ticketId"
- after = "mat_$survey_response_1"
- }
- column "mat_$survey_response" {
- type = "String"
- comment = "column_materializer::properties::$survey_response"
- after = "mat_ticketId"
- }
- column "mat_conceptName" {
- type = "String"
- comment = "column_materializer::properties::conceptName"
- after = "mat_$survey_response"
- }
- column "mat_apiName" {
- type = "String"
- comment = "column_materializer::properties::apiName"
- after = "mat_conceptName"
- }
- column "mat_workplace_billing_plan" {
- type = "String"
- comment = "column_materializer::properties::workplace_billing_plan"
- after = "mat_apiName"
- }
- column "mat_$el_text" {
- type = "String"
- comment = "column_materializer::properties::$el_text"
- after = "mat_workplace_billing_plan"
- }
- column "mat_recording_count_in_period" {
- type = "String"
- comment = "column_materializer::properties::recording_count_in_period"
- after = "mat_$el_text"
- }
- column "mat_$os_version" {
- type = "String"
- comment = "column_materializer::properties::$os_version"
- after = "mat_recording_count_in_period"
- }
- column "mat_orderId" {
- type = "String"
- comment = "column_materializer::properties::orderId"
- after = "mat_$os_version"
- }
- column "mat_commit_sha" {
- type = "String"
- comment = "column_materializer::properties::commit_sha"
- after = "mat_orderId"
- }
- column "mat_$feature_flag_payloads" {
- type = "String"
- comment = "column_materializer::properties::$feature_flag_payloads"
- after = "mat_commit_sha"
- }
- column "mat_event_count_in_period" {
- type = "String"
- comment = "column_materializer::properties::event_count_in_period"
- after = "mat_$feature_flag_payloads"
- }
- column "mat_$groups" {
- type = "String"
- comment = "column_materializer::properties::$groups"
- after = "mat_event_count_in_period"
- }
- column "mat_$feature_flag" {
- type = "String"
- comment = "column_materializer::properties::$feature_flag"
- after = "mat_$groups"
- }
- column "mat_utm_content" {
- type = "String"
- comment = "column_materializer::properties::utm_content"
- after = "mat_$feature_flag"
- }
- column "mat_gclid" {
- type = "String"
- comment = "column_materializer::properties::gclid"
- after = "mat_utm_content"
- }
- column "mat_gad_source" {
- type = "String"
- comment = "column_materializer::properties::gad_source"
- after = "mat_gclid"
- }
- column "mat_gbraid" {
- type = "String"
- comment = "column_materializer::properties::gbraid"
- after = "mat_gad_source"
- }
- column "mat_wbraid" {
- type = "String"
- comment = "column_materializer::properties::wbraid"
- after = "mat_gbraid"
- }
- column "mat_fbclid" {
- type = "String"
- comment = "column_materializer::properties::fbclid"
- after = "mat_wbraid"
- }
- column "mat_msclkid" {
- type = "String"
- comment = "column_materializer::properties::msclkid"
- after = "mat_fbclid"
- }
- column "mat_organization_id" {
- type = "String"
- comment = "column_materializer::properties::organization_id"
- after = "mat_msclkid"
- }
- column "mat_owner_type" {
- type = "String"
- comment = "column_materializer::properties::owner_type"
- after = "mat_organization_id"
- }
- column "mat_device_type" {
- type = "String"
- comment = "column_materializer::properties::device_type"
- after = "mat_owner_type"
- }
- column "mat_$device_id" {
- type = "String"
- comment = "column_materializer::properties::$device_id"
- after = "mat_device_type"
- }
- column "mat_pp_$geoip_continent_name" {
- type = "String"
- comment = "column_materializer::person_properties::$geoip_continent_name"
- after = "mat_$device_id"
- }
- column "mat_$feature_flag_response" {
- type = "String"
- comment = "column_materializer::properties::$feature_flag_response"
- after = "mat_pp_$geoip_continent_name"
- }
- column "mat_pp_utm_source" {
- type = "String"
- comment = "column_materializer::person_properties::utm_source"
- after = "mat_$feature_flag_response"
- }
- column "mat_pp_$referring_domain" {
- type = "String"
- comment = "column_materializer::person_properties::$referring_domain"
- after = "mat_pp_utm_source"
- }
- column "mat_pp_Email_Domain" {
- type = "String"
- comment = "column_materializer::person_properties::Email Domain"
- after = "mat_pp_$referring_domain"
- }
- column "mat_machine_id" {
- type = "String"
- comment = "column_materializer::properties::machine_id"
- after = "mat_pp_Email_Domain"
- }
- column "mat_user_email_domain" {
- type = "String"
- comment = "column_materializer::properties::user_email_domain"
- after = "mat_machine_id"
- }
- column "mat_$lib_version__minor" {
- type = "String"
- comment = "column_materializer::properties::$lib_version__minor"
- after = "mat_user_email_domain"
- }
- column "mat_region" {
- type = "String"
- comment = "column_materializer::properties::region"
- after = "mat_$lib_version__minor"
- }
- column "mat_pp_user_email_domain" {
- type = "String"
- comment = "column_materializer::person_properties::user_email_domain"
- after = "mat_region"
- }
- column "mat_url_promotion_id" {
- type = "String"
- comment = "column_materializer::properties::url_promotion_id"
- after = "mat_pp_user_email_domain"
- }
- column "mat_$lib_custom_api_host" {
- type = "String"
- comment = "column_materializer::properties::$lib_custom_api_host"
- after = "mat_url_promotion_id"
- }
- column "mat_user_platform" {
- type = "String"
- comment = "column_materializer::properties::user_platform"
- after = "person_mode"
- }
- column "mat_pp_$geoip_country_name" {
- type = "String"
- comment = "column_materializer::person_properties::$geoip_country_name"
- after = "mat_user_platform"
- }
- column "mat_environment" {
- type = "String"
- comment = "column_materializer::properties::environment"
- after = "mat_pp_$geoip_country_name"
- }
- column "mat_customer_email" {
- type = "String"
- comment = "column_materializer::properties::customer_email"
- after = "mat_environment"
- }
- column "mat_client_name" {
- type = "String"
- comment = "column_materializer::properties::client_name"
- after = "mat_customer_email"
- }
- column "mat_screen_name" {
- type = "String"
- comment = "column_materializer::properties::screen_name"
- after = "mat_client_name"
- }
- column "mat_app_version" {
- type = "String"
- comment = "column_materializer::properties::app_version"
- after = "mat_screen_name"
- }
- column "mat_subdomain" {
- type = "String"
- comment = "column_materializer::properties::subdomain"
- after = "is_deleted"
- }
- column "mat_$device" {
- type = "String"
- comment = "column_materializer::properties::$device"
- after = "mat_subdomain"
- }
- column "mat_id" {
- type = "String"
- comment = "column_materializer::properties::id"
- after = "mat_$device"
- }
- column "mat_record_id" {
- type = "String"
- comment = "column_materializer::properties::record_id"
- after = "mat_id"
- }
- column "mat_referrer_id" {
- type = "String"
- comment = "column_materializer::properties::record_id"
- after = "mat_record_id"
- }
- column "mat_$exception_issue_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_issue_id"
- after = "mat_referrer_id"
- }
- column "mat_$exception_fingerprint" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_fingerprint"
- after = "mat_$exception_issue_id"
- }
- column "mat_$web_vitals_LCP_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_LCP_value"
- after = "mat_$exception_fingerprint"
- }
- column "mat_$web_vitals_FCP_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_FCP_value"
- after = "mat_$web_vitals_LCP_value"
- }
- column "mat_$web_vitals_CLS_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_CLS_value"
- after = "mat_$web_vitals_FCP_value"
- }
- column "mat_$web_vitals_INP_value" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$web_vitals_INP_value"
- after = "mat_$web_vitals_CLS_value"
- }
- column "mat_$viewport_width" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$viewport_width"
- after = "mat_$web_vitals_INP_value"
- }
- column "mat_$viewport_height" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$viewport_height"
- after = "mat_$viewport_width"
- }
- column "mat_$anon_distinct_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$anon_distinct_id"
- after = "mat_$viewport_height"
- }
column "mat_$ai_trace_id" {
type = "Nullable(String)"
comment = "column_materializer::properties::$ai_trace_id"
after = "person_properties_map_custom"
}
- column "mat_$ai_model" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_model"
- after = "mat_$ai_trace_id"
- }
- column "mat_$ai_provider" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_provider"
- after = "mat_$ai_model"
- }
- column "mat_$ai_parent_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_parent_id"
- after = "mat_$ai_provider"
- }
- column "mat_$ai_span_id" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_span_id"
- after = "mat_$ai_parent_id"
- }
- column "mat_$ai_http_status" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_http_status"
- after = "mat_$ai_span_id"
- }
- column "mat_$exception_types" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_types"
- after = "mat_$ai_http_status"
- }
- column "mat_$exception_values" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_values"
- after = "mat_$exception_types"
- }
- column "mat_$exception_sources" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_sources"
- after = "mat_$exception_values"
- }
- column "mat_$exception_functions" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$exception_functions"
- after = "mat_$exception_sources"
- }
- column "mat_$process_person_profile" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$process_person_profile"
- after = "$session_id_uuid"
- }
- column "mat_$is_identified" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$is_identified"
- after = "properties_group_ai"
- }
- column "dmat_numeric_0" {
- type = "Nullable(Float64)"
- after = "dmat_string_9"
- }
- column "dmat_numeric_1" {
- type = "Nullable(Float64)"
- after = "dmat_numeric_0"
- }
- column "dmat_numeric_2" {
- type = "Nullable(Float64)"
- after = "dmat_numeric_1"
- }
- column "dmat_numeric_3" {
- type = "Nullable(Float64)"
- after = "dmat_numeric_2"
- }
- column "dmat_numeric_4" {
- type = "Nullable(Float64)"
- after = "dmat_numeric_3"
- }
- column "dmat_numeric_5" {
- type = "Nullable(Float64)"
- after = "dmat_numeric_4"
- }
- column "dmat_numeric_6" {
- type = "Nullable(Float64)"
- after = "dmat_numeric_5"
- }
- column "dmat_numeric_7" {
- type = "Nullable(Float64)"
- after = "dmat_numeric_6"
- }
- column "dmat_numeric_8" {
- type = "Nullable(Float64)"
- after = "dmat_numeric_7"
- }
- column "dmat_numeric_9" {
- type = "Nullable(Float64)"
- after = "dmat_numeric_8"
- }
- column "dmat_bool_0" {
- type = "Nullable(UInt8)"
- after = "dmat_numeric_9"
- }
- column "dmat_bool_1" {
- type = "Nullable(UInt8)"
- after = "dmat_bool_0"
- }
- column "dmat_bool_2" {
- type = "Nullable(UInt8)"
- after = "dmat_bool_1"
- }
- column "dmat_bool_3" {
- type = "Nullable(UInt8)"
- after = "dmat_bool_2"
- }
- column "dmat_bool_4" {
- type = "Nullable(UInt8)"
- after = "dmat_bool_3"
- }
- column "dmat_bool_5" {
- type = "Nullable(UInt8)"
- after = "dmat_bool_4"
- }
- column "dmat_bool_6" {
- type = "Nullable(UInt8)"
- after = "dmat_bool_5"
- }
- column "dmat_bool_7" {
- type = "Nullable(UInt8)"
- after = "dmat_bool_6"
- }
- column "dmat_bool_8" {
- type = "Nullable(UInt8)"
- after = "dmat_bool_7"
- }
- column "dmat_bool_9" {
- type = "Nullable(UInt8)"
- after = "dmat_bool_8"
- }
- column "dmat_datetime_0" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- after = "dmat_bool_9"
- }
- column "dmat_datetime_1" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- after = "dmat_datetime_0"
- }
- column "dmat_datetime_2" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- after = "dmat_datetime_1"
- }
- column "dmat_datetime_3" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- after = "dmat_datetime_2"
- }
- column "dmat_datetime_4" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- after = "dmat_datetime_3"
- }
- column "dmat_datetime_5" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- after = "dmat_datetime_4"
- }
- column "dmat_datetime_6" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- after = "dmat_datetime_5"
- }
- column "dmat_datetime_7" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- after = "dmat_datetime_6"
- }
- column "dmat_datetime_8" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- after = "dmat_datetime_7"
- }
- column "dmat_datetime_9" {
- type = "Nullable(DateTime64(6, 'UTC'))"
- after = "dmat_datetime_8"
- }
- column "mat_$ai_total_cost_usd" {
- type = "Nullable(String)"
- comment = "column_materializer::properties::$ai_total_cost_usd"
- after = "historical_migration"
- }
column "properties_group_ai_large" {
type = "Map(String, String)"
- after = "mat_$ai_total_cost_usd"
+ after = "historical_migration"
}
}
}
diff --git a/posthog/clickhouse/hcl/roles/shared/sql/custom_metrics_backups.sql b/posthog/clickhouse/hcl/roles/shared/sql/custom_metrics_backups.sql
index e025c4cf64e5..cea3f99a1acc 100644
--- a/posthog/clickhouse/hcl/roles/shared/sql/custom_metrics_backups.sql
+++ b/posthog/clickhouse/hcl/roles/shared/sql/custom_metrics_backups.sql
@@ -1,9 +1,9 @@
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/roles/shared/sql/custom_metrics_replication_queue.sql b/posthog/clickhouse/hcl/roles/shared/sql/custom_metrics_replication_queue.sql
index e0b3019732fa..887c43d0cfde 100644
--- a/posthog/clickhouse/hcl/roles/shared/sql/custom_metrics_replication_queue.sql
+++ b/posthog/clickhouse/hcl/roles/shared/sql/custom_metrics_replication_queue.sql
@@ -1,9 +1,9 @@
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/dev/ai_events.sql b/posthog/clickhouse/hcl/sql/dev/ai_events.sql
index 6eac0f441576..aef22d4618cd 100644
--- a/posthog/clickhouse/hcl/sql/dev/ai_events.sql
+++ b/posthog/clickhouse/hcl/sql/dev/ai_events.sql
@@ -86,7 +86,7 @@ CREATE TABLE posthog.kafka_ai_events_json_ws (
person_properties String,
person_created_at DateTime64(3),
person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ai_events_ws\'', kafka_max_block_size = 5000, kafka_num_consumers = 1, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_ai_events_json\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_ai_events_ws', kafka_max_block_size = 5000, kafka_num_consumers = 1, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_ai_events_json';
CREATE TABLE posthog.person (
id UUID,
created_at DateTime64(3),
@@ -341,10 +341,10 @@ FROM system.query_log
WHERE type != 'QueryStart';
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -399,10 +399,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/dev/auxiliary.sql b/posthog/clickhouse/hcl/sql/dev/auxiliary.sql
index fc9984f06f90..465b8e6c870f 100644
--- a/posthog/clickhouse/hcl/sql/dev/auxiliary.sql
+++ b/posthog/clickhouse/hcl/sql/dev/auxiliary.sql
@@ -87,14 +87,14 @@ CREATE TABLE posthog.kafka_hog_invocation_results (
invocation_globals String,
version UInt64,
is_deleted UInt8
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';
+) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_hog_invocation_results', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_hog_invocation_results';
CREATE TABLE posthog.kafka_ingestion_warnings_v2 (
team_id Int64,
source LowCardinality(String),
type String,
details String,
timestamp DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ingestion_warnings_v2\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_ingestion_warnings_v2', kafka_topic_list = 'clickhouse_ingestion_warnings';
CREATE TABLE posthog.kafka_message_assets (
team_id Int64,
function_kind LowCardinality(String),
@@ -112,14 +112,14 @@ CREATE TABLE posthog.kafka_message_assets (
version UInt64,
is_deleted UInt8,
html String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_message_assets\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_message_assets\'';
+) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_message_assets', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_message_assets';
CREATE TABLE posthog.kafka_property_values (
team_id Int64,
property_type LowCardinality(String),
property_key String,
property_value String,
property_count UInt64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_property_values\'', kafka_num_consumers = 1, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_property_values\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_property_values', kafka_num_consumers = 1, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_property_values';
CREATE TABLE posthog.message_assets_data (
team_id Int64,
function_kind LowCardinality(String),
@@ -885,10 +885,10 @@ CREATE MATERIALIZED VIEW posthog.property_values_mv TO posthog.property_values (
FROM posthog.kafka_property_values;
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -943,10 +943,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/dev/batch_exports.sql b/posthog/clickhouse/hcl/sql/dev/batch_exports.sql
index 15bda2e755da..4f3212e25c2d 100644
--- a/posthog/clickhouse/hcl/sql/dev/batch_exports.sql
+++ b/posthog/clickhouse/hcl/sql/dev/batch_exports.sql
@@ -192,10 +192,10 @@ FROM system.query_log
WHERE type != 'QueryStart';
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -250,10 +250,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/dev/logs.sql b/posthog/clickhouse/hcl/sql/dev/logs.sql
index ba5cd58d555a..21860a6fbcc1 100644
--- a/posthog/clickhouse/hcl/sql/dev/logs.sql
+++ b/posthog/clickhouse/hcl/sql/dev/logs.sql
@@ -22,7 +22,7 @@ CREATE TABLE posthog.kafka_metrics_avro (
instrumentation_scope Nullable(String),
attributes Map(String, String),
series_fingerprint Nullable(Int64)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_metrics', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-metrics-avro-new\'', kafka_max_block_size = 65536, kafka_num_consumers = 8, kafka_poll_max_batch_size = 65536, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_metrics\'';
+) ENGINE = Kafka(warpstream_metrics) SETTINGS kafka_flush_interval_ms = 10000, kafka_format = 'Avro', kafka_group_name = 'clickhouse-metrics-avro-new', kafka_max_block_size = 4096, kafka_num_consumers = 2, kafka_poll_max_batch_size = 4096, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_metrics';
CREATE TABLE posthog.kafka_trace_spans_avro (
uuid String,
trace_id String,
@@ -45,7 +45,7 @@ CREATE TABLE posthog.kafka_trace_spans_avro (
links Array(String),
dropped_links_count Int32,
status_code Int32
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_traces', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-traces-avro\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_traces\'';
+) ENGINE = Kafka(warpstream_traces) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-traces-avro', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_traces';
CREATE TABLE posthog.log_attributes2 (
team_id Int32,
time_bucket DateTime64(0),
@@ -1101,10 +1101,10 @@ GROUP BY
_partition, _topic;
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -1159,10 +1159,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/dev/ops.sql b/posthog/clickhouse/hcl/sql/dev/ops.sql
new file mode 100644
index 000000000000..655af8b6e190
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/dev/ops.sql
@@ -0,0 +1,637 @@
+-- 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.event_property_daily_stats (
+ analysis_date Date,
+ team_id Int64,
+ property_key String,
+ event_count UInt64,
+ distinct_event_names UInt32,
+ total_property_bytes UInt64,
+ min_property_bytes UInt64,
+ max_property_bytes UInt64,
+ avg_property_bytes Float64,
+ p50_property_bytes Float64,
+ p90_property_bytes Float64,
+ p95_property_bytes Float64,
+ p99_property_bytes Float64,
+ property_size_histogram Array(Tuple(Float64, Float64, UInt64)),
+ top_event_names Array(String),
+ sample_rate Float32,
+ computed_at DateTime
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.event_property_daily_stats', '{replica}') ORDER BY (analysis_date, team_id, property_key) TTL analysis_date + toIntervalDay(30) SETTINGS index_granularity = 8192;
+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,
+ PROJECTION by_label_value (SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, label_name, label_value, id, metric_name),
+ PROJECTION by_id_label (SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, id, label_name, metric_name, label_value)
+) 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 CODEC(T64, Default),
+ metric_name LowCardinality(String),
+ timestamp DateTime64(3, 'UTC') CODEC(DoubleDelta, Default),
+ id UInt64,
+ value Float64 CODEC(Gorilla(8), Default)
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_samples_new', '{replica}') ORDER BY (team_id, metric_name, toStartOfTenMinutes(timestamp), id, timestamp) PARTITION BY toYYYYMMDD(timestamp) SETTINGS index_granularity = 8192;
+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'),
+ PROJECTION by_id (SELECT team_id, id, metric_name, labels_json, min_time, max_time
+ORDER BY team_id, id)
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_series', '{replica}') ORDER BY (team_id, metric_name, id) SETTINGS index_granularity = 1024;
+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'), ''),
+ 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', storage_policy = 's3_tiered';
+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 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 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.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/dev/sessions.sql b/posthog/clickhouse/hcl/sql/dev/sessions.sql
new file mode 100644
index 000000000000..2dc01b4d82fd
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/dev/sessions.sql
@@ -0,0 +1,583 @@
+-- AUTO-GENERATED from the declarative HCL by ops/gen-sql.sh — do not edit.
+-- Full CREATE schema for the dev/sessions node. Apply to a fresh ClickHouse to build it.
+
+CREATE TABLE posthog.channel_definition (
+ domain String,
+ kind String,
+ domain_type Nullable(String),
+ type_if_paid Nullable(String),
+ type_if_organic Nullable(String)
+) ENGINE = ReplicatedMergeTree('/clickhouse/tables/sessions/noshard/posthog.channel_definition', '{replica}-{shard}') ORDER BY (domain, kind) SETTINGS default_compression_codec = 'lz4', index_granularity = 8192;
+CREATE TABLE posthog.cohortpeople (
+ person_id UUID,
+ cohort_id Int64,
+ team_id Int64,
+ sign Int8,
+ version UInt64
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'cohortpeople', rand());
+CREATE TABLE posthog.events (
+ uuid UUID,
+ event String,
+ properties String,
+ timestamp DateTime64(6, 'UTC'),
+ team_id Int64,
+ distinct_id String,
+ elements_hash String,
+ created_at DateTime64(6, 'UTC'),
+ _timestamp DateTime,
+ _offset UInt64,
+ elements_chain String,
+ $group_0 String COMMENT 'column_materializer::$group_0',
+ $group_1 String COMMENT 'column_materializer::$group_1',
+ $group_2 String COMMENT 'column_materializer::$group_2',
+ $group_3 String COMMENT 'column_materializer::$group_3',
+ $group_4 String COMMENT 'column_materializer::$group_4',
+ $window_id String COMMENT 'column_materializer::$window_id',
+ $session_id String COMMENT 'column_materializer::$session_id',
+ group_0 String ALIAS `$group_0`,
+ group_1 String ALIAS `$group_1`,
+ group_2 String ALIAS `$group_2`,
+ group_3 String ALIAS `$group_3`,
+ group_4 String ALIAS `$group_4`,
+ person_id UUID,
+ person_properties String,
+ group0_properties String,
+ group1_properties String,
+ group2_properties String,
+ group3_properties String,
+ group4_properties String,
+ person_created_at DateTime64(3),
+ 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),
+ inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),
+ person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),
+ elements_chain_href String COMMENT 'column_materializer::elements_chain::href',
+ elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',
+ elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',
+ elements_chain_elements Array(Enum8('a'=1, 'button'=2, 'form'=3, 'input'=4, 'select'=5, 'textarea'=6, 'label'=7)) COMMENT 'column_materializer::elements_chain::elements',
+ properties_group_custom Map(String, String),
+ properties_group_feature_flags Map(String, String),
+ is_deleted Bool,
+ person_properties_map_custom Map(String, String),
+ mat_$ai_trace_id Nullable(String) COMMENT 'column_materializer::properties::$ai_trace_id',
+ $session_id_uuid Nullable(UInt128),
+ consumer_breadcrumbs Array(String),
+ properties_group_ai Map(String, String),
+ mat_historical_migration Nullable(String) COMMENT 'column_materializer::properties::historical_migration',
+ mat_$ai_session_id Nullable(String) COMMENT 'column_materializer::properties::$ai_session_id',
+ mat_$ai_is_error Nullable(String) COMMENT 'column_materializer::properties::$ai_is_error',
+ dmat_string_0 Nullable(String),
+ dmat_string_1 Nullable(String),
+ dmat_string_2 Nullable(String),
+ dmat_string_3 Nullable(String),
+ dmat_string_4 Nullable(String),
+ dmat_string_5 Nullable(String),
+ dmat_string_6 Nullable(String),
+ dmat_string_7 Nullable(String),
+ dmat_string_8 Nullable(String),
+ dmat_string_9 Nullable(String),
+ historical_migration Bool,
+ properties_group_ai_large Map(String, String),
+ mat_$ai_prompt_name Nullable(String) COMMENT 'column_materializer::properties::$ai_prompt_name'
+) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));
+CREATE TABLE posthog.person_distinct_id_overrides (
+ team_id Int64,
+ distinct_id String,
+ person_id UUID,
+ is_deleted Int8,
+ version Int64,
+ _timestamp DateTime,
+ _offset UInt64,
+ _partition UInt64
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_distinct_id_overrides', sipHash64(distinct_id));
+CREATE TABLE posthog.person_static_cohort (
+ id UUID,
+ person_id UUID,
+ cohort_id Int64,
+ team_id Int64,
+ _timestamp DateTime,
+ _offset UInt64
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'person_static_cohort', rand());
+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.raw_sessions (
+ team_id Int64,
+ session_id_v7 UInt128,
+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),
+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),
+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),
+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),
+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),
+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ end_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),
+ last_external_click_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),
+ initial_browser AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_browser_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_os AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_os_version AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_device_type AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_viewport_width AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),
+ initial_viewport_height AggregateFunction(argMin, Int64, DateTime64(6, 'UTC')),
+ initial_geoip_country_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_geoip_subdivision_1_code AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_geoip_subdivision_1_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_geoip_subdivision_city_name AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_geoip_time_zone AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_irclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ pageview_count SimpleAggregateFunction(sum, Int64),
+ pageview_uniq AggregateFunction(uniq, Nullable(UUID)),
+ autocapture_count SimpleAggregateFunction(sum, Int64),
+ autocapture_uniq AggregateFunction(uniq, Nullable(UUID)),
+ screen_count SimpleAggregateFunction(sum, Int64),
+ screen_uniq AggregateFunction(uniq, Nullable(UUID)),
+ maybe_has_session_replay SimpleAggregateFunction(max, Bool),
+ page_screen_autocapture_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),
+ vitals_lcp AggregateFunction(argMin, Nullable(Float64), DateTime64(6, 'UTC')),
+ initial__kx AggregateFunction(argMin, String, DateTime64(6, 'UTC'))
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.raw_sessions', '{shard}-{replica}') ORDER BY (team_id, toStartOfHour(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000))), cityHash64(session_id_v7), session_id_v7) PARTITION BY toYYYYMM(fromUnixTimestamp(intDiv(toUInt64(bitShiftRight(session_id_v7, 80)), 1000))) SAMPLE BY cityHash64(session_id_v7) SETTINGS index_granularity = 8192;
+CREATE TABLE posthog.raw_sessions_v3 (
+ team_id Int64,
+ session_id_v7 UInt128,
+ session_timestamp DateTime64(3) DEFAULT fromUnixTimestamp64Milli(toUInt64(bitShiftRight(session_id_v7, 80))),
+ distinct_id AggregateFunction(argMax, String, DateTime64(6, 'UTC')),
+ distinct_ids AggregateFunction(groupUniqArray, String),
+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),
+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),
+ max_inserted_at SimpleAggregateFunction(max, DateTime64(6, 'UTC')),
+ urls SimpleAggregateFunction(groupUniqArrayArray(2000), Array(String)),
+ entry_url AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ end_url AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC')),
+ last_external_click_url AggregateFunction(argMax, Nullable(String), DateTime64(6, 'UTC')),
+ browser AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ browser_version AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ os AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ os_version AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ device_type AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ viewport_width AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC')),
+ viewport_height AggregateFunction(argMin, Nullable(Int64), DateTime64(6, 'UTC')),
+ geoip_country_code AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ geoip_subdivision_1_code AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ geoip_subdivision_1_name AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ geoip_subdivision_city_name AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ geoip_time_zone AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ entry_referring_domain AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ entry_utm_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ entry_utm_campaign AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ entry_utm_medium AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ entry_utm_term AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ entry_utm_content AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ entry_gclid AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ entry_gad_source AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ entry_fbclid AggregateFunction(argMin, Nullable(String), DateTime64(6, 'UTC')),
+ entry_has_gclid AggregateFunction(argMin, Bool, DateTime64(6, 'UTC')),
+ entry_has_fbclid AggregateFunction(argMin, Bool, DateTime64(6, 'UTC')),
+ entry_ad_ids_map AggregateFunction(argMin, Map(String, String), DateTime64(6, 'UTC')),
+ entry_ad_ids_set AggregateFunction(argMin, Array(String), DateTime64(6, 'UTC')),
+ entry_channel_type_properties AggregateFunction(argMin, Tuple(Nullable(String), Nullable(String), Nullable(String), Nullable(String), Bool, Bool, Nullable(String)), DateTime64(6, 'UTC')),
+ pageview_uniq AggregateFunction(uniqExact, Nullable(UUID)),
+ autocapture_uniq AggregateFunction(uniqExact, Nullable(UUID)),
+ screen_uniq AggregateFunction(uniqExact, Nullable(UUID)),
+ page_screen_uniq_up_to AggregateFunction(uniqUpTo(1), Nullable(UUID)),
+ has_autocapture SimpleAggregateFunction(max, Bool),
+ flag_values AggregateFunction(groupUniqArrayMap, Map(String, String)),
+ flag_keys SimpleAggregateFunction(groupUniqArrayArray, Array(String)),
+ event_names SimpleAggregateFunction(groupUniqArrayArray, Array(String)),
+ hosts SimpleAggregateFunction(groupUniqArrayArray(100), Array(String)),
+ emails SimpleAggregateFunction(groupUniqArrayArray(10), Array(String)),
+ has_replay_events SimpleAggregateFunction(max, Bool),
+ INDEX event_names_bloom_filter event_names TYPE bloom_filter() GRANULARITY 1,
+ INDEX flag_keys_bloom_filter flag_keys TYPE bloom_filter() GRANULARITY 1
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3', '{shard}-{replica}') ORDER BY (team_id, session_timestamp, session_id_v7) PARTITION BY toYYYYMM(session_timestamp) SETTINGS index_granularity = 8192, storage_policy = 's3_tiered';
+CREATE TABLE posthog.sessions (
+ session_id String,
+ team_id Int64,
+ distinct_id SimpleAggregateFunction(any, String),
+ min_timestamp SimpleAggregateFunction(min, DateTime64(6, 'UTC')),
+ max_timestamp SimpleAggregateFunction(max, DateTime64(6, 'UTC')),
+ urls SimpleAggregateFunction(groupUniqArrayArray, Array(String)),
+ entry_url AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ exit_url AggregateFunction(argMax, String, DateTime64(6, 'UTC')),
+ initial_referring_domain AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_utm_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_utm_campaign AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_utm_medium AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_utm_term AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_utm_content AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_gclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_gad_source AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_gclsrc AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_dclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_gbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_wbraid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_fbclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_msclkid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_twclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_li_fat_id AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_mc_cid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_igshid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ initial_ttclid AggregateFunction(argMin, String, DateTime64(6, 'UTC')),
+ event_count_map SimpleAggregateFunction(sumMap, Map(String, Int64)),
+ pageview_count SimpleAggregateFunction(sum, Int64),
+ autocapture_count SimpleAggregateFunction(sum, Int64)
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.sessions', '{shard}-{replica}') ORDER BY (toStartOfDay(min_timestamp), team_id, session_id) PARTITION BY toYYYYMM(min_timestamp) SETTINGS index_granularity = 512;
+CREATE TABLE posthog.web_pre_aggregated_teams (
+ team_id UInt64,
+ enabled_by String DEFAULT 'system',
+ version UInt32 DEFAULT toUnixTimestamp(now())
+) ENGINE = Distributed('posthog_single_shard', 'posthog', 'web_pre_aggregated_teams');
+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_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 OR REPLACE DICTIONARY posthog.channel_definition_dict (`domain` String, `kind` String, `domain_type` Nullable(String), `type_if_paid` Nullable(String), `type_if_organic` Nullable(String)) PRIMARY KEY domain, kind SOURCE(CLICKHOUSE(USER 'dict_reader' TABLE 'channel_definition')) LAYOUT(COMPLEX_KEY_HASHED()) LIFETIME(MIN 3000 MAX 3600);
+CREATE OR REPLACE DICTIONARY posthog.web_pre_aggregated_teams_dict (`team_id` UInt64) PRIMARY KEY team_id SOURCE(CLICKHOUSE(USER 'dict_reader' QUERY 'SELECT team_id FROM `web_pre_aggregated_teams` FINAL WHERE version > 0')) LAYOUT(HASHED()) LIFETIME(MIN 3000 MAX 3600);
+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/local-multi/ai_events.sql b/posthog/clickhouse/hcl/sql/local-multi/ai_events.sql
index 342cf3fcccd1..1191ec992bb0 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/ai_events.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/ai_events.sql
@@ -14,7 +14,7 @@ CREATE TABLE posthog.kafka_ai_events_json (
person_properties String,
person_created_at DateTime64(3),
person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ai_events_json\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_ai_events_json';
CREATE TABLE posthog.person (
id UUID,
created_at DateTime64(3),
@@ -268,10 +268,10 @@ FROM system.query_log
WHERE type != 'QueryStart';
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -326,10 +326,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql b/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql
index f2414cad88b6..b06ee60ab77d 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/auxiliary.sql
@@ -78,7 +78,7 @@ CREATE TABLE posthog.kafka_error_tracking_fingerprint_issue_state (
first_seen DateTime64(3, 'UTC'),
is_deleted Int8,
version Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-error-tracking-fingerprint-issue-state\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_fingerprint_issue_state\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse-error-tracking-fingerprint-issue-state', kafka_topic_list = 'clickhouse_error_tracking_fingerprint_issue_state';
CREATE TABLE posthog.kafka_hog_invocation_results (
team_id Int64,
function_kind LowCardinality(String),
@@ -101,14 +101,14 @@ CREATE TABLE posthog.kafka_hog_invocation_results (
invocation_globals String,
version UInt64,
is_deleted UInt8
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';
+) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_hog_invocation_results', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_hog_invocation_results';
CREATE TABLE posthog.kafka_ingestion_warnings_v2 (
team_id Int64,
source LowCardinality(String),
type String,
details String,
timestamp DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ingestion_warnings_v2\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_ingestion_warnings_v2', kafka_topic_list = 'clickhouse_ingestion_warnings';
CREATE TABLE posthog.kafka_message_assets (
team_id Int64,
function_kind LowCardinality(String),
@@ -126,14 +126,14 @@ CREATE TABLE posthog.kafka_message_assets (
version UInt64,
is_deleted UInt8,
html String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_message_assets\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_message_assets\'';
+) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_message_assets', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_message_assets';
CREATE TABLE posthog.kafka_property_values (
team_id Int64,
property_type LowCardinality(String),
property_key String,
property_value String,
property_count UInt64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_property_values\'', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_property_values\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_property_values', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_property_values';
CREATE TABLE posthog.message_assets_data (
team_id Int64,
function_kind LowCardinality(String),
@@ -906,10 +906,10 @@ CREATE MATERIALIZED VIEW posthog.property_values_mv TO posthog.property_values (
FROM posthog.kafka_property_values;
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -964,10 +964,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/local-multi/data.sql b/posthog/clickhouse/hcl/sql/local-multi/data.sql
index b925c1afdf0a..8cd2b6e709b5 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/data.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/data.sql
@@ -366,7 +366,7 @@ CREATE TABLE posthog.kafka_events_json (
dmat_string_7 Nullable(String),
dmat_string_8 Nullable(String),
dmat_string_9 Nullable(String)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_events_json';
CREATE TABLE posthog.kafka_performance_events (
uuid UUID,
session_id String,
@@ -415,14 +415,14 @@ CREATE TABLE posthog.kafka_performance_events (
navigation_type LowCardinality(String),
unload_event_end Float64,
unload_event_start Float64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_performance_events\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_performance_events';
CREATE TABLE posthog.kafka_person_distinct_id (
distinct_id String,
person_id UUID,
team_id Int64,
_sign Nullable(Int8),
is_deleted Nullable(Int8)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_unique_id\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_person_unique_id';
CREATE TABLE posthog.kafka_person_overrides (
team_id Int32,
old_person_id UUID,
@@ -2744,10 +2744,10 @@ GROUP BY
`$session_id`, team_id;
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -2802,10 +2802,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql b/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql
index e05f949c9cc4..53fb017ec4f2 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/ingestion_events.sql
@@ -35,7 +35,7 @@ CREATE TABLE posthog.kafka_events_json_native_json (
dmat_string_7 Nullable(String),
dmat_string_8 Nullable(String),
dmat_string_9 Nullable(String)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_events_json_native_json\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_events_json_native_json', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_events_json';
CREATE TABLE posthog.kafka_logs_avro (
uuid String,
trace_id String,
@@ -54,7 +54,7 @@ CREATE TABLE posthog.kafka_logs_avro (
retention_days Nullable(Int32),
pattern Nullable(String),
pattern_version Nullable(Int32)
-) ENGINE = Kafka() SETTINGS input_format_avro_allow_missing_fields = 1, kafka_broker_list = 'warpstream_logs', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-logs-avro-new\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_logs\'';
+) ENGINE = Kafka(warpstream_logs) SETTINGS input_format_avro_allow_missing_fields = 1, kafka_format = 'Avro', kafka_group_name = 'clickhouse-logs-avro-new', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_logs';
CREATE TABLE posthog.query_log_archive (
hostname LowCardinality(String),
user LowCardinality(String),
diff --git a/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sql b/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sql
index b396f20b55b0..2a4f46655d5f 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/ingestion_medium.sql
@@ -10,7 +10,7 @@ CREATE TABLE posthog.kafka_app_metrics2 (
metric_kind String,
metric_name String,
count Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics2\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_app_metrics2';
CREATE TABLE posthog.kafka_app_metrics2_ws (
team_id Int64,
timestamp DateTime64(6, 'UTC'),
@@ -20,19 +20,19 @@ CREATE TABLE posthog.kafka_app_metrics2_ws (
metric_kind String,
metric_name String,
count Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_app_metrics2_ws\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics2\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_app_metrics2_ws', kafka_topic_list = 'clickhouse_app_metrics2';
CREATE TABLE posthog.kafka_cohort_membership (
team_id Int64,
cohort_id Int64,
person_id UUID,
status Enum8('entered'=1, 'left'=2, 'member'=3, 'not_member'=4),
last_updated DateTime64(6)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_cohort_membership_changed\'', kafka_topic_list = 'kafka_topic_list = \'cohort_membership_changed\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_cohort_membership_changed', kafka_topic_list = 'cohort_membership_changed';
CREATE TABLE posthog.kafka_distinct_id_usage (
team_id Int64,
distinct_id String,
timestamp DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_distinct_id_usage\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'distinct_id_usage_events_json\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_distinct_id_usage', kafka_skip_broken_messages = 100, kafka_topic_list = 'distinct_id_usage_events_json';
CREATE TABLE posthog.kafka_flag_evaluations (
uuid UUID,
event LowCardinality(String),
@@ -49,7 +49,7 @@ CREATE TABLE posthog.kafka_flag_evaluations (
group3_properties String,
group4_properties String,
inserted_at DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_flag_evaluations\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_flag_evaluations\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_flag_evaluations', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_flag_evaluations';
CREATE TABLE posthog.kafka_heatmaps (
session_id String,
team_id Int64,
@@ -63,7 +63,7 @@ CREATE TABLE posthog.kafka_heatmaps (
pointer_target_fixed Bool,
current_url String,
type LowCardinality(String)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_heatmap_events\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_heatmap_events';
CREATE TABLE posthog.kafka_precalculated_events (
team_id Int64,
date Nullable(Date),
@@ -72,7 +72,7 @@ CREATE TABLE posthog.kafka_precalculated_events (
condition String,
uuid UUID,
source String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_prefiltered_events\'', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_prefiltered_events\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_flush_interval_ms = 7500, kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_prefiltered_events', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_prefiltered_events';
CREATE TABLE posthog.kafka_precalculated_person_properties (
team_id Int64,
distinct_id String,
@@ -80,7 +80,7 @@ CREATE TABLE posthog.kafka_precalculated_person_properties (
condition String,
matches Bool,
source String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_precalculated_person_properties\'', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_precalculated_person_properties\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_flush_interval_ms = 7500, kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_precalculated_person_properties', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_precalculated_person_properties';
CREATE TABLE posthog.kafka_session_replay_features (
session_id String,
team_id Int64,
@@ -151,7 +151,7 @@ CREATE TABLE posthog.kafka_session_replay_features (
text_selection_count Int64,
selection_copy_count Int64,
is_deleted UInt8
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_session_replay_features\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_session_replay_features';
CREATE TABLE posthog.kafka_tophog (
timestamp DateTime64(6, 'UTC'),
metric LowCardinality(String),
@@ -162,7 +162,7 @@ CREATE TABLE posthog.kafka_tophog (
pipeline LowCardinality(String),
lane LowCardinality(String),
labels Map(LowCardinality(String), String)
-) ENGINE = Kafka() SETTINGS date_time_input_format = 'best_effort', kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_tophog\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_tophog\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS date_time_input_format = 'best_effort', kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_tophog', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_tophog';
CREATE TABLE posthog.kafka_tophog_ws (
timestamp DateTime64(6, 'UTC'),
metric LowCardinality(String),
@@ -173,7 +173,7 @@ CREATE TABLE posthog.kafka_tophog_ws (
pipeline LowCardinality(String),
lane LowCardinality(String),
labels Map(LowCardinality(String), String)
-) ENGINE = Kafka() SETTINGS date_time_input_format = 'best_effort', kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_tophog_ws\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_tophog\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS date_time_input_format = 'best_effort', kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_tophog_ws', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_tophog';
CREATE TABLE posthog.query_log_archive (
hostname LowCardinality(String),
user LowCardinality(String),
diff --git a/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sql b/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sql
index 8b535e3b8b2e..727f0cd660c8 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/ingestion_small.sql
@@ -13,7 +13,7 @@ CREATE TABLE posthog.kafka_app_metrics (
error_uuid UUID,
error_type String,
error_details String CODEC(ZSTD(3))
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_app_metrics';
CREATE TABLE posthog.kafka_billing_usage_records (
schema_version UInt8,
record_id String,
@@ -25,7 +25,7 @@ CREATE TABLE posthog.kafka_billing_usage_records (
quantity Int64,
timestamp DateTime64(6, 'UTC'),
inserted_at DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS date_time_input_format = 'best_effort', kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_billing_usage_records\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_billing_usage_records\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS date_time_input_format = 'best_effort', kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_billing_usage_records', kafka_topic_list = 'clickhouse_billing_usage_records';
CREATE TABLE posthog.kafka_duplicate_events (
team_id Int64,
distinct_id String,
@@ -43,7 +43,7 @@ CREATE TABLE posthog.kafka_duplicate_events (
duplicate_message String,
distinct_fields String,
inserted_at DateTime64(3, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_duplicate_events\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_events_duplicates\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_duplicate_events', kafka_topic_list = 'clickhouse_ingestion_events_duplicates';
CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_embeddings (
team_id Int64,
model_name LowCardinality(String),
@@ -51,14 +51,14 @@ CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_embeddings (
fingerprint String,
inserted_at DateTime64(3, 'UTC'),
embeddings Array(Float64)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_error_tracking_fingerprint_embeddings\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_issue_fingerprint_embeddings\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_error_tracking_fingerprint_embeddings', kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint_embeddings';
CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_overrides (
team_id Int64,
fingerprint String,
issue_id UUID,
is_deleted Int8,
version Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-error-tracking-issue-fingerprint-overrides\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_issue_fingerprint\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse-error-tracking-issue-fingerprint-overrides', kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint';
CREATE TABLE posthog.kafka_events_dead_letter_queue (
id UUID,
event_uuid UUID,
@@ -76,21 +76,21 @@ CREATE TABLE posthog.kafka_events_dead_letter_queue (
error_location String,
error String,
tags Array(String)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_skip_broken_messages = 1000, kafka_topic_list = 'kafka_topic_list = \'events_dead_letter_queue\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_skip_broken_messages = 1000, kafka_topic_list = 'events_dead_letter_queue';
CREATE TABLE posthog.kafka_groups (
group_type_index UInt8,
group_key String,
created_at DateTime64(3),
team_id Int64,
group_properties String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_groups\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_groups';
CREATE TABLE posthog.kafka_ingestion_warnings (
team_id Int64,
source LowCardinality(String),
type String,
details String CODEC(ZSTD(3)),
timestamp DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_ingestion_warnings';
CREATE TABLE posthog.kafka_log_entries_v3 (
team_id UInt64,
log_source LowCardinality(String),
@@ -99,7 +99,7 @@ CREATE TABLE posthog.kafka_log_entries_v3 (
timestamp DateTime64(6, 'UTC'),
level LowCardinality(String),
message String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_log_entries\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'log_entries\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_log_entries', kafka_skip_broken_messages = 100, kafka_topic_list = 'log_entries';
CREATE TABLE posthog.kafka_log_entries_ws (
team_id UInt64,
log_source LowCardinality(String),
@@ -108,7 +108,7 @@ CREATE TABLE posthog.kafka_log_entries_ws (
timestamp DateTime64(6, 'UTC'),
level LowCardinality(String),
message String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_log_entries_ws\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'log_entries\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_log_entries_ws', kafka_skip_broken_messages = 100, kafka_topic_list = 'log_entries';
CREATE TABLE posthog.kafka_person (
id UUID,
created_at DateTime64(3),
@@ -118,21 +118,21 @@ CREATE TABLE posthog.kafka_person (
is_deleted Int8,
version UInt64,
last_seen_at Nullable(DateTime64(3))
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_person';
CREATE TABLE posthog.kafka_person_distinct_id2 (
team_id Int64,
distinct_id String,
person_id UUID,
is_deleted Int8,
version Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_distinct_id\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_person_distinct_id';
CREATE TABLE posthog.kafka_person_distinct_id_overrides (
team_id Int64,
distinct_id String,
person_id UUID,
is_deleted Int8,
version Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-person-distinct-id-overrides\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_distinct_id\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse-person-distinct-id-overrides', kafka_topic_list = 'clickhouse_person_distinct_id';
CREATE TABLE posthog.kafka_plugin_log_entries (
id UUID,
team_id Int64,
@@ -143,7 +143,7 @@ CREATE TABLE posthog.kafka_plugin_log_entries (
type String,
message String,
instance_id UUID
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'plugin_log_entries\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'plugin_log_entries';
CREATE TABLE posthog.kafka_posthog_document_embeddings (
team_id Int64,
product LowCardinality(String),
@@ -156,7 +156,7 @@ CREATE TABLE posthog.kafka_posthog_document_embeddings (
content String,
metadata String,
embedding Array(Float64)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_document_embeddings\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_document_embeddings\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_document_embeddings', kafka_topic_list = 'clickhouse_document_embeddings';
CREATE TABLE posthog.kafka_session_replay_events (
session_id String,
team_id Int64,
@@ -184,7 +184,7 @@ CREATE TABLE posthog.kafka_session_replay_events (
ai_tags_freeform Array(String),
ai_highlighted UInt8,
surfacing_score Nullable(Float32)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_session_replay_events\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_session_replay_events';
CREATE TABLE posthog.kafka_usage_report_events_preagg (
uuid UUID,
event String,
@@ -193,7 +193,7 @@ CREATE TABLE posthog.kafka_usage_report_events_preagg (
team_id Int64,
distinct_id String,
person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_usage_report_events_preagg\'', kafka_num_consumers = 1, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_usage_report_events_preagg', kafka_num_consumers = 1, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_events_json';
CREATE TABLE posthog.query_log_archive (
hostname LowCardinality(String),
user LowCardinality(String),
diff --git a/posthog/clickhouse/hcl/sql/local-multi/logs.sql b/posthog/clickhouse/hcl/sql/local-multi/logs.sql
index db3c0df6770e..86e506e0d9b1 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/logs.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/logs.sql
@@ -22,7 +22,7 @@ CREATE TABLE posthog.kafka_metrics_avro (
instrumentation_scope Nullable(String),
attributes Map(String, String),
series_fingerprint Nullable(Int64)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_metrics', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-metrics-avro-new\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_metrics\'';
+) ENGINE = Kafka(warpstream_metrics) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-metrics-avro-new', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_metrics';
CREATE TABLE posthog.kafka_trace_spans_avro (
uuid String,
trace_id String,
@@ -45,7 +45,7 @@ CREATE TABLE posthog.kafka_trace_spans_avro (
links Array(String),
dropped_links_count Int32,
status_code Int32
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_traces', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-traces-avro\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_traces\'';
+) ENGINE = Kafka(warpstream_traces) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-traces-avro', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_traces';
CREATE TABLE posthog.log_attributes (
team_id Int32 CODEC(DoubleDelta, ZSTD(1)),
time_bucket DateTime64(0) CODEC(DoubleDelta, ZSTD(1)),
diff --git a/posthog/clickhouse/hcl/sql/local-multi/ops.sql b/posthog/clickhouse/hcl/sql/local-multi/ops.sql
index 08cd0a04811b..fda25f6d31ea 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/ops.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/ops.sql
@@ -114,10 +114,10 @@ CREATE TABLE posthog.sharded_query_log_archive (
) 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 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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -172,10 +172,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/local-multi/sessions.sql b/posthog/clickhouse/hcl/sql/local-multi/sessions.sql
index d3e79a04c21d..402526528ef8 100644
--- a/posthog/clickhouse/hcl/sql/local-multi/sessions.sql
+++ b/posthog/clickhouse/hcl/sql/local-multi/sessions.sql
@@ -165,10 +165,10 @@ FROM system.query_log
WHERE type != 'QueryStart';
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -223,10 +223,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/local-single/all.sql b/posthog/clickhouse/hcl/sql/local-single/all.sql
index 65c66268443a..33a1d23428fd 100644
--- a/posthog/clickhouse/hcl/sql/local-single/all.sql
+++ b/posthog/clickhouse/hcl/sql/local-single/all.sql
@@ -271,7 +271,7 @@ CREATE TABLE posthog.kafka_ai_events_json (
person_properties String,
person_created_at DateTime64(3),
person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ai_events_json\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_ai_events_json';
CREATE TABLE posthog.kafka_app_metrics (
team_id Int64,
timestamp DateTime64(6, 'UTC'),
@@ -284,7 +284,7 @@ CREATE TABLE posthog.kafka_app_metrics (
error_uuid UUID,
error_type String,
error_details String CODEC(ZSTD(3))
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_app_metrics';
CREATE TABLE posthog.kafka_app_metrics2 (
team_id Int64,
timestamp DateTime64(6, 'UTC'),
@@ -294,7 +294,7 @@ CREATE TABLE posthog.kafka_app_metrics2 (
metric_kind String,
metric_name String,
count Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics2\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_app_metrics2';
CREATE TABLE posthog.kafka_app_metrics2_ws (
team_id Int64,
timestamp DateTime64(6, 'UTC'),
@@ -304,7 +304,7 @@ CREATE TABLE posthog.kafka_app_metrics2_ws (
metric_kind String,
metric_name String,
count Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_app_metrics2_ws\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_app_metrics2\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_app_metrics2_ws', kafka_topic_list = 'clickhouse_app_metrics2';
CREATE TABLE posthog.kafka_billing_usage_records (
schema_version UInt8,
record_id String,
@@ -316,19 +316,19 @@ CREATE TABLE posthog.kafka_billing_usage_records (
quantity Int64,
timestamp DateTime64(6, 'UTC'),
inserted_at DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS date_time_input_format = 'best_effort', kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_billing_usage_records\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_billing_usage_records\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS date_time_input_format = 'best_effort', kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_billing_usage_records', kafka_topic_list = 'clickhouse_billing_usage_records';
CREATE TABLE posthog.kafka_cohort_membership (
team_id Int64,
cohort_id Int64,
person_id UUID,
status Enum8('entered'=1, 'left'=2, 'member'=3, 'not_member'=4),
last_updated DateTime64(6)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_cohort_membership_changed\'', kafka_topic_list = 'kafka_topic_list = \'cohort_membership_changed\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_cohort_membership_changed', kafka_topic_list = 'cohort_membership_changed';
CREATE TABLE posthog.kafka_distinct_id_usage (
team_id Int64,
distinct_id String,
timestamp DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_distinct_id_usage\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'distinct_id_usage_events_json\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_distinct_id_usage', kafka_skip_broken_messages = 100, kafka_topic_list = 'distinct_id_usage_events_json';
CREATE TABLE posthog.kafka_duplicate_events (
team_id Int64,
distinct_id String,
@@ -346,7 +346,7 @@ CREATE TABLE posthog.kafka_duplicate_events (
duplicate_message String,
distinct_fields String,
inserted_at DateTime64(3, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_duplicate_events\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_events_duplicates\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_duplicate_events', kafka_topic_list = 'clickhouse_ingestion_events_duplicates';
CREATE TABLE posthog.kafka_error_tracking_fingerprint_issue_state (
team_id Int64,
fingerprint String,
@@ -360,7 +360,7 @@ CREATE TABLE posthog.kafka_error_tracking_fingerprint_issue_state (
first_seen DateTime64(3, 'UTC'),
is_deleted Int8,
version Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-error-tracking-fingerprint-issue-state\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_fingerprint_issue_state\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse-error-tracking-fingerprint-issue-state', kafka_topic_list = 'clickhouse_error_tracking_fingerprint_issue_state';
CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_embeddings (
team_id Int64,
model_name LowCardinality(String),
@@ -368,14 +368,14 @@ CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_embeddings (
fingerprint String,
inserted_at DateTime64(3, 'UTC'),
embeddings Array(Float64)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_error_tracking_fingerprint_embeddings\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_issue_fingerprint_embeddings\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_error_tracking_fingerprint_embeddings', kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint_embeddings';
CREATE TABLE posthog.kafka_error_tracking_issue_fingerprint_overrides (
team_id Int64,
fingerprint String,
issue_id UUID,
is_deleted Int8,
version Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-error-tracking-issue-fingerprint-overrides\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_error_tracking_issue_fingerprint\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse-error-tracking-issue-fingerprint-overrides', kafka_topic_list = 'clickhouse_error_tracking_issue_fingerprint';
CREATE TABLE posthog.kafka_events_dead_letter_queue (
id UUID,
event_uuid UUID,
@@ -393,7 +393,7 @@ CREATE TABLE posthog.kafka_events_dead_letter_queue (
error_location String,
error String,
tags Array(String)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_skip_broken_messages = 1000, kafka_topic_list = 'kafka_topic_list = \'events_dead_letter_queue\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_skip_broken_messages = 1000, kafka_topic_list = 'events_dead_letter_queue';
CREATE TABLE posthog.kafka_events_json (
uuid UUID,
event String,
@@ -428,7 +428,7 @@ CREATE TABLE posthog.kafka_events_json (
dmat_string_7 Nullable(String),
dmat_string_8 Nullable(String),
dmat_string_9 Nullable(String)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_events_json';
CREATE TABLE posthog.kafka_events_json_native_json (
uuid UUID,
event String,
@@ -463,7 +463,7 @@ CREATE TABLE posthog.kafka_events_json_native_json (
dmat_string_7 Nullable(String),
dmat_string_8 Nullable(String),
dmat_string_9 Nullable(String)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_events_json_native_json\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_events_json_native_json', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_events_json';
CREATE TABLE posthog.kafka_flag_evaluations (
uuid UUID,
event LowCardinality(String),
@@ -480,14 +480,14 @@ CREATE TABLE posthog.kafka_flag_evaluations (
group3_properties String,
group4_properties String,
inserted_at DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_flag_evaluations\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_flag_evaluations\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_flag_evaluations', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_flag_evaluations';
CREATE TABLE posthog.kafka_groups (
group_type_index UInt8,
group_key String,
created_at DateTime64(3),
team_id Int64,
group_properties String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_groups\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_groups';
CREATE TABLE posthog.kafka_heatmaps (
session_id String,
team_id Int64,
@@ -501,7 +501,7 @@ CREATE TABLE posthog.kafka_heatmaps (
pointer_target_fixed Bool,
current_url String,
type LowCardinality(String)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_heatmap_events\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_heatmap_events';
CREATE TABLE posthog.kafka_hog_invocation_results (
team_id Int64,
function_kind LowCardinality(String),
@@ -524,21 +524,21 @@ CREATE TABLE posthog.kafka_hog_invocation_results (
invocation_globals String,
version UInt64,
is_deleted UInt8
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';
+) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_hog_invocation_results', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_hog_invocation_results';
CREATE TABLE posthog.kafka_ingestion_warnings (
team_id Int64,
source LowCardinality(String),
type String,
details String CODEC(ZSTD(3)),
timestamp DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_ingestion_warnings';
CREATE TABLE posthog.kafka_ingestion_warnings_v2 (
team_id Int64,
source LowCardinality(String),
type String,
details String,
timestamp DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ingestion_warnings_v2\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_ingestion_warnings_v2', kafka_topic_list = 'clickhouse_ingestion_warnings';
CREATE TABLE posthog.kafka_log_entries_v3 (
team_id UInt64,
log_source LowCardinality(String),
@@ -547,7 +547,7 @@ CREATE TABLE posthog.kafka_log_entries_v3 (
timestamp DateTime64(6, 'UTC'),
level LowCardinality(String),
message String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_log_entries\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'log_entries\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_log_entries', kafka_skip_broken_messages = 100, kafka_topic_list = 'log_entries';
CREATE TABLE posthog.kafka_log_entries_ws (
team_id UInt64,
log_source LowCardinality(String),
@@ -556,7 +556,7 @@ CREATE TABLE posthog.kafka_log_entries_ws (
timestamp DateTime64(6, 'UTC'),
level LowCardinality(String),
message String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_log_entries_ws\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'log_entries\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_log_entries_ws', kafka_skip_broken_messages = 100, kafka_topic_list = 'log_entries';
CREATE TABLE posthog.kafka_logs_avro (
uuid String,
trace_id String,
@@ -575,7 +575,7 @@ CREATE TABLE posthog.kafka_logs_avro (
retention_days Nullable(Int32),
pattern Nullable(String),
pattern_version Nullable(Int32)
-) ENGINE = Kafka() SETTINGS input_format_avro_allow_missing_fields = 1, kafka_broker_list = 'warpstream_logs', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-logs-avro-new\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_logs\'';
+) ENGINE = Kafka(warpstream_logs) SETTINGS input_format_avro_allow_missing_fields = 1, kafka_format = 'Avro', kafka_group_name = 'clickhouse-logs-avro-new', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_logs';
CREATE TABLE posthog.kafka_message_assets (
team_id Int64,
function_kind LowCardinality(String),
@@ -593,7 +593,7 @@ CREATE TABLE posthog.kafka_message_assets (
version UInt64,
is_deleted UInt8,
html String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_message_assets\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_message_assets\'';
+) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_message_assets', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_message_assets';
CREATE TABLE posthog.kafka_metrics_avro (
uuid String,
trace_id String,
@@ -615,7 +615,7 @@ CREATE TABLE posthog.kafka_metrics_avro (
instrumentation_scope Nullable(String),
attributes Map(String, String),
series_fingerprint Nullable(Int64)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_metrics', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-metrics-avro-new\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_metrics\'';
+) ENGINE = Kafka(warpstream_metrics) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-metrics-avro-new', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_metrics';
CREATE TABLE posthog.kafka_performance_events (
uuid UUID,
session_id String,
@@ -664,7 +664,7 @@ CREATE TABLE posthog.kafka_performance_events (
navigation_type LowCardinality(String),
unload_event_end Float64,
unload_event_start Float64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_performance_events\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_performance_events';
CREATE TABLE posthog.kafka_person (
id UUID,
created_at DateTime64(3),
@@ -674,28 +674,28 @@ CREATE TABLE posthog.kafka_person (
is_deleted Int8,
version UInt64,
last_seen_at Nullable(DateTime64(3))
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_person';
CREATE TABLE posthog.kafka_person_distinct_id (
distinct_id String,
person_id UUID,
team_id Int64,
_sign Nullable(Int8),
is_deleted Nullable(Int8)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_unique_id\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_person_unique_id';
CREATE TABLE posthog.kafka_person_distinct_id2 (
team_id Int64,
distinct_id String,
person_id UUID,
is_deleted Int8,
version Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_distinct_id\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_person_distinct_id';
CREATE TABLE posthog.kafka_person_distinct_id_overrides (
team_id Int64,
distinct_id String,
person_id UUID,
is_deleted Int8,
version Int64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse-person-distinct-id-overrides\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_person_distinct_id\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse-person-distinct-id-overrides', kafka_topic_list = 'clickhouse_person_distinct_id';
CREATE TABLE posthog.kafka_person_overrides (
team_id Int32,
old_person_id UUID,
@@ -714,7 +714,7 @@ CREATE TABLE posthog.kafka_plugin_log_entries (
type String,
message String,
instance_id UUID
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'plugin_log_entries\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'plugin_log_entries';
CREATE TABLE posthog.kafka_posthog_document_embeddings (
team_id Int64,
product LowCardinality(String),
@@ -727,7 +727,7 @@ CREATE TABLE posthog.kafka_posthog_document_embeddings (
content String,
metadata String,
embedding Array(Float64)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_document_embeddings\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_document_embeddings\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_document_embeddings', kafka_topic_list = 'clickhouse_document_embeddings';
CREATE TABLE posthog.kafka_precalculated_events (
team_id Int64,
date Nullable(Date),
@@ -736,7 +736,7 @@ CREATE TABLE posthog.kafka_precalculated_events (
condition String,
uuid UUID,
source String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_prefiltered_events\'', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_prefiltered_events\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_flush_interval_ms = 7500, kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_prefiltered_events', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_prefiltered_events';
CREATE TABLE posthog.kafka_precalculated_person_properties (
team_id Int64,
distinct_id String,
@@ -744,14 +744,14 @@ CREATE TABLE posthog.kafka_precalculated_person_properties (
condition String,
matches Bool,
source String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_flush_interval_ms = 7500, kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_precalculated_person_properties\'', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_precalculated_person_properties\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_flush_interval_ms = 7500, kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_precalculated_person_properties', kafka_max_block_size = 1000000, kafka_num_consumers = 1, kafka_poll_max_batch_size = 100000, kafka_poll_timeout_ms = 1000, kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_precalculated_person_properties';
CREATE TABLE posthog.kafka_property_values (
team_id Int64,
property_type LowCardinality(String),
property_key String,
property_value String,
property_count UInt64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_property_values\'', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_property_values\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_property_values', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_property_values';
CREATE TABLE posthog.kafka_session_replay_events (
session_id String,
team_id Int64,
@@ -779,7 +779,7 @@ CREATE TABLE posthog.kafka_session_replay_events (
ai_tags_freeform Array(String),
ai_highlighted UInt8,
surfacing_score Nullable(Float32)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_session_replay_events\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_session_replay_events';
CREATE TABLE posthog.kafka_session_replay_features (
session_id String,
team_id Int64,
@@ -850,7 +850,7 @@ CREATE TABLE posthog.kafka_session_replay_features (
text_selection_count Int64,
selection_copy_count Int64,
is_deleted UInt8
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'group1\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_session_replay_features\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'group1', kafka_topic_list = 'clickhouse_session_replay_features';
CREATE TABLE posthog.kafka_tophog (
timestamp DateTime64(6, 'UTC'),
metric LowCardinality(String),
@@ -861,7 +861,7 @@ CREATE TABLE posthog.kafka_tophog (
pipeline LowCardinality(String),
lane LowCardinality(String),
labels Map(LowCardinality(String), String)
-) ENGINE = Kafka() SETTINGS date_time_input_format = 'best_effort', kafka_broker_list = 'msk_cluster', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_tophog\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_tophog\'';
+) ENGINE = Kafka(msk_cluster) SETTINGS date_time_input_format = 'best_effort', kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_tophog', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_tophog';
CREATE TABLE posthog.kafka_tophog_ws (
timestamp DateTime64(6, 'UTC'),
metric LowCardinality(String),
@@ -872,7 +872,7 @@ CREATE TABLE posthog.kafka_tophog_ws (
pipeline LowCardinality(String),
lane LowCardinality(String),
labels Map(LowCardinality(String), String)
-) ENGINE = Kafka() SETTINGS date_time_input_format = 'best_effort', kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_tophog_ws\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_tophog\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS date_time_input_format = 'best_effort', kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_tophog_ws', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_tophog';
CREATE TABLE posthog.kafka_trace_spans_avro (
uuid String,
trace_id String,
@@ -895,7 +895,7 @@ CREATE TABLE posthog.kafka_trace_spans_avro (
links Array(String),
dropped_links_count Int32,
status_code Int32
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_traces', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-traces-avro\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_traces\'';
+) ENGINE = Kafka(warpstream_traces) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-traces-avro', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_traces';
CREATE TABLE posthog.kafka_usage_report_events_preagg (
uuid UUID,
event String,
@@ -904,7 +904,7 @@ CREATE TABLE posthog.kafka_usage_report_events_preagg (
team_id Int64,
distinct_id String,
person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_usage_report_events_preagg\'', kafka_num_consumers = 1, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_events_json\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_usage_report_events_preagg', kafka_num_consumers = 1, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_events_json';
CREATE TABLE posthog.llma_metrics_daily (
date Date,
team_id UInt64,
@@ -5478,10 +5478,10 @@ GROUP BY
date, team_id, person_mode, lib, event;
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -5536,10 +5536,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/prod-eu/ai_events.sql b/posthog/clickhouse/hcl/sql/prod-eu/ai_events.sql
index dfa2f3cbfe39..5f219f9fb3c6 100644
--- a/posthog/clickhouse/hcl/sql/prod-eu/ai_events.sql
+++ b/posthog/clickhouse/hcl/sql/prod-eu/ai_events.sql
@@ -86,7 +86,7 @@ CREATE TABLE posthog.kafka_ai_events_json_ws (
person_properties String,
person_created_at DateTime64(3),
person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ai_events_ws\'', kafka_max_block_size = 5000, kafka_num_consumers = 16, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_ai_events_json\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_ai_events_ws', kafka_max_block_size = 5000, kafka_num_consumers = 16, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_ai_events_json';
CREATE TABLE posthog.person (
id UUID,
created_at DateTime64(3),
@@ -341,10 +341,10 @@ FROM system.query_log
WHERE type != 'QueryStart';
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -399,10 +399,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql b/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql
index ac7937f00dbc..b8a095ef8ec5 100644
--- a/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql
+++ b/posthog/clickhouse/hcl/sql/prod-eu/auxiliary.sql
@@ -87,14 +87,14 @@ CREATE TABLE posthog.kafka_hog_invocation_results (
invocation_globals String,
version UInt64,
is_deleted UInt8
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';
+) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_hog_invocation_results', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_hog_invocation_results';
CREATE TABLE posthog.kafka_ingestion_warnings_v2 (
team_id Int64,
source LowCardinality(String),
type String,
details String,
timestamp DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ingestion_warnings_v2\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_ingestion_warnings_v2', kafka_topic_list = 'clickhouse_ingestion_warnings';
CREATE TABLE posthog.kafka_message_assets (
team_id Int64,
function_kind LowCardinality(String),
@@ -112,14 +112,14 @@ CREATE TABLE posthog.kafka_message_assets (
version UInt64,
is_deleted UInt8,
html String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_message_assets\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_message_assets\'';
+) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_message_assets', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_message_assets';
CREATE TABLE posthog.kafka_property_values (
team_id Int64,
property_type LowCardinality(String),
property_key String,
property_value String,
property_count UInt64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_property_values\'', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_property_values\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_property_values', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_property_values';
CREATE TABLE posthog.message_assets_data (
team_id Int64,
function_kind LowCardinality(String),
@@ -885,10 +885,10 @@ CREATE MATERIALIZED VIEW posthog.property_values_mv TO posthog.property_values (
FROM posthog.kafka_property_values;
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -943,10 +943,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/prod-eu/batch_exports.sql b/posthog/clickhouse/hcl/sql/prod-eu/batch_exports.sql
index 36b2c10b91f0..eb14568af8bd 100644
--- a/posthog/clickhouse/hcl/sql/prod-eu/batch_exports.sql
+++ b/posthog/clickhouse/hcl/sql/prod-eu/batch_exports.sql
@@ -193,10 +193,10 @@ FROM system.query_log
WHERE type != 'QueryStart';
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -251,10 +251,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql b/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
index 5561cff3604b..b98b07397375 100644
--- a/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
+++ b/posthog/clickhouse/hcl/sql/prod-eu/logs.sql
@@ -22,7 +22,7 @@ CREATE TABLE posthog.kafka_metrics_avro (
instrumentation_scope Nullable(String),
attributes Map(String, String),
series_fingerprint Nullable(Int64)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_metrics', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-metrics-avro-new\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_metrics\'';
+) ENGINE = Kafka(warpstream_metrics) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-metrics-avro-new', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_metrics';
CREATE TABLE posthog.kafka_trace_spans_avro (
uuid String,
trace_id String,
@@ -45,7 +45,7 @@ CREATE TABLE posthog.kafka_trace_spans_avro (
links Array(String),
dropped_links_count Int32,
status_code Int32
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_traces', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-traces-avro\'', kafka_num_consumers = 2, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_traces\'';
+) ENGINE = Kafka(warpstream_traces) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-traces-avro', kafka_num_consumers = 2, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_traces';
CREATE TABLE posthog.log_attributes2 (
team_id Int32,
time_bucket DateTime64(0),
@@ -1116,10 +1116,10 @@ GROUP BY
_partition, _topic;
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -1174,10 +1174,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/prod-eu/ops.sql b/posthog/clickhouse/hcl/sql/prod-eu/ops.sql
new file mode 100644
index 000000000000..4753d9aa5b78
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/prod-eu/ops.sql
@@ -0,0 +1,624 @@
+-- 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.event_property_daily_stats (
+ analysis_date Date,
+ team_id Int64,
+ property_key String,
+ event_count UInt64,
+ distinct_event_names UInt32,
+ total_property_bytes UInt64,
+ min_property_bytes UInt64,
+ max_property_bytes UInt64,
+ avg_property_bytes Float64,
+ p50_property_bytes Float64,
+ p90_property_bytes Float64,
+ p95_property_bytes Float64,
+ p99_property_bytes Float64,
+ property_size_histogram Array(Tuple(Float64, Float64, UInt64)),
+ top_event_names Array(String),
+ sample_rate Float32,
+ computed_at DateTime
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.event_property_daily_stats', '{replica}') ORDER BY (analysis_date, team_id, property_key) TTL analysis_date + toIntervalDay(30) SETTINGS index_granularity = 8192;
+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,
+ PROJECTION by_label_value (SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, label_name, label_value, id, metric_name),
+ PROJECTION by_id_label (SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, id, label_name, metric_name, label_value)
+) 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 CODEC(T64, Default),
+ metric_name LowCardinality(String),
+ timestamp DateTime64(3, 'UTC') CODEC(DoubleDelta, Default),
+ id UInt64,
+ value Float64 CODEC(Gorilla(8), Default)
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_samples_new', '{replica}') ORDER BY (team_id, metric_name, toStartOfTenMinutes(timestamp), id, timestamp) PARTITION BY toYYYYMMDD(timestamp) SETTINGS index_granularity = 8192;
+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'),
+ PROJECTION by_id (SELECT team_id, id, metric_name, labels_json, min_time, max_time
+ORDER BY team_id, id)
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_series', '{replica}') ORDER BY (team_id, metric_name, id) SETTINGS index_granularity = 1024;
+CREATE TABLE posthog.query_team_daily_stats (
+ analysis_date Date,
+ team_id Int64,
+ query_count UInt64,
+ error_count UInt64,
+ distinct_query_shapes UInt64,
+ total_duration_ms UInt64,
+ avg_duration_ms Float64,
+ p50_duration_ms Float64,
+ p90_duration_ms Float64,
+ p99_duration_ms Float64,
+ max_duration_ms UInt64,
+ total_read_rows UInt64,
+ total_read_bytes UInt64 COMMENT 'Uncompressed bytes scanned, coordinator-side summed across shards (is_initial_query=1). Compute/scan cost proxy, NOT stored footprint.',
+ total_result_rows UInt64,
+ total_result_bytes UInt64,
+ total_written_rows UInt64,
+ total_written_bytes UInt64,
+ total_cpu_seconds Float64 COMMENT 'ProfileEvents OSCPUVirtualTimeMicroseconds summed across ALL QueryFinish rows (initiator + shard leaves) / 1e6. CPU is not folded onto the initiator row, so leaves must be summed.',
+ total_memory_usage UInt64 COMMENT 'Peak memory_usage summed across all shard rows (per-node peak; not folded onto the initiator).',
+ max_memory_usage UInt64 COMMENT 'Largest single-node peak memory across all shard rows.',
+ p99_memory_usage Float64,
+ total_s3_get_objects UInt64 COMMENT 'ProfileEvents S3GetObject summed across all shard rows: object-storage GET count.',
+ total_s3_read_bytes UInt64 COMMENT 'ProfileEvents ReadBufferFromS3Bytes summed across all shard rows: object-storage read cost proxy.',
+ query_kind_counts Map(String, UInt64) COMMENT 'query_kind -> count for QueryFinish rows.',
+ computed_at DateTime
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.query_team_daily_stats', '{replica}') ORDER BY (analysis_date, team_id) TTL analysis_date + toIntervalDay(90) 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, max_replicated_merges_in_queue = 6, object_serialization_version = 'v3', object_shared_data_serialization_version = 'map_with_buckets', parts_to_delay_insert = 1000, parts_to_throw_insert = 3000, prefer_fetch_merged_part_size_threshold = 1, prefer_fetch_merged_part_time_threshold = 60;
+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-eu/sessions.sql b/posthog/clickhouse/hcl/sql/prod-eu/sessions.sql
index 5d3a586c2097..77d8b66eb183 100644
--- a/posthog/clickhouse/hcl/sql/prod-eu/sessions.sql
+++ b/posthog/clickhouse/hcl/sql/prod-eu/sessions.sql
@@ -27,95 +27,18 @@ CREATE TABLE posthog.events (
_timestamp DateTime,
_offset UInt64,
elements_chain String,
- mat_$user_id String COMMENT 'column_materializer::$user_id',
- mat_$browser String COMMENT 'column_materializer::$browser',
- mat_$host String COMMENT 'column_materializer::$host',
- mat_$current_url String COMMENT 'column_materializer::$current_url',
- mat_distinct_id String COMMENT 'column_materializer::distinct_id',
- mat_action String COMMENT 'column_materializer::action',
- mat_origin String COMMENT 'column_materializer::origin',
- mat_email String COMMENT 'column_materializer::email',
- mat_key String COMMENT 'column_materializer::key',
- mat_insight String COMMENT 'column_materializer::insight',
- mat_$event_type String COMMENT 'column_materializer::$event_type',
- mat_created_by String COMMENT 'column_materializer::created_by',
- mat_total_event_actions_count String COMMENT 'column_materializer::total_event_actions_count',
- mat_is_demo_project String COMMENT 'column_materializer::is_demo_project',
- mat_$active_feature_flags String COMMENT 'column_materializer::$active_feature_flags',
- mat_filters_count String COMMENT 'column_materializer::filters_count',
- mat_utm_source String COMMENT 'column_materializer::utm_source',
- mat_apiErrorMessage String COMMENT 'column_materializer::apiErrorMessage',
- mat_$referring_domain String COMMENT 'column_materializer::$referring_domain',
- mat_statusCode String COMMENT 'column_materializer::statusCode',
- mat_deal_id String COMMENT 'column_materializer::deal_id',
- mat_realm String COMMENT 'column_materializer::realm',
$group_0 String COMMENT 'column_materializer::$group_0',
$group_1 String COMMENT 'column_materializer::$group_1',
$group_2 String COMMENT 'column_materializer::$group_2',
$group_3 String COMMENT 'column_materializer::$group_3',
$group_4 String COMMENT 'column_materializer::$group_4',
- mat_$lib String COMMENT 'column_materializer::$lib',
- mat_$os String COMMENT 'column_materializer::$os',
- mat_$initial_referrer String COMMENT 'column_materializer::$initial_referrer',
- mat_$app_version String COMMENT 'column_materializer::$app_version',
- mat_$initial_referring_domain String COMMENT 'column_materializer::$initial_referring_domain',
- mat_symbol String COMMENT 'column_materializer::symbol',
- mat_page String COMMENT 'column_materializer::page',
- mat_type String COMMENT 'column_materializer::type',
- mat_currentScreen String COMMENT 'column_materializer::currentScreen',
- mat_utm_campaign String COMMENT 'column_materializer::utm_campaign',
- mat_is_organization_first_user String COMMENT 'column_materializer::is_organization_first_user',
- mat_is_first_component_load String COMMENT 'column_materializer::is_first_component_load',
- mat_team String COMMENT 'column_materializer::team',
- mat_context String COMMENT 'column_materializer::context',
- mat_sdk String COMMENT 'column_materializer::sdk',
- mat_created_by_system String COMMENT 'column_materializer::created_by_system',
- mat_item_count String COMMENT 'column_materializer::item_count',
- mat_$ip String COMMENT 'column_materializer::$ip',
- mat_$referrer String COMMENT 'column_materializer::$referrer',
- mat_action_name String COMMENT 'column_materializer::action_name',
- mat_$geoip_country_name String COMMENT 'column_materializer::$geoip_country_name',
- mat_$device_model String COMMENT 'column_materializer::$device_model',
- mat_progress String COMMENT 'column_materializer::progress',
- mat_chain String COMMENT 'column_materializer::chain',
- mat_$device_type String COMMENT 'column_materializer::$device_type',
- mat_usd String COMMENT 'column_materializer::usd',
- mat_app_name String COMMENT 'column_materializer::app_name',
- mat_$screen_name String COMMENT 'column_materializer::$screen_name',
- mat_index String COMMENT 'column_materializer::index',
- mat_token String COMMENT 'column_materializer::token',
- mat_method String COMMENT 'column_materializer::method',
- mat_address String COMMENT 'column_materializer::address',
- mat_name String COMMENT 'column_materializer::name',
- mat_inviteCode String COMMENT 'column_materializer::inviteCode',
$window_id String COMMENT 'column_materializer::$window_id',
$session_id String COMMENT 'column_materializer::$session_id',
- mat_osName String COMMENT 'column_materializer::osName',
- mat_nativeBuildVersion String COMMENT 'column_materializer::nativeBuildVersion',
- mat_revenue String COMMENT 'column_materializer::revenue',
group_0 String ALIAS `$group_0`,
group_1 String ALIAS `$group_1`,
group_2 String ALIAS `$group_2`,
group_3 String ALIAS `$group_3`,
group_4 String ALIAS `$group_4`,
- alias_mat__user_id String ALIAS `mat_$user_id`,
- alias_mat__browser String ALIAS `mat_$browser`,
- alias_mat__host String ALIAS `mat_$host`,
- alias_mat__current_url String ALIAS `mat_$current_url`,
- alias_mat__event_type String ALIAS `mat_$event_type`,
- alias_mat__active_feature_flags String ALIAS `mat_$active_feature_flags`,
- alias_mat__referring_domain String ALIAS `mat_$referring_domain`,
- alias_mat__lib String ALIAS `mat_$lib`,
- alias_mat__os String ALIAS `mat_$os`,
- alias_mat__initial_referrer String ALIAS `mat_$initial_referrer`,
- alias_mat__app_version String ALIAS `mat_$app_version`,
- alias_mat__initial_referring_domain String ALIAS `mat_$initial_referring_domain`,
- alias_mat__ip String ALIAS `mat_$ip`,
- alias_mat__referrer String ALIAS `mat_$referrer`,
- alias_mat__geoip_country_name String ALIAS `mat_$geoip_country_name`,
- alias_mat__device_model String ALIAS `mat_$device_model`,
- alias_mat__device_type String ALIAS `mat_$device_type`,
- alias_mat__screen_name String ALIAS `mat_$screen_name`,
person_id UUID,
person_properties String,
group0_properties String,
@@ -129,191 +52,8 @@ CREATE TABLE posthog.events (
group2_created_at DateTime64(3),
group3_created_at DateTime64(3),
group4_created_at DateTime64(3),
- mat_arguments String COMMENT 'column_materializer::properties::arguments',
- mat_source String COMMENT 'column_materializer::properties::source',
- mat_pp_email String COMMENT 'column_materializer::person_properties::email',
- mat_$time String COMMENT 'column_materializer::properties::$time',
- mat_$pathname String COMMENT 'column_materializer::properties::$pathname',
- mat_$geoip_city_name String COMMENT 'column_materializer::properties::$geoip_city_name',
- mat_community_id String COMMENT 'column_materializer::properties::community_id',
- mat_thread_id String COMMENT 'column_materializer::properties::thread_id',
- mat_Event_productCode String COMMENT 'column_materializer::properties::Event.productCode',
- mat_env String COMMENT 'column_materializer::properties::env',
- mat_target String COMMENT 'column_materializer::properties::target',
- mat_Subscription_plan_amount String COMMENT 'column_materializer::properties::Subscription.plan.amount',
- mat_title String COMMENT 'column_materializer::properties::title',
- mat_Connection_app_name String COMMENT 'column_materializer::properties::Connection.app.name',
- mat_utm_medium String COMMENT 'column_materializer::properties::utm_medium',
- mat_Account_client_id String COMMENT 'column_materializer::properties::Account.client_id',
- mat_HTTP_Method String COMMENT 'column_materializer::properties::HTTP Method',
- mat_audio_duration String COMMENT 'column_materializer::properties::audio_duration',
- mat_duration String COMMENT 'column_materializer::properties::duration',
- mat_url String COMMENT 'column_materializer::properties::url',
- mat_group_id String COMMENT 'column_materializer::properties::group_id',
- mat_platform String COMMENT 'column_materializer::properties::platform',
- mat_pp_$browser String COMMENT 'column_materializer::person_properties::$browser',
- mat_payment_status String COMMENT 'column_materializer::properties::payment_status',
- mat_testSessionId String COMMENT 'column_materializer::properties::testSessionId',
inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),
- mat_$sent_at String COMMENT 'column_materializer::properties::$sent_at',
- mat_pp_companyName String COMMENT 'column_materializer::person_properties::companyName',
- mat_function String COMMENT 'column_materializer::properties::function',
- mat_store_url String COMMENT 'column_materializer::properties::store_url',
- mat_email_domain String COMMENT 'column_materializer::properties::email_domain',
- mat_institution_name String COMMENT 'column_materializer::properties::institution_name',
- mat_authentication_method String COMMENT 'column_materializer::properties::authentication_method',
- mat_initial_step String COMMENT 'column_materializer::properties::initial_step',
- mat_status_message String COMMENT 'column_materializer::properties::status_message',
- mat_mode String COMMENT 'column_materializer::properties::mode',
- mat_protocol String COMMENT 'column_materializer::properties::protocol',
- mat_job_type String COMMENT 'column_materializer::properties::job_type',
- mat_is_oauth String COMMENT 'column_materializer::properties::is_oauth',
- mat_is_initial_aggregation String COMMENT 'column_materializer::properties::is_initial_aggregation',
- mat_search_term String COMMENT 'column_materializer::properties::search_term',
- mat_valid_ach_accounts String COMMENT 'column_materializer::properties::valid_ach_accounts',
- mat_gross String COMMENT 'column_materializer::properties::gross',
- mat_orderType String COMMENT 'column_materializer::properties::orderType',
- mat_sku String COMMENT 'column_materializer::properties::sku',
- mat_dual_channel String COMMENT 'column_materializer::properties::dual_channel',
- mat_channel String COMMENT 'column_materializer::properties::channel',
- mat_workspaceId String COMMENT 'column_materializer::properties::workspaceId',
- mat_numberOfSecrets String COMMENT 'column_materializer::properties::numberOfSecrets',
- mat_organizations String COMMENT 'column_materializer::properties::organizations',
- mat_organization String COMMENT 'column_materializer::properties::organization',
- mat_contributionError String COMMENT 'column_materializer::properties::contributionError',
- mat_phone String COMMENT 'column_materializer::properties::phone',
- mat_$initial_pathname String COMMENT 'column_materializer::properties::$initial_pathname',
- mat_organization_name String COMMENT 'column_materializer::properties::organization_name',
- mat_category String COMMENT 'column_materializer::properties::category',
- mat_$lib_version String COMMENT 'column_materializer::properties::$lib_version',
- mat_pp_$initial_utm_campaign String COMMENT 'column_materializer::person_properties::$initial_utm_campaign',
- mat_pp_$initial_utm_medium String COMMENT 'column_materializer::person_properties::$initial_utm_medium',
- mat_pp_$initial_gclid String COMMENT 'column_materializer::person_properties::$initial_gclid',
- mat_pp_$initial_gad_source String COMMENT 'column_materializer::person_properties::$initial_gad_source',
- mat_pp_$initial_utm_source String COMMENT 'column_materializer::person_properties::$initial_utm_source',
- mat_pp_$initial_referring_domain String COMMENT 'column_materializer::person_properties::$initial_referring_domain',
- mat_pp_$initial_utm_term String COMMENT 'column_materializer::person_properties::$initial_utm_term',
- mat_pp_$initial_utm_content String COMMENT 'column_materializer::person_properties::$initial_utm_content',
- mat_pp_$initial_gbraid String COMMENT 'column_materializer::person_properties::$initial_gbraid::disabled',
- mat_pp_$initial_wbraid String COMMENT 'column_materializer::person_properties::$initial_wbraid::disabled',
- mat_pp_$initial_msclkid String COMMENT 'column_materializer::person_properties::$initial_msclkid',
- mat_pp_$initial_fbclid String COMMENT 'column_materializer::person_properties::$initial_fbclid',
- mat_$geoip_subdivision_1_code String COMMENT 'column_materializer::properties::$geoip_subdivision_1_code',
- mat_wlo_enabled String COMMENT 'column_materializer::properties::wlo_enabled',
- mat_$prev_pageview_max_scroll_percentage String COMMENT 'column_materializer::properties::$prev_pageview_max_scroll_percentage',
- mat_$prev_pageview_max_content_percentage String COMMENT 'column_materializer::properties::$prev_pageview_max_content_percentage',
- mat_$prev_pageview_pathname String COMMENT 'column_materializer::properties::$prev_pageview_pathname',
- mat_pp_$initial_pathname String COMMENT 'column_materializer::person_properties::$initial_pathname',
- mat_pp_$geoip_country_code String COMMENT 'column_materializer::person_properties::$geoip_country_code',
- mat_pp_username String COMMENT 'column_materializer::person_properties::username',
- mat_pp_serverMasterclass String COMMENT 'column_materializer::person_properties::serverMasterclass',
- mat_content_length String COMMENT 'column_materializer::properties::content_length',
- mat_pp_serverMarketing String COMMENT 'column_materializer::person_properties::serverMarketing',
- mat_$browser_version String COMMENT 'column_materializer::properties::$browser_version',
- mat_pp_role String COMMENT 'column_materializer::person_properties::role',
- mat_pp_customer String COMMENT 'column_materializer::person_properties::customer',
- mat_event String COMMENT 'column_materializer::properties::event',
- mat_disable_institution_search String COMMENT 'column_materializer::properties::disable_institution_search',
- mat_is_first_event_for_user String COMMENT 'column_materializer::properties::is_first_event_for_user',
- mat_current_member_guid String COMMENT 'column_materializer::properties::current_member_guid',
- mat_user_agent String COMMENT 'column_materializer::properties::user_agent',
- mat_is_test_user String COMMENT 'column_materializer::properties::is_test_user',
- mat_referrer String COMMENT 'column_materializer::properties::referrer',
- mat_pp_$initial_current_url String COMMENT 'column_materializer::person_properties::$initial_current_url',
- mat_most_recent_app_os String COMMENT 'column_materializer::properties::most_recent_app_os',
- mat_pp_hubspot_score String COMMENT 'column_materializer::person_properties::hubspot_score',
- mat_pp_id String COMMENT 'column_materializer::person_properties::id',
- mat_pp_$current_url String COMMENT 'column_materializer::person_properties::$current_url',
- mat_product_key String COMMENT 'column_materializer::properties::product_key',
- mat_Plan_type_and_filter String COMMENT 'column_materializer::properties::Plan type and filter',
- mat_$app_namespace String COMMENT 'column_materializer::properties::$app_namespace',
- mat_$os_name String COMMENT 'column_materializer::properties::$os_name',
- mat_pp_$os_name String COMMENT 'column_materializer::person_properties::$os_name::disabled',
- mat_pp_$app_version String COMMENT 'column_materializer::person_properties::$app_version',
- mat_subscriptionStatus String COMMENT 'column_materializer::properties::subscriptionStatus',
- mat_$screen_height String COMMENT 'column_materializer::properties::$screen_height',
- mat_$screen_width String COMMENT 'column_materializer::properties::$screen_width',
- mat_tag String COMMENT 'column_materializer::properties::tag',
- mat_$app_build String COMMENT 'column_materializer::properties::$app_build',
- mat_surface_tag String COMMENT 'column_materializer::properties::surface_tag',
- mat_survey_responses_count_in_period String COMMENT 'column_materializer::properties::survey_responses_count_in_period',
- mat_event_count_in_month String COMMENT 'column_materializer::properties::event_count_in_month',
- mat_ramp String COMMENT 'column_materializer::properties::ramp',
- mat_auto_chapters String COMMENT 'column_materializer::properties::auto_chapters',
- mat_sentiment_analysis String COMMENT 'column_materializer::properties::sentiment_analysis',
- mat_redact_pii String COMMENT 'column_materializer::properties::redact_pii',
- mat_content_safety String COMMENT 'column_materializer::properties::content_safety',
- mat_iab_categories String COMMENT 'column_materializer::properties::iab_categories',
- mat_auto_highlights String COMMENT 'column_materializer::properties::auto_highlights',
- mat_entity_detection String COMMENT 'column_materializer::properties::entity_detection',
- mat_summarization String COMMENT 'column_materializer::properties::summarization',
- mat_pp_val_region String COMMENT 'column_materializer::person_properties::val_region',
- mat_client_id String COMMENT 'column_materializer::properties::client_id',
- mat_$geoip_country_code String COMMENT 'column_materializer::properties::$geoip_country_code',
- mat_disfluencies String COMMENT 'column_materializer::properties::disfluencies',
- mat_filter_profanity String COMMENT 'column_materializer::properties::filter_profanity',
- mat_speaker_labels String COMMENT 'column_materializer::properties::speaker_labels',
- mat_language_detection String COMMENT 'column_materializer::properties::language_detection',
- mat_product_analytics_projected_amount String COMMENT 'column_materializer::properties::product_analytics_projected_amount',
- mat_recordings_projected_amount String COMMENT 'column_materializer::properties::recordings_projected_amount',
- mat_events_projected_amount String COMMENT 'column_materializer::properties::events_projected_amount',
- mat_session_replay_projected_amount String COMMENT 'column_materializer::properties::session_replay_projected_amount',
- mat_total_usd String COMMENT 'column_materializer::properties::total_usd',
- mat_stripe_amount_paid String COMMENT 'column_materializer::properties::stripe_amount_paid',
- mat_workspace String COMMENT 'column_materializer::properties::workspace',
- mat_created_at String COMMENT 'column_materializer::properties::created_at',
- mat_kind String COMMENT 'column_materializer::properties::kind',
- mat_product String COMMENT 'column_materializer::properties::product',
- mat_message String COMMENT 'column_materializer::properties::message',
- mat_initiator String COMMENT 'column_materializer::properties::initiator',
- mat_query String COMMENT 'column_materializer::properties::query',
- mat_$survey_id String COMMENT 'column_materializer::properties::$survey_id',
- mat_$survey_response_1 String COMMENT 'column_materializer::properties::$survey_response_1',
- mat_ticketId String COMMENT 'column_materializer::properties::ticketId',
- mat_$survey_response String COMMENT 'column_materializer::properties::$survey_response',
- mat_conceptName String COMMENT 'column_materializer::properties::conceptName',
- mat_apiName String COMMENT 'column_materializer::properties::apiName',
- mat_workplace_billing_plan String COMMENT 'column_materializer::properties::workplace_billing_plan',
- mat_$el_text String COMMENT 'column_materializer::properties::$el_text',
- mat_recording_count_in_period String COMMENT 'column_materializer::properties::recording_count_in_period',
- mat_$os_version String COMMENT 'column_materializer::properties::$os_version',
- mat_orderId String COMMENT 'column_materializer::properties::orderId',
- mat_commit_sha String COMMENT 'column_materializer::properties::commit_sha',
- mat_$feature_flag_payloads String COMMENT 'column_materializer::properties::$feature_flag_payloads',
- mat_event_count_in_period String COMMENT 'column_materializer::properties::event_count_in_period',
- mat_$groups String COMMENT 'column_materializer::properties::$groups',
- mat_$feature_flag String COMMENT 'column_materializer::properties::$feature_flag',
- mat_utm_content String COMMENT 'column_materializer::properties::utm_content',
- mat_gclid String COMMENT 'column_materializer::properties::gclid',
- mat_gad_source String COMMENT 'column_materializer::properties::gad_source',
- mat_gbraid String COMMENT 'column_materializer::properties::gbraid',
- mat_wbraid String COMMENT 'column_materializer::properties::wbraid',
- mat_fbclid String COMMENT 'column_materializer::properties::fbclid',
- mat_msclkid String COMMENT 'column_materializer::properties::msclkid',
- mat_organization_id String COMMENT 'column_materializer::properties::organization_id',
- mat_owner_type String COMMENT 'column_materializer::properties::owner_type',
- mat_device_type String COMMENT 'column_materializer::properties::device_type',
- mat_$device_id String COMMENT 'column_materializer::properties::$device_id',
- mat_pp_$geoip_continent_name String COMMENT 'column_materializer::person_properties::$geoip_continent_name',
- mat_$feature_flag_response String COMMENT 'column_materializer::properties::$feature_flag_response',
- mat_pp_utm_source String COMMENT 'column_materializer::person_properties::utm_source',
- mat_pp_$referring_domain String COMMENT 'column_materializer::person_properties::$referring_domain',
- mat_pp_Email_Domain String COMMENT 'column_materializer::person_properties::Email Domain',
- mat_machine_id String COMMENT 'column_materializer::properties::machine_id',
- mat_user_email_domain String COMMENT 'column_materializer::properties::user_email_domain',
- mat_$lib_version__minor String COMMENT 'column_materializer::properties::$lib_version__minor',
- mat_region String COMMENT 'column_materializer::properties::region',
- mat_pp_user_email_domain String COMMENT 'column_materializer::person_properties::user_email_domain',
- mat_url_promotion_id String COMMENT 'column_materializer::properties::url_promotion_id',
- mat_$lib_custom_api_host String COMMENT 'column_materializer::properties::$lib_custom_api_host',
person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),
- mat_user_platform String COMMENT 'column_materializer::properties::user_platform',
- mat_pp_$geoip_country_name String COMMENT 'column_materializer::person_properties::$geoip_country_name',
- mat_environment String COMMENT 'column_materializer::properties::environment',
- mat_customer_email String COMMENT 'column_materializer::properties::customer_email',
- mat_client_name String COMMENT 'column_materializer::properties::client_name',
- mat_screen_name String COMMENT 'column_materializer::properties::screen_name',
- mat_app_version String COMMENT 'column_materializer::properties::app_version',
elements_chain_href String COMMENT 'column_materializer::elements_chain::href',
elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',
elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',
@@ -321,36 +61,11 @@ CREATE TABLE posthog.events (
properties_group_custom Map(String, String),
properties_group_feature_flags Map(String, String),
is_deleted Bool,
- mat_subdomain String COMMENT 'column_materializer::properties::subdomain',
- mat_$device String COMMENT 'column_materializer::properties::$device',
- mat_id String COMMENT 'column_materializer::properties::id',
- mat_record_id String COMMENT 'column_materializer::properties::record_id',
- mat_referrer_id String COMMENT 'column_materializer::properties::record_id',
- mat_$exception_issue_id Nullable(String) COMMENT 'column_materializer::properties::$exception_issue_id',
- mat_$exception_fingerprint Nullable(String) COMMENT 'column_materializer::properties::$exception_fingerprint',
- mat_$web_vitals_LCP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_LCP_value',
- mat_$web_vitals_FCP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_FCP_value',
- mat_$web_vitals_CLS_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_CLS_value',
- mat_$web_vitals_INP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_INP_value',
- mat_$viewport_width Nullable(String) COMMENT 'column_materializer::properties::$viewport_width',
- mat_$viewport_height Nullable(String) COMMENT 'column_materializer::properties::$viewport_height',
- mat_$anon_distinct_id Nullable(String) COMMENT 'column_materializer::properties::$anon_distinct_id',
person_properties_map_custom Map(String, String),
mat_$ai_trace_id Nullable(String) COMMENT 'column_materializer::properties::$ai_trace_id',
- mat_$ai_model Nullable(String) COMMENT 'column_materializer::properties::$ai_model',
- mat_$ai_provider Nullable(String) COMMENT 'column_materializer::properties::$ai_provider',
- mat_$ai_parent_id Nullable(String) COMMENT 'column_materializer::properties::$ai_parent_id',
- mat_$ai_span_id Nullable(String) COMMENT 'column_materializer::properties::$ai_span_id',
- mat_$ai_http_status Nullable(String) COMMENT 'column_materializer::properties::$ai_http_status',
- mat_$exception_types Nullable(String) COMMENT 'column_materializer::properties::$exception_types',
- mat_$exception_values Nullable(String) COMMENT 'column_materializer::properties::$exception_values',
- mat_$exception_sources Nullable(String) COMMENT 'column_materializer::properties::$exception_sources',
- mat_$exception_functions Nullable(String) COMMENT 'column_materializer::properties::$exception_functions',
$session_id_uuid Nullable(UInt128),
- mat_$process_person_profile Nullable(String) COMMENT 'column_materializer::properties::$process_person_profile',
consumer_breadcrumbs Array(String),
properties_group_ai Map(String, String),
- mat_$is_identified Nullable(String) COMMENT 'column_materializer::properties::$is_identified',
mat_historical_migration Nullable(String) COMMENT 'column_materializer::properties::historical_migration',
mat_$ai_session_id Nullable(String) COMMENT 'column_materializer::properties::$ai_session_id',
mat_$ai_is_error Nullable(String) COMMENT 'column_materializer::properties::$ai_is_error',
@@ -364,48 +79,10 @@ CREATE TABLE posthog.events (
dmat_string_7 Nullable(String),
dmat_string_8 Nullable(String),
dmat_string_9 Nullable(String),
- dmat_numeric_0 Nullable(Float64),
- dmat_numeric_1 Nullable(Float64),
- dmat_numeric_2 Nullable(Float64),
- dmat_numeric_3 Nullable(Float64),
- dmat_numeric_4 Nullable(Float64),
- dmat_numeric_5 Nullable(Float64),
- dmat_numeric_6 Nullable(Float64),
- dmat_numeric_7 Nullable(Float64),
- dmat_numeric_8 Nullable(Float64),
- dmat_numeric_9 Nullable(Float64),
- dmat_bool_0 Nullable(UInt8),
- dmat_bool_1 Nullable(UInt8),
- dmat_bool_2 Nullable(UInt8),
- dmat_bool_3 Nullable(UInt8),
- dmat_bool_4 Nullable(UInt8),
- dmat_bool_5 Nullable(UInt8),
- dmat_bool_6 Nullable(UInt8),
- dmat_bool_7 Nullable(UInt8),
- dmat_bool_8 Nullable(UInt8),
- dmat_bool_9 Nullable(UInt8),
- dmat_datetime_0 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_1 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_2 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_3 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_4 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_5 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_6 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_7 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_8 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_9 Nullable(DateTime64(6, 'UTC')),
historical_migration Bool,
- mat_$ai_total_cost_usd Nullable(String) COMMENT 'column_materializer::properties::$ai_total_cost_usd',
properties_group_ai_large Map(String, String),
mat_$ai_prompt_name Nullable(String) COMMENT 'column_materializer::properties::$ai_prompt_name',
- mat_$ai_experiment_id Nullable(String) COMMENT 'column_materializer::properties::$ai_experiment_id',
- mat_$survey_submission_id Nullable(String) COMMENT 'column_materializer::properties::$survey_submission_id',
- mat_$geoip_subdivision_1_name Nullable(String) COMMENT 'column_materializer::properties::$geoip_subdivision_1_name',
- mat_$raw_user_agent Nullable(String) COMMENT 'column_materializer::properties::$raw_user_agent',
- mat_$prev_pageview_duration Nullable(String) COMMENT 'column_materializer::properties::$prev_pageview_duration',
- mat_pp_$initial_host Nullable(String) COMMENT 'column_materializer::person_properties::$initial_host',
- mat_pp_$initial_url Nullable(String) COMMENT 'column_materializer::person_properties::$initial_url',
- mat_pp_$initial_geoip_country_name Nullable(String) COMMENT 'column_materializer::person_properties::$initial_geoip_country_name'
+ mat_$ai_experiment_id Nullable(String) COMMENT 'column_materializer::properties::$ai_experiment_id'
) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));
CREATE TABLE posthog.person_distinct_id_overrides (
team_id Int64,
@@ -626,7 +303,7 @@ CREATE TABLE posthog.raw_sessions_v3 (
has_replay_events SimpleAggregateFunction(max, Bool),
INDEX event_names_bloom_filter event_names TYPE bloom_filter() GRANULARITY 1,
INDEX flag_keys_bloom_filter flag_keys TYPE bloom_filter() GRANULARITY 1
-) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3', '{shard}-{replica}') ORDER BY (team_id, session_timestamp, session_id_v7) PARTITION BY toYYYYMM(session_timestamp) SETTINGS index_granularity = 8192;
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3', '{shard}-{replica}') ORDER BY (team_id, session_timestamp, session_id_v7) PARTITION BY toYYYYMM(session_timestamp) SETTINGS index_granularity = 8192, storage_policy = 's3_tiered';
CREATE TABLE posthog.sessions (
session_id String,
team_id Int64,
@@ -733,10 +410,10 @@ FROM system.query_log
WHERE type != 'QueryStart';
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -791,10 +468,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/prod-us/ai_events.sql b/posthog/clickhouse/hcl/sql/prod-us/ai_events.sql
index 5dc5fec6b489..a2b1789c4744 100644
--- a/posthog/clickhouse/hcl/sql/prod-us/ai_events.sql
+++ b/posthog/clickhouse/hcl/sql/prod-us/ai_events.sql
@@ -86,7 +86,7 @@ CREATE TABLE posthog.kafka_ai_events_json_ws (
person_properties String,
person_created_at DateTime64(3),
person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ai_events_ws\'', kafka_max_block_size = 5000, kafka_num_consumers = 16, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_ai_events_json\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_ai_events_ws', kafka_max_block_size = 5000, kafka_num_consumers = 16, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_ai_events_json';
CREATE TABLE posthog.person (
id UUID,
created_at DateTime64(3),
@@ -341,10 +341,10 @@ FROM system.query_log
WHERE type != 'QueryStart';
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -399,10 +399,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql b/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql
index 8e9d357609d7..8454c8756b88 100644
--- a/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql
+++ b/posthog/clickhouse/hcl/sql/prod-us/auxiliary.sql
@@ -87,14 +87,14 @@ CREATE TABLE posthog.kafka_hog_invocation_results (
invocation_globals String,
version UInt64,
is_deleted UInt8
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_hog_invocation_results\'', kafka_max_block_size = 100000, kafka_num_consumers = 1, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_hog_invocation_results\'';
+) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_hog_invocation_results', kafka_max_block_size = 100000, kafka_num_consumers = 1, kafka_poll_timeout_ms = 10000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_hog_invocation_results';
CREATE TABLE posthog.kafka_ingestion_warnings_v2 (
team_id Int64,
source LowCardinality(String),
type String,
details String,
timestamp DateTime64(6, 'UTC')
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_ingestion_warnings_v2\'', kafka_topic_list = 'kafka_topic_list = \'clickhouse_ingestion_warnings\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_ingestion_warnings_v2', kafka_topic_list = 'clickhouse_ingestion_warnings';
CREATE TABLE posthog.kafka_message_assets (
team_id Int64,
function_kind LowCardinality(String),
@@ -112,14 +112,14 @@ CREATE TABLE posthog.kafka_message_assets (
version UInt64,
is_deleted UInt8,
html String
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_cyclotron', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_message_assets\'', kafka_skip_broken_messages = 100, kafka_topic_list = 'kafka_topic_list = \'clickhouse_message_assets\'';
+) ENGINE = Kafka(warpstream_cyclotron) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_message_assets', kafka_skip_broken_messages = 100, kafka_topic_list = 'clickhouse_message_assets';
CREATE TABLE posthog.kafka_property_values (
team_id Int64,
property_type LowCardinality(String),
property_key String,
property_value String,
property_count UInt64
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_ingestion', kafka_format = 'kafka_format = \'JSONEachRow\'', kafka_group_name = 'kafka_group_name = \'clickhouse_property_values\'', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_property_values\'';
+) ENGINE = Kafka(warpstream_ingestion) SETTINGS kafka_format = 'JSONEachRow', kafka_group_name = 'clickhouse_property_values', kafka_num_consumers = 8, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_property_values';
CREATE TABLE posthog.message_assets_data (
team_id Int64,
function_kind LowCardinality(String),
@@ -885,10 +885,10 @@ CREATE MATERIALIZED VIEW posthog.property_values_mv TO posthog.property_values (
FROM posthog.kafka_property_values;
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -943,10 +943,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/prod-us/batch_exports.sql b/posthog/clickhouse/hcl/sql/prod-us/batch_exports.sql
index 77725791f004..b6ca768614af 100644
--- a/posthog/clickhouse/hcl/sql/prod-us/batch_exports.sql
+++ b/posthog/clickhouse/hcl/sql/prod-us/batch_exports.sql
@@ -192,10 +192,10 @@ FROM system.query_log
WHERE type != 'QueryStart';
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -250,10 +250,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/prod-us/logs.sql b/posthog/clickhouse/hcl/sql/prod-us/logs.sql
index e09897b91862..50c926d09861 100644
--- a/posthog/clickhouse/hcl/sql/prod-us/logs.sql
+++ b/posthog/clickhouse/hcl/sql/prod-us/logs.sql
@@ -22,7 +22,7 @@ CREATE TABLE posthog.kafka_metrics_avro (
instrumentation_scope Nullable(String),
attributes Map(String, String),
series_fingerprint Nullable(Int64)
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_metrics', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-metrics-avro-new\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_metrics\'';
+) ENGINE = Kafka(warpstream_metrics) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-metrics-avro-new', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_metrics';
CREATE TABLE posthog.kafka_trace_spans_avro (
uuid String,
trace_id String,
@@ -45,7 +45,7 @@ CREATE TABLE posthog.kafka_trace_spans_avro (
links Array(String),
dropped_links_count Int32,
status_code Int32
-) ENGINE = Kafka() SETTINGS kafka_broker_list = 'warpstream_traces', kafka_format = 'kafka_format = \'Avro\'', kafka_group_name = 'kafka_group_name = \'clickhouse-traces-avro\'', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'kafka_topic_list = \'clickhouse_traces\'';
+) ENGINE = Kafka(warpstream_traces) SETTINGS kafka_format = 'Avro', kafka_group_name = 'clickhouse-traces-avro', kafka_num_consumers = 8, kafka_poll_max_batch_size = 1000, kafka_poll_timeout_ms = 3000, kafka_skip_broken_messages = 100, kafka_thread_per_consumer = 1, kafka_topic_list = 'clickhouse_traces';
CREATE TABLE posthog.log_attributes2 (
team_id Int32,
time_bucket DateTime64(0),
@@ -1110,10 +1110,10 @@ GROUP BY
_partition, _topic;
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -1168,10 +1168,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,
diff --git a/posthog/clickhouse/hcl/sql/prod-us/ops.sql b/posthog/clickhouse/hcl/sql/prod-us/ops.sql
new file mode 100644
index 000000000000..a4dc7f6d299a
--- /dev/null
+++ b/posthog/clickhouse/hcl/sql/prod-us/ops.sql
@@ -0,0 +1,652 @@
+-- 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.event_property_daily_stats (
+ analysis_date Date,
+ team_id Int64,
+ property_key String,
+ event_count UInt64,
+ distinct_event_names UInt32,
+ total_property_bytes UInt64,
+ min_property_bytes UInt64,
+ max_property_bytes UInt64,
+ avg_property_bytes Float64,
+ p50_property_bytes Float64,
+ p90_property_bytes Float64,
+ p95_property_bytes Float64,
+ p99_property_bytes Float64,
+ property_size_histogram Array(Tuple(Float64, Float64, UInt64)),
+ top_event_names Array(String),
+ sample_rate Float32,
+ computed_at DateTime
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.event_property_daily_stats', '{replica}') ORDER BY (analysis_date, team_id, property_key) TTL analysis_date + toIntervalDay(30) SETTINGS index_granularity = 8192;
+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,
+ PROJECTION by_label_value (SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, label_name, label_value, id, metric_name),
+ PROJECTION by_id_label (SELECT team_id, metric_name, label_name, label_value, id
+ORDER BY team_id, id, label_name, metric_name, label_value)
+) 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 CODEC(T64, Default),
+ metric_name LowCardinality(String),
+ timestamp DateTime64(3, 'UTC') CODEC(DoubleDelta, Default),
+ id UInt64,
+ value Float64 CODEC(Gorilla(8), Default)
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_samples_new', '{replica}') ORDER BY (team_id, metric_name, toStartOfTenMinutes(timestamp), id, timestamp) PARTITION BY toYYYYMMDD(timestamp) SETTINGS index_granularity = 8192;
+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'),
+ PROJECTION by_id (SELECT team_id, id, metric_name, labels_json, min_time, max_time
+ORDER BY team_id, id)
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.metrics_series', '{replica}') ORDER BY (team_id, metric_name, id) SETTINGS index_granularity = 1024;
+CREATE TABLE posthog.query_team_daily_stats (
+ analysis_date Date,
+ team_id Int64,
+ query_count UInt64,
+ error_count UInt64,
+ distinct_query_shapes UInt64,
+ total_duration_ms UInt64,
+ avg_duration_ms Float64,
+ p50_duration_ms Float64,
+ p90_duration_ms Float64,
+ p99_duration_ms Float64,
+ max_duration_ms UInt64,
+ total_read_rows UInt64,
+ total_read_bytes UInt64 COMMENT 'Uncompressed bytes scanned, coordinator-side summed across shards (is_initial_query=1). Compute/scan cost proxy, NOT stored footprint.',
+ total_result_rows UInt64,
+ total_result_bytes UInt64,
+ total_written_rows UInt64,
+ total_written_bytes UInt64,
+ total_cpu_seconds Float64 COMMENT 'ProfileEvents OSCPUVirtualTimeMicroseconds summed across ALL QueryFinish rows (initiator + shard leaves) / 1e6. CPU is not folded onto the initiator row, so leaves must be summed.',
+ total_memory_usage UInt64 COMMENT 'Peak memory_usage summed across all shard rows (per-node peak; not folded onto the initiator).',
+ max_memory_usage UInt64 COMMENT 'Largest single-node peak memory across all shard rows.',
+ p99_memory_usage Float64,
+ total_s3_get_objects UInt64 COMMENT 'ProfileEvents S3GetObject summed across all shard rows: object-storage GET count.',
+ total_s3_read_bytes UInt64 COMMENT 'ProfileEvents ReadBufferFromS3Bytes summed across all shard rows: object-storage read cost proxy.',
+ query_kind_counts Map(String, UInt64) COMMENT 'query_kind -> count for QueryFinish rows.',
+ computed_at DateTime
+) ENGINE = ReplicatedMergeTree('/clickhouse/ops/tables/{shard}/posthog.query_team_daily_stats', '{replica}') ORDER BY (analysis_date, team_id) PARTITION BY analysis_date TTL analysis_date + toIntervalDay(90) 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'), ''),
+ 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', storage_policy = 's3_tiered';
+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
+ );
diff --git a/posthog/clickhouse/hcl/sql/prod-us/sessions.sql b/posthog/clickhouse/hcl/sql/prod-us/sessions.sql
index 2a1a18be8c25..3438ce792caa 100644
--- a/posthog/clickhouse/hcl/sql/prod-us/sessions.sql
+++ b/posthog/clickhouse/hcl/sql/prod-us/sessions.sql
@@ -27,95 +27,18 @@ CREATE TABLE posthog.events (
_timestamp DateTime,
_offset UInt64,
elements_chain String,
- mat_$user_id String COMMENT 'column_materializer::$user_id',
- mat_$browser String COMMENT 'column_materializer::$browser',
- mat_$host String COMMENT 'column_materializer::$host',
- mat_$current_url String COMMENT 'column_materializer::$current_url',
- mat_distinct_id String COMMENT 'column_materializer::distinct_id',
- mat_action String COMMENT 'column_materializer::action',
- mat_origin String COMMENT 'column_materializer::origin',
- mat_email String COMMENT 'column_materializer::email',
- mat_key String COMMENT 'column_materializer::key',
- mat_insight String COMMENT 'column_materializer::insight',
- mat_$event_type String COMMENT 'column_materializer::$event_type',
- mat_created_by String COMMENT 'column_materializer::created_by',
- mat_total_event_actions_count String COMMENT 'column_materializer::total_event_actions_count',
- mat_is_demo_project String COMMENT 'column_materializer::is_demo_project',
- mat_$active_feature_flags String COMMENT 'column_materializer::$active_feature_flags',
- mat_filters_count String COMMENT 'column_materializer::filters_count',
- mat_utm_source String COMMENT 'column_materializer::utm_source',
- mat_apiErrorMessage String COMMENT 'column_materializer::apiErrorMessage',
- mat_$referring_domain String COMMENT 'column_materializer::$referring_domain',
- mat_statusCode String COMMENT 'column_materializer::statusCode',
- mat_deal_id String COMMENT 'column_materializer::deal_id',
- mat_realm String COMMENT 'column_materializer::realm',
$group_0 String COMMENT 'column_materializer::$group_0',
$group_1 String COMMENT 'column_materializer::$group_1',
$group_2 String COMMENT 'column_materializer::$group_2',
$group_3 String COMMENT 'column_materializer::$group_3',
$group_4 String COMMENT 'column_materializer::$group_4',
- mat_$lib String COMMENT 'column_materializer::$lib',
- mat_$os String COMMENT 'column_materializer::$os',
- mat_$initial_referrer String COMMENT 'column_materializer::$initial_referrer',
- mat_$app_version String COMMENT 'column_materializer::$app_version',
- mat_$initial_referring_domain String COMMENT 'column_materializer::$initial_referring_domain',
- mat_symbol String COMMENT 'column_materializer::symbol',
- mat_page String COMMENT 'column_materializer::page',
- mat_type String COMMENT 'column_materializer::type',
- mat_currentScreen String COMMENT 'column_materializer::currentScreen',
- mat_utm_campaign String COMMENT 'column_materializer::utm_campaign',
- mat_is_organization_first_user String COMMENT 'column_materializer::is_organization_first_user',
- mat_is_first_component_load String COMMENT 'column_materializer::is_first_component_load',
- mat_team String COMMENT 'column_materializer::team',
- mat_context String COMMENT 'column_materializer::context',
- mat_sdk String COMMENT 'column_materializer::sdk',
- mat_created_by_system String COMMENT 'column_materializer::created_by_system',
- mat_item_count String COMMENT 'column_materializer::item_count',
- mat_$ip String COMMENT 'column_materializer::$ip',
- mat_$referrer String COMMENT 'column_materializer::$referrer',
- mat_action_name String COMMENT 'column_materializer::action_name',
- mat_$geoip_country_name String COMMENT 'column_materializer::$geoip_country_name',
- mat_$device_model String COMMENT 'column_materializer::$device_model',
- mat_progress String COMMENT 'column_materializer::progress',
- mat_chain String COMMENT 'column_materializer::chain',
- mat_$device_type String COMMENT 'column_materializer::$device_type',
- mat_usd String COMMENT 'column_materializer::usd',
- mat_app_name String COMMENT 'column_materializer::app_name',
- mat_$screen_name String COMMENT 'column_materializer::$screen_name',
- mat_index String COMMENT 'column_materializer::index',
- mat_token String COMMENT 'column_materializer::token',
- mat_method String COMMENT 'column_materializer::method',
- mat_address String COMMENT 'column_materializer::address',
- mat_name String COMMENT 'column_materializer::name',
- mat_inviteCode String COMMENT 'column_materializer::inviteCode',
$window_id String COMMENT 'column_materializer::$window_id',
$session_id String COMMENT 'column_materializer::$session_id',
- mat_osName String COMMENT 'column_materializer::osName',
- mat_nativeBuildVersion String COMMENT 'column_materializer::nativeBuildVersion',
- mat_revenue String COMMENT 'column_materializer::revenue',
group_0 String ALIAS `$group_0`,
group_1 String ALIAS `$group_1`,
group_2 String ALIAS `$group_2`,
group_3 String ALIAS `$group_3`,
group_4 String ALIAS `$group_4`,
- alias_mat__user_id String ALIAS `mat_$user_id`,
- alias_mat__browser String ALIAS `mat_$browser`,
- alias_mat__host String ALIAS `mat_$host`,
- alias_mat__current_url String ALIAS `mat_$current_url`,
- alias_mat__event_type String ALIAS `mat_$event_type`,
- alias_mat__active_feature_flags String ALIAS `mat_$active_feature_flags`,
- alias_mat__referring_domain String ALIAS `mat_$referring_domain`,
- alias_mat__lib String ALIAS `mat_$lib`,
- alias_mat__os String ALIAS `mat_$os`,
- alias_mat__initial_referrer String ALIAS `mat_$initial_referrer`,
- alias_mat__app_version String ALIAS `mat_$app_version`,
- alias_mat__initial_referring_domain String ALIAS `mat_$initial_referring_domain`,
- alias_mat__ip String ALIAS `mat_$ip`,
- alias_mat__referrer String ALIAS `mat_$referrer`,
- alias_mat__geoip_country_name String ALIAS `mat_$geoip_country_name`,
- alias_mat__device_model String ALIAS `mat_$device_model`,
- alias_mat__device_type String ALIAS `mat_$device_type`,
- alias_mat__screen_name String ALIAS `mat_$screen_name`,
person_id UUID,
person_properties String,
group0_properties String,
@@ -129,191 +52,8 @@ CREATE TABLE posthog.events (
group2_created_at DateTime64(3),
group3_created_at DateTime64(3),
group4_created_at DateTime64(3),
- mat_arguments String COMMENT 'column_materializer::properties::arguments',
- mat_source String COMMENT 'column_materializer::properties::source',
- mat_pp_email String COMMENT 'column_materializer::person_properties::email',
- mat_$time String COMMENT 'column_materializer::properties::$time',
- mat_$pathname String COMMENT 'column_materializer::properties::$pathname',
- mat_$geoip_city_name String COMMENT 'column_materializer::properties::$geoip_city_name',
- mat_community_id String COMMENT 'column_materializer::properties::community_id',
- mat_thread_id String COMMENT 'column_materializer::properties::thread_id',
- mat_Event_productCode String COMMENT 'column_materializer::properties::Event.productCode',
- mat_env String COMMENT 'column_materializer::properties::env',
- mat_target String COMMENT 'column_materializer::properties::target',
- mat_Subscription_plan_amount String COMMENT 'column_materializer::properties::Subscription.plan.amount',
- mat_title String COMMENT 'column_materializer::properties::title',
- mat_Connection_app_name String COMMENT 'column_materializer::properties::Connection.app.name',
- mat_utm_medium String COMMENT 'column_materializer::properties::utm_medium',
- mat_Account_client_id String COMMENT 'column_materializer::properties::Account.client_id',
- mat_HTTP_Method String COMMENT 'column_materializer::properties::HTTP Method',
- mat_audio_duration String COMMENT 'column_materializer::properties::audio_duration',
- mat_duration String COMMENT 'column_materializer::properties::duration',
- mat_url String COMMENT 'column_materializer::properties::url',
- mat_group_id String COMMENT 'column_materializer::properties::group_id',
- mat_platform String COMMENT 'column_materializer::properties::platform',
- mat_pp_$browser String COMMENT 'column_materializer::person_properties::$browser',
- mat_payment_status String COMMENT 'column_materializer::properties::payment_status',
- mat_testSessionId String COMMENT 'column_materializer::properties::testSessionId',
inserted_at Nullable(DateTime64(6, 'UTC')) DEFAULT now64(),
- mat_$sent_at String COMMENT 'column_materializer::properties::$sent_at',
- mat_pp_companyName String COMMENT 'column_materializer::person_properties::companyName',
- mat_function String COMMENT 'column_materializer::properties::function',
- mat_store_url String COMMENT 'column_materializer::properties::store_url',
- mat_email_domain String COMMENT 'column_materializer::properties::email_domain',
- mat_institution_name String COMMENT 'column_materializer::properties::institution_name',
- mat_authentication_method String COMMENT 'column_materializer::properties::authentication_method',
- mat_initial_step String COMMENT 'column_materializer::properties::initial_step',
- mat_status_message String COMMENT 'column_materializer::properties::status_message',
- mat_mode String COMMENT 'column_materializer::properties::mode',
- mat_protocol String COMMENT 'column_materializer::properties::protocol',
- mat_job_type String COMMENT 'column_materializer::properties::job_type',
- mat_is_oauth String COMMENT 'column_materializer::properties::is_oauth',
- mat_is_initial_aggregation String COMMENT 'column_materializer::properties::is_initial_aggregation',
- mat_search_term String COMMENT 'column_materializer::properties::search_term',
- mat_valid_ach_accounts String COMMENT 'column_materializer::properties::valid_ach_accounts',
- mat_gross String COMMENT 'column_materializer::properties::gross',
- mat_orderType String COMMENT 'column_materializer::properties::orderType',
- mat_sku String COMMENT 'column_materializer::properties::sku',
- mat_dual_channel String COMMENT 'column_materializer::properties::dual_channel',
- mat_channel String COMMENT 'column_materializer::properties::channel',
- mat_workspaceId String COMMENT 'column_materializer::properties::workspaceId',
- mat_numberOfSecrets String COMMENT 'column_materializer::properties::numberOfSecrets',
- mat_organizations String COMMENT 'column_materializer::properties::organizations',
- mat_organization String COMMENT 'column_materializer::properties::organization',
- mat_contributionError String COMMENT 'column_materializer::properties::contributionError',
- mat_phone String COMMENT 'column_materializer::properties::phone',
- mat_$initial_pathname String COMMENT 'column_materializer::properties::$initial_pathname',
- mat_organization_name String COMMENT 'column_materializer::properties::organization_name',
- mat_category String COMMENT 'column_materializer::properties::category',
- mat_$lib_version String COMMENT 'column_materializer::properties::$lib_version',
- mat_pp_$initial_utm_campaign String COMMENT 'column_materializer::person_properties::$initial_utm_campaign',
- mat_pp_$initial_utm_medium String COMMENT 'column_materializer::person_properties::$initial_utm_medium',
- mat_pp_$initial_gclid String COMMENT 'column_materializer::person_properties::$initial_gclid',
- mat_pp_$initial_gad_source String COMMENT 'column_materializer::person_properties::$initial_gad_source',
- mat_pp_$initial_utm_source String COMMENT 'column_materializer::person_properties::$initial_utm_source',
- mat_pp_$initial_referring_domain String COMMENT 'column_materializer::person_properties::$initial_referring_domain',
- mat_pp_$initial_utm_term String COMMENT 'column_materializer::person_properties::$initial_utm_term',
- mat_pp_$initial_utm_content String COMMENT 'column_materializer::person_properties::$initial_utm_content',
- mat_pp_$initial_gbraid String COMMENT 'column_materializer::person_properties::$initial_gbraid::disabled',
- mat_pp_$initial_wbraid String COMMENT 'column_materializer::person_properties::$initial_wbraid::disabled',
- mat_pp_$initial_msclkid String COMMENT 'column_materializer::person_properties::$initial_msclkid',
- mat_pp_$initial_fbclid String COMMENT 'column_materializer::person_properties::$initial_fbclid',
- mat_$geoip_subdivision_1_code String COMMENT 'column_materializer::properties::$geoip_subdivision_1_code',
- mat_wlo_enabled String COMMENT 'column_materializer::properties::wlo_enabled',
- mat_$prev_pageview_max_scroll_percentage String COMMENT 'column_materializer::properties::$prev_pageview_max_scroll_percentage',
- mat_$prev_pageview_max_content_percentage String COMMENT 'column_materializer::properties::$prev_pageview_max_content_percentage',
- mat_$prev_pageview_pathname String COMMENT 'column_materializer::properties::$prev_pageview_pathname',
- mat_pp_$initial_pathname String COMMENT 'column_materializer::person_properties::$initial_pathname',
- mat_pp_$geoip_country_code String COMMENT 'column_materializer::person_properties::$geoip_country_code',
- mat_pp_username String COMMENT 'column_materializer::person_properties::username',
- mat_pp_serverMasterclass String COMMENT 'column_materializer::person_properties::serverMasterclass',
- mat_content_length String COMMENT 'column_materializer::properties::content_length',
- mat_pp_serverMarketing String COMMENT 'column_materializer::person_properties::serverMarketing',
- mat_$browser_version String COMMENT 'column_materializer::properties::$browser_version',
- mat_pp_role String COMMENT 'column_materializer::person_properties::role',
- mat_pp_customer String COMMENT 'column_materializer::person_properties::customer',
- mat_event String COMMENT 'column_materializer::properties::event',
- mat_disable_institution_search String COMMENT 'column_materializer::properties::disable_institution_search',
- mat_is_first_event_for_user String COMMENT 'column_materializer::properties::is_first_event_for_user',
- mat_current_member_guid String COMMENT 'column_materializer::properties::current_member_guid',
- mat_user_agent String COMMENT 'column_materializer::properties::user_agent',
- mat_is_test_user String COMMENT 'column_materializer::properties::is_test_user',
- mat_referrer String COMMENT 'column_materializer::properties::referrer',
- mat_pp_$initial_current_url String COMMENT 'column_materializer::person_properties::$initial_current_url',
- mat_most_recent_app_os String COMMENT 'column_materializer::properties::most_recent_app_os',
- mat_pp_hubspot_score String COMMENT 'column_materializer::person_properties::hubspot_score',
- mat_pp_id String COMMENT 'column_materializer::person_properties::id',
- mat_pp_$current_url String COMMENT 'column_materializer::person_properties::$current_url',
- mat_product_key String COMMENT 'column_materializer::properties::product_key',
- mat_Plan_type_and_filter String COMMENT 'column_materializer::properties::Plan type and filter',
- mat_$app_namespace String COMMENT 'column_materializer::properties::$app_namespace',
- mat_$os_name String COMMENT 'column_materializer::properties::$os_name',
- mat_pp_$os_name String COMMENT 'column_materializer::person_properties::$os_name::disabled',
- mat_pp_$app_version String COMMENT 'column_materializer::person_properties::$app_version',
- mat_subscriptionStatus String COMMENT 'column_materializer::properties::subscriptionStatus',
- mat_$screen_height String COMMENT 'column_materializer::properties::$screen_height',
- mat_$screen_width String COMMENT 'column_materializer::properties::$screen_width',
- mat_tag String COMMENT 'column_materializer::properties::tag',
- mat_$app_build String COMMENT 'column_materializer::properties::$app_build',
- mat_surface_tag String COMMENT 'column_materializer::properties::surface_tag',
- mat_survey_responses_count_in_period String COMMENT 'column_materializer::properties::survey_responses_count_in_period',
- mat_event_count_in_month String COMMENT 'column_materializer::properties::event_count_in_month',
- mat_ramp String COMMENT 'column_materializer::properties::ramp',
- mat_auto_chapters String COMMENT 'column_materializer::properties::auto_chapters',
- mat_sentiment_analysis String COMMENT 'column_materializer::properties::sentiment_analysis',
- mat_redact_pii String COMMENT 'column_materializer::properties::redact_pii',
- mat_content_safety String COMMENT 'column_materializer::properties::content_safety',
- mat_iab_categories String COMMENT 'column_materializer::properties::iab_categories',
- mat_auto_highlights String COMMENT 'column_materializer::properties::auto_highlights',
- mat_entity_detection String COMMENT 'column_materializer::properties::entity_detection',
- mat_summarization String COMMENT 'column_materializer::properties::summarization',
- mat_pp_val_region String COMMENT 'column_materializer::person_properties::val_region',
- mat_client_id String COMMENT 'column_materializer::properties::client_id',
- mat_$geoip_country_code String COMMENT 'column_materializer::properties::$geoip_country_code',
- mat_disfluencies String COMMENT 'column_materializer::properties::disfluencies',
- mat_filter_profanity String COMMENT 'column_materializer::properties::filter_profanity',
- mat_speaker_labels String COMMENT 'column_materializer::properties::speaker_labels',
- mat_language_detection String COMMENT 'column_materializer::properties::language_detection',
- mat_product_analytics_projected_amount String COMMENT 'column_materializer::properties::product_analytics_projected_amount',
- mat_recordings_projected_amount String COMMENT 'column_materializer::properties::recordings_projected_amount',
- mat_events_projected_amount String COMMENT 'column_materializer::properties::events_projected_amount',
- mat_session_replay_projected_amount String COMMENT 'column_materializer::properties::session_replay_projected_amount',
- mat_total_usd String COMMENT 'column_materializer::properties::total_usd',
- mat_stripe_amount_paid String COMMENT 'column_materializer::properties::stripe_amount_paid',
- mat_workspace String COMMENT 'column_materializer::properties::workspace',
- mat_created_at String COMMENT 'column_materializer::properties::created_at',
- mat_kind String COMMENT 'column_materializer::properties::kind',
- mat_product String COMMENT 'column_materializer::properties::product',
- mat_message String COMMENT 'column_materializer::properties::message',
- mat_initiator String COMMENT 'column_materializer::properties::initiator',
- mat_query String COMMENT 'column_materializer::properties::query',
- mat_$survey_id String COMMENT 'column_materializer::properties::$survey_id',
- mat_$survey_response_1 String COMMENT 'column_materializer::properties::$survey_response_1',
- mat_ticketId String COMMENT 'column_materializer::properties::ticketId',
- mat_$survey_response String COMMENT 'column_materializer::properties::$survey_response',
- mat_conceptName String COMMENT 'column_materializer::properties::conceptName',
- mat_apiName String COMMENT 'column_materializer::properties::apiName',
- mat_workplace_billing_plan String COMMENT 'column_materializer::properties::workplace_billing_plan',
- mat_$el_text String COMMENT 'column_materializer::properties::$el_text',
- mat_recording_count_in_period String COMMENT 'column_materializer::properties::recording_count_in_period',
- mat_$os_version String COMMENT 'column_materializer::properties::$os_version',
- mat_orderId String COMMENT 'column_materializer::properties::orderId',
- mat_commit_sha String COMMENT 'column_materializer::properties::commit_sha',
- mat_$feature_flag_payloads String COMMENT 'column_materializer::properties::$feature_flag_payloads',
- mat_event_count_in_period String COMMENT 'column_materializer::properties::event_count_in_period',
- mat_$groups String COMMENT 'column_materializer::properties::$groups',
- mat_$feature_flag String COMMENT 'column_materializer::properties::$feature_flag',
- mat_utm_content String COMMENT 'column_materializer::properties::utm_content',
- mat_gclid String COMMENT 'column_materializer::properties::gclid',
- mat_gad_source String COMMENT 'column_materializer::properties::gad_source',
- mat_gbraid String COMMENT 'column_materializer::properties::gbraid',
- mat_wbraid String COMMENT 'column_materializer::properties::wbraid',
- mat_fbclid String COMMENT 'column_materializer::properties::fbclid',
- mat_msclkid String COMMENT 'column_materializer::properties::msclkid',
- mat_organization_id String COMMENT 'column_materializer::properties::organization_id',
- mat_owner_type String COMMENT 'column_materializer::properties::owner_type',
- mat_device_type String COMMENT 'column_materializer::properties::device_type',
- mat_$device_id String COMMENT 'column_materializer::properties::$device_id',
- mat_pp_$geoip_continent_name String COMMENT 'column_materializer::person_properties::$geoip_continent_name',
- mat_$feature_flag_response String COMMENT 'column_materializer::properties::$feature_flag_response',
- mat_pp_utm_source String COMMENT 'column_materializer::person_properties::utm_source',
- mat_pp_$referring_domain String COMMENT 'column_materializer::person_properties::$referring_domain',
- mat_pp_Email_Domain String COMMENT 'column_materializer::person_properties::Email Domain',
- mat_machine_id String COMMENT 'column_materializer::properties::machine_id',
- mat_user_email_domain String COMMENT 'column_materializer::properties::user_email_domain',
- mat_$lib_version__minor String COMMENT 'column_materializer::properties::$lib_version__minor',
- mat_region String COMMENT 'column_materializer::properties::region',
- mat_pp_user_email_domain String COMMENT 'column_materializer::person_properties::user_email_domain',
- mat_url_promotion_id String COMMENT 'column_materializer::properties::url_promotion_id',
- mat_$lib_custom_api_host String COMMENT 'column_materializer::properties::$lib_custom_api_host',
person_mode Enum8('full'=0, 'propertyless'=1, 'force_upgrade'=2),
- mat_user_platform String COMMENT 'column_materializer::properties::user_platform',
- mat_pp_$geoip_country_name String COMMENT 'column_materializer::person_properties::$geoip_country_name',
- mat_environment String COMMENT 'column_materializer::properties::environment',
- mat_customer_email String COMMENT 'column_materializer::properties::customer_email',
- mat_client_name String COMMENT 'column_materializer::properties::client_name',
- mat_screen_name String COMMENT 'column_materializer::properties::screen_name',
- mat_app_version String COMMENT 'column_materializer::properties::app_version',
elements_chain_href String COMMENT 'column_materializer::elements_chain::href',
elements_chain_texts Array(String) COMMENT 'column_materializer::elements_chain::texts',
elements_chain_ids Array(String) COMMENT 'column_materializer::elements_chain::ids',
@@ -321,36 +61,11 @@ CREATE TABLE posthog.events (
properties_group_custom Map(String, String),
properties_group_feature_flags Map(String, String),
is_deleted Bool,
- mat_subdomain String COMMENT 'column_materializer::properties::subdomain',
- mat_$device String COMMENT 'column_materializer::properties::$device',
- mat_id String COMMENT 'column_materializer::properties::id',
- mat_record_id String COMMENT 'column_materializer::properties::record_id',
- mat_referrer_id String COMMENT 'column_materializer::properties::record_id',
- mat_$exception_issue_id Nullable(String) COMMENT 'column_materializer::properties::$exception_issue_id',
- mat_$exception_fingerprint Nullable(String) COMMENT 'column_materializer::properties::$exception_fingerprint',
- mat_$web_vitals_LCP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_LCP_value',
- mat_$web_vitals_FCP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_FCP_value',
- mat_$web_vitals_CLS_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_CLS_value',
- mat_$web_vitals_INP_value Nullable(String) COMMENT 'column_materializer::properties::$web_vitals_INP_value',
- mat_$viewport_width Nullable(String) COMMENT 'column_materializer::properties::$viewport_width',
- mat_$viewport_height Nullable(String) COMMENT 'column_materializer::properties::$viewport_height',
- mat_$anon_distinct_id Nullable(String) COMMENT 'column_materializer::properties::$anon_distinct_id',
person_properties_map_custom Map(String, String),
mat_$ai_trace_id Nullable(String) COMMENT 'column_materializer::properties::$ai_trace_id',
- mat_$ai_model Nullable(String) COMMENT 'column_materializer::properties::$ai_model',
- mat_$ai_provider Nullable(String) COMMENT 'column_materializer::properties::$ai_provider',
- mat_$ai_parent_id Nullable(String) COMMENT 'column_materializer::properties::$ai_parent_id',
- mat_$ai_span_id Nullable(String) COMMENT 'column_materializer::properties::$ai_span_id',
- mat_$ai_http_status Nullable(String) COMMENT 'column_materializer::properties::$ai_http_status',
- mat_$exception_types Nullable(String) COMMENT 'column_materializer::properties::$exception_types',
- mat_$exception_values Nullable(String) COMMENT 'column_materializer::properties::$exception_values',
- mat_$exception_sources Nullable(String) COMMENT 'column_materializer::properties::$exception_sources',
- mat_$exception_functions Nullable(String) COMMENT 'column_materializer::properties::$exception_functions',
$session_id_uuid Nullable(UInt128),
- mat_$process_person_profile Nullable(String) COMMENT 'column_materializer::properties::$process_person_profile',
consumer_breadcrumbs Array(String),
properties_group_ai Map(String, String),
- mat_$is_identified Nullable(String) COMMENT 'column_materializer::properties::$is_identified',
mat_historical_migration Nullable(String) COMMENT 'column_materializer::properties::historical_migration',
mat_$ai_session_id Nullable(String) COMMENT 'column_materializer::properties::$ai_session_id',
mat_$ai_is_error Nullable(String) COMMENT 'column_materializer::properties::$ai_is_error',
@@ -364,38 +79,7 @@ CREATE TABLE posthog.events (
dmat_string_7 Nullable(String),
dmat_string_8 Nullable(String),
dmat_string_9 Nullable(String),
- dmat_numeric_0 Nullable(Float64),
- dmat_numeric_1 Nullable(Float64),
- dmat_numeric_2 Nullable(Float64),
- dmat_numeric_3 Nullable(Float64),
- dmat_numeric_4 Nullable(Float64),
- dmat_numeric_5 Nullable(Float64),
- dmat_numeric_6 Nullable(Float64),
- dmat_numeric_7 Nullable(Float64),
- dmat_numeric_8 Nullable(Float64),
- dmat_numeric_9 Nullable(Float64),
- dmat_bool_0 Nullable(UInt8),
- dmat_bool_1 Nullable(UInt8),
- dmat_bool_2 Nullable(UInt8),
- dmat_bool_3 Nullable(UInt8),
- dmat_bool_4 Nullable(UInt8),
- dmat_bool_5 Nullable(UInt8),
- dmat_bool_6 Nullable(UInt8),
- dmat_bool_7 Nullable(UInt8),
- dmat_bool_8 Nullable(UInt8),
- dmat_bool_9 Nullable(UInt8),
- dmat_datetime_0 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_1 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_2 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_3 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_4 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_5 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_6 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_7 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_8 Nullable(DateTime64(6, 'UTC')),
- dmat_datetime_9 Nullable(DateTime64(6, 'UTC')),
historical_migration Bool,
- mat_$ai_total_cost_usd Nullable(String) COMMENT 'column_materializer::properties::$ai_total_cost_usd',
properties_group_ai_large Map(String, String),
mat_$ai_prompt_name Nullable(String) COMMENT 'column_materializer::properties::$ai_prompt_name'
) ENGINE = Distributed('posthog', 'posthog', 'sharded_events', sipHash64(distinct_id));
@@ -618,7 +302,7 @@ CREATE TABLE posthog.raw_sessions_v3 (
has_replay_events SimpleAggregateFunction(max, Bool),
INDEX event_names_bloom_filter event_names TYPE bloom_filter() GRANULARITY 1,
INDEX flag_keys_bloom_filter flag_keys TYPE bloom_filter() GRANULARITY 1
-) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3', '{shard}-{replica}') ORDER BY (team_id, session_timestamp, session_id_v7) PARTITION BY toYYYYMM(session_timestamp) SETTINGS index_granularity = 8192, replicated_deduplication_window = 0, replicated_deduplication_window_for_async_inserts = 0;
+) ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/sessions/noshard/posthog.raw_sessions_v3', '{shard}-{replica}') ORDER BY (team_id, session_timestamp, session_id_v7) PARTITION BY toYYYYMM(session_timestamp) SETTINGS index_granularity = 8192, max_replicated_merges_in_queue = 5, parts_to_delay_insert = 1500, parts_to_throw_insert = 2000, prefer_fetch_merged_part_size_threshold = 1, prefer_fetch_merged_part_time_threshold = 0, replicated_deduplication_window = 0, replicated_deduplication_window_for_async_inserts = 0, storage_policy = 's3_tiered';
CREATE TABLE posthog.sessions (
session_id String,
team_id Int64,
@@ -752,10 +436,10 @@ FROM system.query_log
WHERE type != 'QueryStart';
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('instance', hostname()) AS labels,
@@ -810,10 +494,10 @@ FROM
);
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,
+ [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
+ arrayJoin(arrayZip(names, `values`, descriptions, types)) AS tpl
SELECT
tpl.1 AS name,
map('table', `table`, 'instance', hostname()) AS labels,