Skip to content

Instantly share code, notes, and snippets.

@caseyduquettesc
Created December 1, 2020 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caseyduquettesc/0a026f549366728b9733ff60c0b956ec to your computer and use it in GitHub Desktop.
Save caseyduquettesc/0a026f549366728b9733ff60c0b956ec to your computer and use it in GitHub Desktop.
sentry clickhouse ddl's
CREATE TABLE default.sentry_dist (
`event_id` FixedString(32),
`project_id` UInt64,
`group_id` UInt64,
`timestamp` DateTime,
`deleted` UInt8,
`retention_days` UInt16,
`platform` Nullable(String),
`message` Nullable(String),
`primary_hash` Nullable(FixedString(32)),
`received` Nullable(DateTime),
`search_message` Nullable(String),
`title` Nullable(String),
`location` Nullable(String),
`user_id` Nullable(String),
`username` Nullable(String),
`email` Nullable(String),
`ip_address` Nullable(String),
`geo_country_code` Nullable(String),
`geo_region` Nullable(String),
`geo_city` Nullable(String),
`sdk_name` Nullable(String),
`sdk_version` Nullable(String),
`type` Nullable(String),
`version` Nullable(String),
`offset` Nullable(UInt64),
`partition` Nullable(UInt16),
`message_timestamp` Nullable(DateTime),
`os_build` Nullable(String),
`os_kernel_version` Nullable(String),
`device_name` Nullable(String),
`device_brand` Nullable(String),
`device_locale` Nullable(String),
`device_uuid` Nullable(String),
`device_model_id` Nullable(String),
`device_arch` Nullable(String),
`device_battery_level` Nullable(Float32),
`device_orientation` Nullable(String),
`device_simulator` Nullable(UInt8),
`device_online` Nullable(UInt8),
`device_charging` Nullable(UInt8),
`level` Nullable(String),
`logger` Nullable(String),
`server_name` Nullable(String),
`transaction` Nullable(String),
`environment` Nullable(String),
`sentry:release` Nullable(String),
`sentry:dist` Nullable(String),
`sentry:user` Nullable(String),
`site` Nullable(String),
`url` Nullable(String),
`app_device` Nullable(String),
`device` Nullable(String),
`device_family` Nullable(String),
`runtime` Nullable(String),
`runtime_name` Nullable(String),
`browser` Nullable(String),
`browser_name` Nullable(String),
`os` Nullable(String),
`os_name` Nullable(String),
`os_rooted` Nullable(UInt8),
`tags.key` Array(String),
`tags.value` Array(String),
`_tags_flattened` Nullable(String),
`contexts.key` Array(String),
`contexts.value` Array(String),
`http_method` Nullable(String),
`http_referer` Nullable(String),
`exception_stacks.type` Array(Nullable(String)),
`exception_stacks.value` Array(Nullable(String)),
`exception_stacks.mechanism_type` Array(Nullable(String)),
`exception_stacks.mechanism_handled` Array(Nullable(UInt8)),
`exception_frames.abs_path` Array(Nullable(String)),
`exception_frames.filename` Array(Nullable(String)),
`exception_frames.package` Array(Nullable(String)),
`exception_frames.module` Array(Nullable(String)),
`exception_frames.function` Array(Nullable(String)),
`exception_frames.in_app` Array(Nullable(UInt8)),
`exception_frames.colno` Array(Nullable(UInt32)),
`exception_frames.lineno` Array(Nullable(UInt32)),
`exception_frames.stack_level` Array(UInt16),
`culprit` Nullable(String),
`sdk_integrations` Array(String),
`modules.name` Array(String),
`modules.version` Array(String)
) ENGINE = Distributed(
clicks_cluster,
default,
sentry_local,
cityHash64(toString(event_id))
)
CREATE TABLE default.sentry_local (
`event_id` FixedString(32),
`project_id` UInt64,
`group_id` UInt64,
`timestamp` DateTime,
`deleted` UInt8,
`retention_days` UInt16,
`platform` Nullable(String),
`message` Nullable(String),
`primary_hash` Nullable(FixedString(32)),
`received` Nullable(DateTime),
`search_message` Nullable(String),
`title` Nullable(String),
`location` Nullable(String),
`user_id` Nullable(String),
`username` Nullable(String),
`email` Nullable(String),
`ip_address` Nullable(String),
`geo_country_code` Nullable(String),
`geo_region` Nullable(String),
`geo_city` Nullable(String),
`sdk_name` Nullable(String),
`sdk_version` Nullable(String),
`type` Nullable(String),
`version` Nullable(String),
`offset` Nullable(UInt64),
`partition` Nullable(UInt16),
`message_timestamp` Nullable(DateTime),
`os_build` Nullable(String),
`os_kernel_version` Nullable(String),
`device_name` Nullable(String),
`device_brand` Nullable(String),
`device_locale` Nullable(String),
`device_uuid` Nullable(String),
`device_model_id` Nullable(String),
`device_arch` Nullable(String),
`device_battery_level` Nullable(Float32),
`device_orientation` Nullable(String),
`device_simulator` Nullable(UInt8),
`device_online` Nullable(UInt8),
`device_charging` Nullable(UInt8),
`level` Nullable(String),
`logger` Nullable(String),
`server_name` Nullable(String),
`transaction` Nullable(String),
`environment` Nullable(String),
`sentry:release` Nullable(String),
`sentry:dist` Nullable(String),
`sentry:user` Nullable(String),
`site` Nullable(String),
`url` Nullable(String),
`app_device` Nullable(String),
`device` Nullable(String),
`device_family` Nullable(String),
`runtime` Nullable(String),
`runtime_name` Nullable(String),
`browser` Nullable(String),
`browser_name` Nullable(String),
`os` Nullable(String),
`os_name` Nullable(String),
`os_rooted` Nullable(UInt8),
`tags.key` Array(String),
`tags.value` Array(String),
`_tags_flattened` Nullable(String),
`_tags_hash_map` Array(UInt64) MATERIALIZED arrayMap(
(k, v) -> cityHash64(
concat(
replaceRegexpAll(k, '(\\=|\\\\)', '\\\\\\1'),
'=',
v
)
),
tags.key,
tags.value
),
`contexts.key` Array(String),
`contexts.value` Array(String),
`http_method` Nullable(String),
`http_referer` Nullable(String),
`exception_stacks.type` Array(Nullable(String)),
`exception_stacks.value` Array(Nullable(String)),
`exception_stacks.mechanism_type` Array(Nullable(String)),
`exception_stacks.mechanism_handled` Array(Nullable(UInt8)),
`exception_frames.abs_path` Array(Nullable(String)),
`exception_frames.filename` Array(Nullable(String)),
`exception_frames.package` Array(Nullable(String)),
`exception_frames.module` Array(Nullable(String)),
`exception_frames.function` Array(Nullable(String)),
`exception_frames.in_app` Array(Nullable(UInt8)),
`exception_frames.colno` Array(Nullable(UInt32)),
`exception_frames.lineno` Array(Nullable(UInt32)),
`exception_frames.stack_level` Array(UInt16),
`culprit` Nullable(String),
`sdk_integrations` Array(String),
`modules.name` Array(String),
`modules.version` Array(String)
) ENGINE = ReplicatedReplacingMergeTree(
'/clickhouse/tables/{shard}/sentry_local',
'{replica}',
deleted
) PARTITION BY (
toMonday(timestamp),
if(retention_days = 30, 30, 90)
)
ORDER BY
(
project_id,
toStartOfDay(timestamp),
cityHash64(toString(event_id))
) SAMPLE BY cityHash64(toString(event_id)) SETTINGS index_granularity = 8192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment