-
Notifications
You must be signed in to change notification settings - Fork 336
feat: introduce clickhouse db init script #843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d3f88b6
feat: add init script
wrn14897 ef9b18b
feat: init otel_logs + otel_traces tables
wrn14897 bfb1b8c
feat: add more k8s attribute mat fields
wrn14897 f470f49
ci: use init-db.sh script
wrn14897 33f2442
feat: create custom db + address some feedbacks
wrn14897 587de32
feat: add hyperdx_sessions table + related mat fields
wrn14897 f1b8c42
feedback: add 'deployment.environment.name'
wrn14897 73ef60b
feedback: bump default ttl to 30d
wrn14897 8a04694
Merge branch 'main' into warren/introduce-ch-init-script
wrn14897 9a5de5d
Merge branch 'main' into warren/introduce-ch-init-script
wrn14897 5682582
docs: add changeset
wrn14897 8766441
Merge branch 'main' into warren/introduce-ch-init-script
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,7 @@ | ||
| --- | ||
| "@hyperdx/api": patch | ||
| "@hyperdx/app": patch | ||
| "@hyperdx/common-utils": patch | ||
| --- | ||
|
|
||
| feat: introduce clickhouse db init script |
This file contains hidden or 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 hidden or 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 hidden or 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,127 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| DATABASE=${HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE:-default} | ||
|
|
||
| clickhouse client -n <<EOFSQL | ||
| CREATE DATABASE IF NOT EXISTS ${DATABASE}; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS ${DATABASE}.otel_logs | ||
| ( | ||
| \`Timestamp\` DateTime64(9) CODEC(Delta(8), ZSTD(1)), | ||
| \`TimestampTime\` DateTime DEFAULT toDateTime(Timestamp), | ||
| \`TraceId\` String CODEC(ZSTD(1)), | ||
| \`SpanId\` String CODEC(ZSTD(1)), | ||
| \`TraceFlags\` UInt8, | ||
| \`SeverityText\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`SeverityNumber\` UInt8, | ||
| \`ServiceName\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`Body\` String CODEC(ZSTD(1)), | ||
| \`ResourceSchemaUrl\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`ResourceAttributes\` Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
| \`ScopeSchemaUrl\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`ScopeName\` String CODEC(ZSTD(1)), | ||
| \`ScopeVersion\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`ScopeAttributes\` Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
| \`LogAttributes\` Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_k8s.cluster.name\` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.cluster.name'] CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_k8s.container.name\` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.container.name'] CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_k8s.deployment.name\` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.deployment.name'] CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_k8s.namespace.name\` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.namespace.name'] CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_k8s.node.name\` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.node.name'] CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_k8s.pod.name\` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.pod.name'] CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_k8s.pod.uid\` LowCardinality(String) MATERIALIZED ResourceAttributes['k8s.pod.uid'] CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_deployment.environment.name\` LowCardinality(String) MATERIALIZED ResourceAttributes['deployment.environment.name'] 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_lower_body lower(Body) TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 8 | ||
| ) | ||
| ENGINE = MergeTree | ||
| PARTITION BY toDate(TimestampTime) | ||
| PRIMARY KEY (ServiceName, TimestampTime) | ||
| ORDER BY (ServiceName, TimestampTime, Timestamp) | ||
| TTL TimestampTime + toIntervalDay(30) | ||
| SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS ${DATABASE}.otel_traces | ||
| ( | ||
| \`Timestamp\` DateTime64(9) CODEC(Delta(8), 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\` UInt64 CODEC(ZSTD(1)), | ||
| \`StatusCode\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`StatusMessage\` String CODEC(ZSTD(1)), | ||
| \`Events.Timestamp\` Array(DateTime64(9)) CODEC(ZSTD(1)), | ||
| \`Events.Name\` Array(LowCardinality(String)) CODEC(ZSTD(1)), | ||
| \`Events.Attributes\` Array(Map(LowCardinality(String), String)) CODEC(ZSTD(1)), | ||
| \`Links.TraceId\` Array(String) CODEC(ZSTD(1)), | ||
| \`Links.SpanId\` Array(String) CODEC(ZSTD(1)), | ||
| \`Links.TraceState\` Array(String) CODEC(ZSTD(1)), | ||
| \`Links.Attributes\` Array(Map(LowCardinality(String), String)) CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_rum.sessionId\` String MATERIALIZED ResourceAttributes['rum.sessionId'] CODEC(ZSTD(1)), | ||
| INDEX idx_trace_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1, | ||
| INDEX idx_rum_session_id __hdx_materialized_rum.sessionId 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, | ||
| INDEX idx_lower_span_name lower(SpanName) TYPE tokenbf_v1(32768, 3, 0) GRANULARITY 8 | ||
| ) | ||
| ENGINE = MergeTree | ||
| PARTITION BY toDate(Timestamp) | ||
| ORDER BY (ServiceName, SpanName, toDateTime(Timestamp)) | ||
| TTL toDate(Timestamp) + toIntervalDay(30) | ||
| SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1; | ||
|
|
||
| CREATE TABLE ${DATABASE}.hyperdx_sessions | ||
| ( | ||
| \`Timestamp\` DateTime64(9) CODEC(Delta(8), ZSTD(1)), | ||
| \`TimestampTime\` DateTime DEFAULT toDateTime(Timestamp), | ||
| \`TraceId\` String CODEC(ZSTD(1)), | ||
| \`SpanId\` String CODEC(ZSTD(1)), | ||
| \`TraceFlags\` UInt8, | ||
| \`SeverityText\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`SeverityNumber\` UInt8, | ||
| \`ServiceName\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`Body\` String CODEC(ZSTD(1)), | ||
| \`ResourceSchemaUrl\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`ResourceAttributes\` Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
| \`ScopeSchemaUrl\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`ScopeName\` String CODEC(ZSTD(1)), | ||
| \`ScopeVersion\` LowCardinality(String) CODEC(ZSTD(1)), | ||
| \`ScopeAttributes\` Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
| \`LogAttributes\` Map(LowCardinality(String), String) CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_rum.sessionId\` String MATERIALIZED ResourceAttributes['rum.sessionId'] CODEC(ZSTD(1)), | ||
| \`__hdx_materialized_type\` LowCardinality(String) MATERIALIZED toString(simpleJSONExtractInt(Body, 'type')) CODEC(ZSTD(1)), | ||
| INDEX idx_trace_id TraceId TYPE bloom_filter(0.001) GRANULARITY 1, | ||
| INDEX idx_rum_session_id __hdx_materialized_rum.sessionId 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 8 | ||
| ) | ||
| ENGINE = MergeTree | ||
| PARTITION BY toDate(TimestampTime) | ||
| PRIMARY KEY (ServiceName, TimestampTime) | ||
| ORDER BY (ServiceName, TimestampTime, Timestamp) | ||
| TTL TimestampTime + toIntervalDay(30) | ||
| SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1 | ||
| EOFSQL | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.