From 2f1ce9a71b8ca87315b1554a96cadd92236212e3 Mon Sep 17 00:00:00 2001 From: houjinchuan Date: Fri, 2 Aug 2024 15:26:50 +0800 Subject: [PATCH] =?UTF-8?q?[CN-1682]=20clickhouse=E6=96=B0=E5=BB=BAmatch?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../旧部署模式建表语句/cn_clickhouse_ddl.sql | 256 +++ .../cn_clickhouse_ddl_check.sql | 9 + .../clickhouse/cn_clickhouse_ddl_24.08.sql | 1664 +++++++++++++++++ .../cn_clickhouse_ddl_check_24.08.sql | 66 + .../cn_clickhouse_ddl_upgrade_24.08.sql | 176 ++ 5 files changed, 2171 insertions(+) create mode 100644 cyber_narrator/upgrade/2024/CN-24.08/clickhouse/cn_clickhouse_ddl_24.08.sql create mode 100644 cyber_narrator/upgrade/2024/CN-24.08/clickhouse/cn_clickhouse_ddl_check_24.08.sql create mode 100644 cyber_narrator/upgrade/2024/CN-24.08/clickhouse/cn_clickhouse_ddl_upgrade_24.08.sql diff --git a/cyber_narrator/installation/clickhouse/旧部署模式建表语句/cn_clickhouse_ddl.sql b/cyber_narrator/installation/clickhouse/旧部署模式建表语句/cn_clickhouse_ddl.sql index aeefb2e..70e3305 100644 --- a/cyber_narrator/installation/clickhouse/旧部署模式建表语句/cn_clickhouse_ddl.sql +++ b/cyber_narrator/installation/clickhouse/旧部署模式建表语句/cn_clickhouse_ddl.sql @@ -2126,3 +2126,259 @@ GROUP BY ip, l7_protocol, port; + + +CREATE TABLE cyber_narrator_galaxy.match_indicator_local ON CLUSTER ck_cluster ( + indicator_fields String, + indicator_values String, + match_num Int64, + reset Int64, + client_ip String, + client_country_region String, + client_super_admin_area String, + client_admin_area String, + client_longitude Nullable(Float64), + client_latitude Nullable(Float64), + server_ip String, + server_country_region String, + server_super_admin_area String, + server_admin_area String, + server_longitude Nullable(Float64), + server_latitude Nullable(Float64), + domain String, + app String, + match_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) +ENGINE = MergeTree +PARTITION BY toYYYYMMDD(toDate(match_time)) +ORDER BY (match_id, match_time); + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.match_indicator ON CLUSTER ck_cluster ( + indicator_fields String, + indicator_values String, + match_num Int64, + reset Int64, + client_ip String, + client_country_region String, + client_super_admin_area String, + client_admin_area String, + client_longitude Nullable(Float64), + client_latitude Nullable(Float64), + server_ip String, + server_country_region String, + server_super_admin_area String, + server_admin_area String, + server_longitude Nullable(Float64), + server_latitude Nullable(Float64), + domain String, + app String, + match_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'match_indicator_local', rand()); + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.match_indicator ON CLUSTER ck_query ( + indicator_fields String, + indicator_values String, + match_num Int64, + reset Int64, + client_ip String, + client_country_region String, + client_super_admin_area String, + client_admin_area String, + client_longitude Nullable(Float64), + client_latitude Nullable(Float64), + server_ip String, + server_country_region String, + server_super_admin_area String, + server_admin_area String, + server_longitude Nullable(Float64), + server_latitude Nullable(Float64), + domain String, + app String, + match_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'match_indicator_local', rand()); + + +CREATE TABLE cyber_narrator_galaxy.match_threshold_local ON CLUSTER ck_cluster ( + key_fields String, + key_values String, + threshold_num Int64, + records_num Int64, + reset Int64, + start_time Int64, + end_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) +ENGINE = MergeTree +PARTITION BY toYYYYMMDD(toDate(start_time)) +ORDER BY (match_id, start_time); + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.match_threshold ON CLUSTER ck_cluster ( + key_fields String, + key_values String, + threshold_num Int64, + records_num Int64, + reset Int64, + start_time Int64, + end_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'match_threshold_local', rand()); + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.match_threshold ON CLUSTER ck_query ( + key_fields String, + key_values String, + threshold_num Int64, + records_num Int64, + reset Int64, + start_time Int64, + end_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'match_threshold_local', rand()); + + +CREATE TABLE cyber_narrator_galaxy.match_sequence_local ON CLUSTER ck_cluster ( + key_fields String, + key_values String, + event_info String, + start_time Int64, + end_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) +ENGINE = MergeTree +PARTITION BY toYYYYMMDD(toDate(start_time)) +ORDER BY (match_id, start_time); + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.match_sequence ON CLUSTER ck_cluster ( + key_fields String, + key_values String, + event_info String, + start_time Int64, + end_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'match_sequence_local', rand()); + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.match_sequence ON CLUSTER ck_query ( + key_fields String, + key_values String, + event_info String, + start_time Int64, + end_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'match_sequence_local', rand()); + + +CREATE TABLE cyber_narrator_galaxy.match_unordered_sequence_local ON CLUSTER ck_cluster ( + key_fields String, + key_values String, + event_info String, + start_time Int64, + end_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) +ENGINE = MergeTree +PARTITION BY toYYYYMMDD(toDate(start_time)) +ORDER BY (match_id, start_time); + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.match_unordered_sequence ON CLUSTER ck_cluster ( + key_fields String, + key_values String, + event_info String, + start_time Int64, + end_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'match_unordered_sequence_local', rand()); + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.match_unordered_sequence ON CLUSTER ck_query ( + key_fields String, + key_values String, + event_info String, + start_time Int64, + end_time Int64, + match_id UInt64, + rule_id UInt64, + rule_version String, + rule_type String, + is_builtin Int64, + event_type String, + event_name String, + severity Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'match_unordered_sequence_local', rand()); \ No newline at end of file diff --git a/cyber_narrator/installation/clickhouse/旧部署模式建表语句/cn_clickhouse_ddl_check.sql b/cyber_narrator/installation/clickhouse/旧部署模式建表语句/cn_clickhouse_ddl_check.sql index cb72177..c47c9dc 100644 --- a/cyber_narrator/installation/clickhouse/旧部署模式建表语句/cn_clickhouse_ddl_check.sql +++ b/cyber_narrator/installation/clickhouse/旧部署模式建表语句/cn_clickhouse_ddl_check.sql @@ -55,3 +55,12 @@ SELECT subscriber_id, imei, imsi, phone_number, apn, subscriber_longitude, subsc FROM cyber_narrator_galaxy.location_subscriber where stat_time >= toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND recv_time = toUnixTimestamp('2030-01-01 00:00:00') AND match_time = toUnixTimestamp('2030-01-01 00:00:00') AND start_time = toUnixTimestamp('2030-01-01 00:00:00') AND start_time = toUnixTimestamp('2030-01-01 00:00:00') AND start_time = toUnixTimestamp('2030-01-01 00:00:00') AND create_time = toUnixTimestamp('2030-01-01 00:00:00') AND create_time = toUnixTimestamp('2030-01-01 00:00:00') AND start_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND create_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND create_time = toUnixTimestamp('2030-01-01 00:00:00') AND create_time = toUnixTimestamp('2030-01-01 00:00:00') AND create_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND recv_time = toUnixTimestamp('2030-01-01 00:00:00') AND match_time = toUnixTimestamp('2030-01-01 00:00:00') AND start_time = toUnixTimestamp('2030-01-01 00:00:00') AND start_time = toUnixTimestamp('2030-01-01 00:00:00') AND start_time