From f7daadaaa94864090950857e48ea8627e4d1f536 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Tue, 31 Mar 2026 23:30:38 +0200 Subject: [PATCH] feat(clickhouse): add DDL for route_diagrams, agent_events, and logs tables Co-Authored-By: Claude Opus 4.6 (1M context) --- .../clickhouse/V6__route_diagrams.sql | 12 ++++++++++ .../resources/clickhouse/V7__agent_events.sql | 12 ++++++++++ .../main/resources/clickhouse/V8__logs.sql | 22 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 cameleer3-server-app/src/main/resources/clickhouse/V6__route_diagrams.sql create mode 100644 cameleer3-server-app/src/main/resources/clickhouse/V7__agent_events.sql create mode 100644 cameleer3-server-app/src/main/resources/clickhouse/V8__logs.sql diff --git a/cameleer3-server-app/src/main/resources/clickhouse/V6__route_diagrams.sql b/cameleer3-server-app/src/main/resources/clickhouse/V6__route_diagrams.sql new file mode 100644 index 00000000..0dd53568 --- /dev/null +++ b/cameleer3-server-app/src/main/resources/clickhouse/V6__route_diagrams.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS route_diagrams ( + tenant_id LowCardinality(String) DEFAULT 'default', + content_hash String, + route_id LowCardinality(String), + agent_id LowCardinality(String), + application_name LowCardinality(String), + definition String, + created_at DateTime64(3) DEFAULT now64(3) +) +ENGINE = ReplacingMergeTree(created_at) +ORDER BY (tenant_id, content_hash) +SETTINGS index_granularity = 8192; diff --git a/cameleer3-server-app/src/main/resources/clickhouse/V7__agent_events.sql b/cameleer3-server-app/src/main/resources/clickhouse/V7__agent_events.sql new file mode 100644 index 00000000..4fc1d9b3 --- /dev/null +++ b/cameleer3-server-app/src/main/resources/clickhouse/V7__agent_events.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS agent_events ( + tenant_id LowCardinality(String) DEFAULT 'default', + timestamp DateTime64(3) DEFAULT now64(3), + agent_id LowCardinality(String), + app_id LowCardinality(String), + event_type LowCardinality(String), + detail String DEFAULT '' +) +ENGINE = MergeTree() +PARTITION BY (tenant_id, toYYYYMM(timestamp)) +ORDER BY (tenant_id, app_id, agent_id, timestamp) +TTL toDateTime(timestamp) + INTERVAL 365 DAY DELETE; diff --git a/cameleer3-server-app/src/main/resources/clickhouse/V8__logs.sql b/cameleer3-server-app/src/main/resources/clickhouse/V8__logs.sql new file mode 100644 index 00000000..41ce45aa --- /dev/null +++ b/cameleer3-server-app/src/main/resources/clickhouse/V8__logs.sql @@ -0,0 +1,22 @@ +CREATE TABLE IF NOT EXISTS logs ( + tenant_id LowCardinality(String) DEFAULT 'default', + timestamp DateTime64(3), + application LowCardinality(String), + agent_id LowCardinality(String), + level LowCardinality(String), + logger_name LowCardinality(String) DEFAULT '', + message String, + thread_name LowCardinality(String) DEFAULT '', + stack_trace String DEFAULT '', + exchange_id String DEFAULT '', + mdc Map(String, String) DEFAULT map(), + + INDEX idx_msg message TYPE ngrambf_v1(3, 256, 2, 0) GRANULARITY 4, + INDEX idx_stack stack_trace TYPE ngrambf_v1(3, 256, 2, 0) GRANULARITY 4, + INDEX idx_level level TYPE set(10) GRANULARITY 1 +) +ENGINE = MergeTree() +PARTITION BY (tenant_id, toYYYYMM(timestamp)) +ORDER BY (tenant_id, application, timestamp) +TTL toDateTime(timestamp) + INTERVAL 365 DAY DELETE +SETTINGS index_granularity = 8192;