-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[exporter/clickhouse] Add
create_schema
option to config (#32282)
**Description:** Adds `create_schema` boolean to config. This flag will disable the automatic creation of the database and tables so that this can be manually managed by the user. **Link to tracking Issue:** #29443 (related) **Testing:** Ran integration tests, and added test for verifying undefined + true + false in for the value in the config. **Documentation:** Added config option to README along with new "schema management" section that contains some recommendations for production deployments as well as requirements for maintaining compatibility. Also added `examples/default_ddl/` which contains all of the default DDL that the exporter runs. These are to be used as a starting point for users managing their own schema. --------- Co-authored-by: Pablo Baeyens <[email protected]>
- Loading branch information
1 parent
7cc24ff
commit ed0cf90
Showing
14 changed files
with
304 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: clickhouseexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: "Add `create_schema` option to ClickHouse exporter" | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [32282] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: The new create_schema option allows disabling default DDL to let the user manage their own schema. | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- Default database DDL (uses "default" by default, but this is example for non-default database) | ||
|
||
CREATE DATABASE IF NOT EXISTS otel; |
42 changes: 42 additions & 0 deletions
42
exporter/clickhouseexporter/example/default_ddl/histogram_metrics.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- Default Histogram metrics table DDL | ||
|
||
CREATE TABLE IF NOT EXISTS otel_metrics_histogram ( | ||
ResourceAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
ResourceSchemaUrl String CODEC(ZSTD(1)), | ||
ScopeName String CODEC(ZSTD(1)), | ||
ScopeVersion String CODEC(ZSTD(1)), | ||
ScopeAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
ScopeDroppedAttrCount UInt32 CODEC(ZSTD(1)), | ||
ScopeSchemaUrl String CODEC(ZSTD(1)), | ||
ServiceName LowCardinality(String) CODEC(ZSTD(1)), | ||
MetricName String CODEC(ZSTD(1)), | ||
MetricDescription String CODEC(ZSTD(1)), | ||
MetricUnit String CODEC(ZSTD(1)), | ||
Attributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
StartTimeUnix DateTime64(9) CODEC(Delta, ZSTD(1)), | ||
TimeUnix DateTime64(9) CODEC(Delta, ZSTD(1)), | ||
Count UInt64 CODEC(Delta, ZSTD(1)), | ||
Sum Float64 CODEC(ZSTD(1)), | ||
BucketCounts Array(UInt64) CODEC(ZSTD(1)), | ||
ExplicitBounds Array(Float64) CODEC(ZSTD(1)), | ||
Exemplars Nested ( | ||
FilteredAttributes Map(LowCardinality(String), String), | ||
TimeUnix DateTime64(9), | ||
Value Float64, | ||
SpanId String, | ||
TraceId String | ||
) CODEC(ZSTD(1)), | ||
Flags UInt32 CODEC(ZSTD(1)), | ||
Min Float64 CODEC(ZSTD(1)), | ||
Max Float64 CODEC(ZSTD(1)), | ||
INDEX idx_res_attr_key mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_res_attr_value mapValues(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_scope_attr_key mapKeys(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_scope_attr_value mapValues(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_attr_key mapKeys(Attributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_attr_value mapValues(Attributes) TYPE bloom_filter(0.01) GRANULARITY 1 | ||
) ENGINE = MergeTree() | ||
TTL toDateTime("TimeUnix") + toIntervalDay(180) | ||
PARTITION BY toDate(TimeUnix) | ||
ORDER BY (ServiceName, MetricName, Attributes, toUnixTimestamp64Nano(TimeUnix)) | ||
SETTINGS index_granularity=8192, ttl_only_drop_parts = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
-- Default Logs table DDL | ||
|
||
CREATE TABLE IF NOT EXISTS otel_logs ( | ||
Timestamp DateTime64(9) CODEC(Delta, ZSTD(1)), | ||
TraceId String CODEC(ZSTD(1)), | ||
SpanId String CODEC(ZSTD(1)), | ||
TraceFlags UInt32 CODEC(ZSTD(1)), | ||
SeverityText LowCardinality(String) CODEC(ZSTD(1)), | ||
SeverityNumber Int32 CODEC(ZSTD(1)), | ||
ServiceName LowCardinality(String) CODEC(ZSTD(1)), | ||
Body String CODEC(ZSTD(1)), | ||
ResourceSchemaUrl String CODEC(ZSTD(1)), | ||
ResourceAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
ScopeSchemaUrl String CODEC(ZSTD(1)), | ||
ScopeName String CODEC(ZSTD(1)), | ||
ScopeVersion String CODEC(ZSTD(1)), | ||
ScopeAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
LogAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
INDEX idx_trace_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1, | ||
INDEX idx_res_attr_key mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_res_attr_value mapValues(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_scope_attr_key mapKeys(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_scope_attr_value mapValues(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_log_attr_key mapKeys(LogAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_log_attr_value mapValues(LogAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_body Body TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 1 | ||
) ENGINE = MergeTree() | ||
TTL toDateTime("Timestamp") + toIntervalDay(180) | ||
PARTITION BY toDate(Timestamp) | ||
ORDER BY (ServiceName, SeverityText, toUnixTimestamp(Timestamp), TraceId) | ||
SETTINGS index_granularity=8192, ttl_only_drop_parts = 1; |
39 changes: 39 additions & 0 deletions
39
exporter/clickhouseexporter/example/default_ddl/sum_metrics.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- Default Sum metrics table DDL | ||
|
||
CREATE TABLE IF NOT EXISTS otel_metrics_sum ( | ||
ResourceAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
ResourceSchemaUrl String CODEC(ZSTD(1)), | ||
ScopeName String CODEC(ZSTD(1)), | ||
ScopeVersion String CODEC(ZSTD(1)), | ||
ScopeAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
ScopeDroppedAttrCount UInt32 CODEC(ZSTD(1)), | ||
ScopeSchemaUrl String CODEC(ZSTD(1)), | ||
ServiceName LowCardinality(String) CODEC(ZSTD(1)), | ||
MetricName String CODEC(ZSTD(1)), | ||
MetricDescription String CODEC(ZSTD(1)), | ||
MetricUnit String CODEC(ZSTD(1)), | ||
Attributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
StartTimeUnix DateTime64(9) CODEC(Delta, ZSTD(1)), | ||
TimeUnix DateTime64(9) CODEC(Delta, ZSTD(1)), | ||
Value Float64 CODEC(ZSTD(1)), | ||
Flags UInt32 CODEC(ZSTD(1)), | ||
Exemplars Nested ( | ||
FilteredAttributes Map(LowCardinality(String), String), | ||
TimeUnix DateTime64(9), | ||
Value Float64, | ||
SpanId String, | ||
TraceId String | ||
) CODEC(ZSTD(1)), | ||
AggTemp Int32 CODEC(ZSTD(1)), | ||
IsMonotonic Boolean CODEC(Delta, ZSTD(1)), | ||
INDEX idx_res_attr_key mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_res_attr_value mapValues(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_scope_attr_key mapKeys(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_scope_attr_value mapValues(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_attr_key mapKeys(Attributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_attr_value mapValues(Attributes) TYPE bloom_filter(0.01) GRANULARITY 1 | ||
) ENGINE = MergeTree() | ||
TTL toDateTime("TimeUnix") + toIntervalDay(180) | ||
PARTITION BY toDate(TimeUnix) | ||
ORDER BY (ServiceName, MetricName, Attributes, toUnixTimestamp64Nano(TimeUnix)) | ||
SETTINGS index_granularity=8192, ttl_only_drop_parts = 1; |
35 changes: 35 additions & 0 deletions
35
exporter/clickhouseexporter/example/default_ddl/summary_metrics.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- Default Summary metrics DDL | ||
|
||
CREATE TABLE IF NOT EXISTS otel_metrics_summary ( | ||
ResourceAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
ResourceSchemaUrl String CODEC(ZSTD(1)), | ||
ScopeName String CODEC(ZSTD(1)), | ||
ScopeVersion String CODEC(ZSTD(1)), | ||
ScopeAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
ScopeDroppedAttrCount UInt32 CODEC(ZSTD(1)), | ||
ScopeSchemaUrl String CODEC(ZSTD(1)), | ||
ServiceName LowCardinality(String) CODEC(ZSTD(1)), | ||
MetricName String CODEC(ZSTD(1)), | ||
MetricDescription String CODEC(ZSTD(1)), | ||
MetricUnit String CODEC(ZSTD(1)), | ||
Attributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
StartTimeUnix DateTime64(9) CODEC(Delta, ZSTD(1)), | ||
TimeUnix DateTime64(9) CODEC(Delta, ZSTD(1)), | ||
Count UInt64 CODEC(Delta, ZSTD(1)), | ||
Sum Float64 CODEC(ZSTD(1)), | ||
ValueAtQuantiles Nested( | ||
Quantile Float64, | ||
Value Float64 | ||
) CODEC(ZSTD(1)), | ||
Flags UInt32 CODEC(ZSTD(1)), | ||
INDEX idx_res_attr_key mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_res_attr_value mapValues(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_scope_attr_key mapKeys(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_scope_attr_value mapValues(ScopeAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_attr_key mapKeys(Attributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_attr_value mapValues(Attributes) TYPE bloom_filter(0.01) GRANULARITY 1 | ||
) ENGINE = MergeTree() | ||
TTL toDateTime("TimeUnix") + toIntervalDay(180) | ||
PARTITION BY toDate(TimeUnix) | ||
ORDER BY (ServiceName, MetricName, Attributes, toUnixTimestamp64Nano(TimeUnix)) | ||
SETTINGS index_granularity=8192, ttl_only_drop_parts = 1; |
40 changes: 40 additions & 0 deletions
40
exporter/clickhouseexporter/example/default_ddl/traces.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
-- Default Trace table DDL | ||
|
||
CREATE TABLE IF NOT EXISTS otel_traces ( | ||
Timestamp DateTime64(9) CODEC(Delta, ZSTD(1)), | ||
TraceId String CODEC(ZSTD(1)), | ||
SpanId String CODEC(ZSTD(1)), | ||
ParentSpanId String CODEC(ZSTD(1)), | ||
TraceState String CODEC(ZSTD(1)), | ||
SpanName LowCardinality(String) CODEC(ZSTD(1)), | ||
SpanKind LowCardinality(String) CODEC(ZSTD(1)), | ||
ServiceName LowCardinality(String) CODEC(ZSTD(1)), | ||
ResourceAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
ScopeName String CODEC(ZSTD(1)), | ||
ScopeVersion String CODEC(ZSTD(1)), | ||
SpanAttributes Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
Duration Int64 CODEC(ZSTD(1)), | ||
StatusCode LowCardinality(String) CODEC(ZSTD(1)), | ||
StatusMessage String CODEC(ZSTD(1)), | ||
Events Nested ( | ||
Timestamp DateTime64(9), | ||
Name LowCardinality(String), | ||
Attributes Map(LowCardinality(String), String) | ||
) CODEC(ZSTD(1)), | ||
Links Nested ( | ||
TraceId String, | ||
SpanId String, | ||
TraceState String, | ||
Attributes Map(LowCardinality(String), String) | ||
) CODEC(ZSTD(1)), | ||
INDEX idx_trace_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1, | ||
INDEX idx_res_attr_key mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_res_attr_value mapValues(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_span_attr_key mapKeys(SpanAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_span_attr_value mapValues(SpanAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, | ||
INDEX idx_duration Duration TYPE minmax GRANULARITY 1 | ||
) ENGINE = MergeTree() | ||
TTL toDateTime("Timestamp") + toIntervalDay(180) | ||
PARTITION BY toDate(Timestamp) | ||
ORDER BY (ServiceName, SpanName, toUnixTimestamp(Timestamp), TraceId) | ||
SETTINGS index_granularity=8192, ttl_only_drop_parts = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.