2022-09-01 06:44:49 +02:00
|
|
|
SET allow_experimental_object_type = 1;
|
|
|
|
|
2022-09-12 18:55:34 +02:00
|
|
|
-- Create Event
|
2023-03-29 20:06:12 +02:00
|
|
|
CREATE TABLE umami.website_event
|
2022-08-05 05:15:21 +02:00
|
|
|
(
|
2022-10-09 01:12:33 +02:00
|
|
|
website_id UUID,
|
|
|
|
session_id UUID,
|
2023-03-23 07:02:37 +01:00
|
|
|
event_id UUID,
|
2022-09-12 18:55:34 +02:00
|
|
|
--session
|
2022-08-05 05:15:21 +02:00
|
|
|
hostname LowCardinality(String),
|
|
|
|
browser LowCardinality(String),
|
|
|
|
os LowCardinality(String),
|
|
|
|
device LowCardinality(String),
|
|
|
|
screen LowCardinality(String),
|
|
|
|
language LowCardinality(String),
|
2022-09-12 18:55:34 +02:00
|
|
|
country LowCardinality(String),
|
2023-02-20 18:04:20 +01:00
|
|
|
subdivision1 LowCardinality(String),
|
2023-02-16 18:52:07 +01:00
|
|
|
subdivision2 LowCardinality(String),
|
2023-02-15 18:40:49 +01:00
|
|
|
city String,
|
2022-09-12 18:55:34 +02:00
|
|
|
--pageview
|
2023-03-15 01:27:17 +01:00
|
|
|
url_path String,
|
|
|
|
url_query String,
|
|
|
|
referrer_path String,
|
|
|
|
referrer_query String,
|
|
|
|
referrer_domain String,
|
2023-02-15 18:40:49 +01:00
|
|
|
page_title String,
|
2022-09-12 18:55:34 +02:00
|
|
|
--event
|
2022-12-13 04:45:38 +01:00
|
|
|
event_type UInt32,
|
2022-09-12 18:55:34 +02:00
|
|
|
event_name String,
|
2023-06-26 17:19:52 +02:00
|
|
|
created_at DateTime('UTC'),
|
2023-06-26 19:32:23 +02:00
|
|
|
job_id UUID
|
2022-08-05 05:15:21 +02:00
|
|
|
)
|
2022-09-12 18:55:34 +02:00
|
|
|
engine = MergeTree
|
2022-10-12 06:02:15 +02:00
|
|
|
ORDER BY (website_id, session_id, created_at)
|
2022-08-05 05:15:21 +02:00
|
|
|
SETTINGS index_granularity = 8192;
|
|
|
|
|
2023-03-29 20:06:12 +02:00
|
|
|
CREATE TABLE umami.website_event_queue (
|
2022-10-09 01:12:33 +02:00
|
|
|
website_id UUID,
|
|
|
|
session_id UUID,
|
2023-03-23 07:02:37 +01:00
|
|
|
event_id UUID,
|
2023-02-15 18:40:49 +01:00
|
|
|
--session
|
2022-08-05 05:15:21 +02:00
|
|
|
hostname LowCardinality(String),
|
|
|
|
browser LowCardinality(String),
|
|
|
|
os LowCardinality(String),
|
|
|
|
device LowCardinality(String),
|
|
|
|
screen LowCardinality(String),
|
|
|
|
language LowCardinality(String),
|
2022-09-12 18:55:34 +02:00
|
|
|
country LowCardinality(String),
|
2023-02-16 18:52:07 +01:00
|
|
|
subdivision1 LowCardinality(String),
|
|
|
|
subdivision2 LowCardinality(String),
|
2023-02-15 18:40:49 +01:00
|
|
|
city String,
|
|
|
|
--pageview
|
2023-03-15 01:27:17 +01:00
|
|
|
url_path String,
|
|
|
|
url_query String,
|
|
|
|
referrer_path String,
|
|
|
|
referrer_query String,
|
|
|
|
referrer_domain String,
|
2023-02-15 18:40:49 +01:00
|
|
|
page_title String,
|
|
|
|
--event
|
2022-12-13 04:45:38 +01:00
|
|
|
event_type UInt32,
|
2022-08-17 00:27:59 +02:00
|
|
|
event_name String,
|
2023-05-08 08:13:40 +02:00
|
|
|
created_at DateTime('UTC'),
|
|
|
|
--virtual columns
|
|
|
|
_error String,
|
|
|
|
_raw_message String
|
2022-08-05 05:15:21 +02:00
|
|
|
)
|
|
|
|
ENGINE = Kafka
|
2022-10-12 08:10:32 +02:00
|
|
|
SETTINGS kafka_broker_list = 'domain:9092,domain:9093,domain:9094', -- input broker list
|
2022-08-05 05:15:21 +02:00
|
|
|
kafka_topic_list = 'event',
|
|
|
|
kafka_group_name = 'event_consumer_group',
|
|
|
|
kafka_format = 'JSONEachRow',
|
|
|
|
kafka_max_block_size = 1048576,
|
2023-05-08 08:13:40 +02:00
|
|
|
kafka_handle_error_mode = 'stream'
|
2022-08-05 05:15:21 +02:00
|
|
|
|
2023-03-29 20:06:12 +02:00
|
|
|
CREATE MATERIALIZED VIEW umami.website_event_queue_mv TO umami.website_event AS
|
2022-10-12 06:02:15 +02:00
|
|
|
SELECT website_id,
|
|
|
|
session_id,
|
2022-10-09 01:12:33 +02:00
|
|
|
event_id,
|
2022-09-12 18:55:34 +02:00
|
|
|
hostname,
|
|
|
|
browser,
|
|
|
|
os,
|
|
|
|
device,
|
|
|
|
screen,
|
|
|
|
language,
|
|
|
|
country,
|
2023-02-16 18:52:07 +01:00
|
|
|
subdivision1,
|
|
|
|
subdivision2,
|
2023-02-15 18:40:49 +01:00
|
|
|
city,
|
2023-03-20 19:26:45 +01:00
|
|
|
url_path,
|
|
|
|
url_query,
|
|
|
|
referrer_path,
|
|
|
|
referrer_query,
|
|
|
|
referrer_domain,
|
2023-02-15 18:40:49 +01:00
|
|
|
page_title,
|
2022-12-13 04:45:38 +01:00
|
|
|
event_type,
|
2022-08-17 00:27:59 +02:00
|
|
|
event_name,
|
2022-09-12 18:55:34 +02:00
|
|
|
created_at
|
2023-03-29 20:06:12 +02:00
|
|
|
FROM umami.website_event_queue;
|
2023-03-23 07:02:37 +01:00
|
|
|
|
2023-05-08 08:13:40 +02:00
|
|
|
CREATE MATERIALIZED VIEW umami.website_event_errors_mv
|
|
|
|
(
|
|
|
|
error String,
|
|
|
|
raw String
|
|
|
|
)
|
|
|
|
ENGINE = MergeTree
|
|
|
|
ORDER BY (error, raw)
|
|
|
|
SETTINGS index_granularity = 8192 AS
|
|
|
|
SELECT _error AS error,
|
|
|
|
_raw_message AS raw
|
|
|
|
FROM umami.website_event_queue
|
|
|
|
WHERE length(_error) > 0
|
|
|
|
|
2023-03-23 07:02:37 +01:00
|
|
|
CREATE TABLE umami.event_data
|
|
|
|
(
|
|
|
|
website_id UUID,
|
|
|
|
session_id UUID,
|
|
|
|
event_id UUID,
|
|
|
|
url_path String,
|
|
|
|
event_name String,
|
|
|
|
event_key String,
|
2023-06-01 06:46:49 +02:00
|
|
|
string_value Nullable(String),
|
2023-07-07 06:02:56 +02:00
|
|
|
number_value Nullable(Decimal64(4)), --922337203685477.5625
|
2023-06-01 06:46:49 +02:00
|
|
|
date_value Nullable(DateTime('UTC')),
|
|
|
|
data_type UInt32,
|
2023-06-26 17:19:52 +02:00
|
|
|
created_at DateTime('UTC'),
|
2023-06-26 19:32:23 +02:00
|
|
|
job_id UUID
|
2023-03-23 07:02:37 +01:00
|
|
|
)
|
|
|
|
engine = MergeTree
|
2023-03-23 22:01:15 +01:00
|
|
|
ORDER BY (website_id, event_id, event_key, created_at)
|
2023-03-23 07:02:37 +01:00
|
|
|
SETTINGS index_granularity = 8192;
|
|
|
|
|
2023-03-23 22:17:32 +01:00
|
|
|
CREATE TABLE umami.event_data_queue (
|
2023-03-23 07:02:37 +01:00
|
|
|
website_id UUID,
|
|
|
|
session_id UUID,
|
|
|
|
event_id UUID,
|
|
|
|
url_path String,
|
|
|
|
event_name String,
|
|
|
|
event_key String,
|
2023-06-01 06:46:49 +02:00
|
|
|
string_value Nullable(String),
|
2023-07-07 06:02:56 +02:00
|
|
|
number_value Nullable(Decimal64(4)), --922337203685477.5625
|
2023-06-01 06:46:49 +02:00
|
|
|
date_value Nullable(DateTime('UTC')),
|
|
|
|
data_type UInt32,
|
2023-05-08 08:13:40 +02:00
|
|
|
created_at DateTime('UTC'),
|
|
|
|
--virtual columns
|
|
|
|
_error String,
|
|
|
|
_raw_message String
|
2023-03-23 07:02:37 +01:00
|
|
|
)
|
|
|
|
ENGINE = Kafka
|
|
|
|
SETTINGS kafka_broker_list = 'domain:9092,domain:9093,domain:9094', -- input broker list
|
|
|
|
kafka_topic_list = 'event_data',
|
|
|
|
kafka_group_name = 'event_data_consumer_group',
|
|
|
|
kafka_format = 'JSONEachRow',
|
|
|
|
kafka_max_block_size = 1048576,
|
2023-05-08 08:13:40 +02:00
|
|
|
kafka_handle_error_mode = 'stream'
|
2023-03-23 07:02:37 +01:00
|
|
|
|
|
|
|
CREATE MATERIALIZED VIEW umami.event_data_queue_mv TO umami.event_data AS
|
|
|
|
SELECT website_id,
|
|
|
|
session_id,
|
|
|
|
event_id,
|
|
|
|
url_path,
|
|
|
|
event_name,
|
|
|
|
event_key,
|
2023-06-01 06:46:49 +02:00
|
|
|
string_value,
|
2023-07-07 06:02:56 +02:00
|
|
|
number_value,
|
2023-06-01 06:46:49 +02:00
|
|
|
date_value,
|
|
|
|
data_type,
|
2023-03-23 07:02:37 +01:00
|
|
|
created_at
|
2023-05-08 08:13:40 +02:00
|
|
|
FROM umami.event_data_queue;
|
|
|
|
|
|
|
|
CREATE MATERIALIZED VIEW umami.event_data_errors_mv
|
|
|
|
(
|
|
|
|
error String,
|
|
|
|
raw String
|
|
|
|
)
|
|
|
|
ENGINE = MergeTree
|
|
|
|
ORDER BY (error, raw)
|
|
|
|
SETTINGS index_granularity = 8192 AS
|
|
|
|
SELECT _error AS error,
|
|
|
|
_raw_message AS raw
|
|
|
|
FROM umami.event_data_queue
|
|
|
|
WHERE length(_error) > 0
|