diff --git a/cameleer3-server-app/src/main/resources/clickhouse/V4__stats_tables_and_mvs.sql b/cameleer3-server-app/src/main/resources/clickhouse/V4__stats_tables_and_mvs.sql index c35795ce..1aa1a6f0 100644 --- a/cameleer3-server-app/src/main/resources/clickhouse/V4__stats_tables_and_mvs.sql +++ b/cameleer3-server-app/src/main/resources/clickhouse/V4__stats_tables_and_mvs.sql @@ -137,6 +137,7 @@ CREATE TABLE IF NOT EXISTS stats_1m_processor_detail ( application_id LowCardinality(String), route_id LowCardinality(String), processor_id String, + processor_type LowCardinality(String), bucket DateTime, total_count AggregateFunction(count), failed_count AggregateFunction(countIf, UInt8), @@ -146,7 +147,7 @@ CREATE TABLE IF NOT EXISTS stats_1m_processor_detail ( ) ENGINE = AggregatingMergeTree() PARTITION BY (tenant_id, toYYYYMM(bucket)) -ORDER BY (tenant_id, application_id, route_id, processor_id, bucket) +ORDER BY (tenant_id, application_id, route_id, processor_id, processor_type, bucket) TTL bucket + INTERVAL 365 DAY DELETE; CREATE MATERIALIZED VIEW IF NOT EXISTS stats_1m_processor_detail_mv TO stats_1m_processor_detail AS @@ -155,6 +156,7 @@ SELECT application_id, route_id, processor_id, + processor_type, toStartOfMinute(start_time) AS bucket, countState() AS total_count, countIfState(status = 'FAILED') AS failed_count, @@ -162,4 +164,4 @@ SELECT maxState(duration_ms) AS duration_max, quantileState(0.99)(duration_ms) AS p99_duration FROM processor_executions -GROUP BY tenant_id, application_id, route_id, processor_id, bucket; +GROUP BY tenant_id, application_id, route_id, processor_id, processor_type, bucket;