From 1abf25dfafe9e8ebabdb1cbf78c648ff401469b2 Mon Sep 17 00:00:00 2001 From: nityanandagohain Date: Tue, 8 Aug 2023 15:51:48 +0530 Subject: [PATCH 1/2] feat: add default indexes for top level keys --- .../migrations/000007_default_indexes.down.sql | 5 +++++ .../migrations/000007_default_indexes.up.sql | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 exporter/clickhouselogsexporter/migrations/000007_default_indexes.down.sql create mode 100644 exporter/clickhouselogsexporter/migrations/000007_default_indexes.up.sql diff --git a/exporter/clickhouselogsexporter/migrations/000007_default_indexes.down.sql b/exporter/clickhouselogsexporter/migrations/000007_default_indexes.down.sql new file mode 100644 index 00000000..dd21eb16 --- /dev/null +++ b/exporter/clickhouselogsexporter/migrations/000007_default_indexes.down.sql @@ -0,0 +1,5 @@ +ALTER TABLE signoz_logs.logs ON CLUSTER cluster drop index IF EXISTS severity_number_idx; + +ALTER TABLE signoz_logs.logs ON CLUSTER cluster drop index IF EXISTS severity_text_idx; + +ALTER TABLE signoz_logs.logs ON CLUSTER cluster drop index IF EXISTS trace_flags_idx; \ No newline at end of file diff --git a/exporter/clickhouselogsexporter/migrations/000007_default_indexes.up.sql b/exporter/clickhouselogsexporter/migrations/000007_default_indexes.up.sql new file mode 100644 index 00000000..01c7024c --- /dev/null +++ b/exporter/clickhouselogsexporter/migrations/000007_default_indexes.up.sql @@ -0,0 +1,12 @@ +-- This migration adds default indexes to top level keys of the log model + +-- https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-severitynumber range 1-24 and 0 means it's not set +ALTER TABLE signoz_logs.logs ON CLUSTER cluster add index IF NOT EXISTS severity_number_idx (severity_number) TYPE set(25) GRANULARITY 4; + +-- https://opentelemetry.io/docs/specs/otel/logs/data-model/#displaying-severity 24 different values and empty means not set. +ALTER TABLE signoz_logs.logs ON CLUSTER cluster add index IF NOT EXISTS severity_text_idx (severity_text) TYPE set(25) GRANULARITY 4; + + +-- No point in addding index for trace_id, span_id as they are not set as they are always unique +-- trace_flags can be a set so adding a default bloom filter +ALTER TABLE signoz_logs.logs ON CLUSTER cluster add index IF NOT EXISTS trace_flags_idx (trace_flags) TYPE bloom_filter() GRANULARITY 4; \ No newline at end of file From cf1cdf306753c2c3e4be32ffa850b4b1991f988f Mon Sep 17 00:00:00 2001 From: nityanandagohain Date: Tue, 8 Aug 2023 15:53:36 +0530 Subject: [PATCH 2/2] fix: comment updated --- .../migrations/000007_default_indexes.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/clickhouselogsexporter/migrations/000007_default_indexes.up.sql b/exporter/clickhouselogsexporter/migrations/000007_default_indexes.up.sql index 01c7024c..b0e98cb0 100644 --- a/exporter/clickhouselogsexporter/migrations/000007_default_indexes.up.sql +++ b/exporter/clickhouselogsexporter/migrations/000007_default_indexes.up.sql @@ -7,6 +7,6 @@ ALTER TABLE signoz_logs.logs ON CLUSTER cluster add index IF NOT EXISTS severity ALTER TABLE signoz_logs.logs ON CLUSTER cluster add index IF NOT EXISTS severity_text_idx (severity_text) TYPE set(25) GRANULARITY 4; --- No point in addding index for trace_id, span_id as they are not set as they are always unique +-- No point in addding index for trace_id, span_id as they are not set and they are always unique -- trace_flags can be a set so adding a default bloom filter ALTER TABLE signoz_logs.logs ON CLUSTER cluster add index IF NOT EXISTS trace_flags_idx (trace_flags) TYPE bloom_filter() GRANULARITY 4; \ No newline at end of file