From 73c935001152610fcda2ce8af18e9d75298e2cbd Mon Sep 17 00:00:00 2001 From: doleyzi <43397300+doleyzi@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:01:47 +0800 Subject: [PATCH] [INLONG-9914][Audit] Add SQL related to audit-service (#9915) * Add SQL related to audit-service * Add SQL related to audit-service --- .../apcache_inlong_audit_aggregate.sql | 68 +++++++++++++++++++ .../{ => audit-store}/apache_inlong_audit.sql | 0 .../apache_inlong_audit_clickhouse.sql | 0 .../clickhouse-changes-1.9.0.sql | 0 .../{ => audit-store}/mysql-changes-1.9.0.sql | 0 5 files changed, 68 insertions(+) create mode 100644 inlong-audit/sql/audit-service/apcache_inlong_audit_aggregate.sql rename inlong-audit/sql/{ => audit-store}/apache_inlong_audit.sql (100%) rename inlong-audit/sql/{ => audit-store}/apache_inlong_audit_clickhouse.sql (100%) rename inlong-audit/sql/{ => audit-store}/clickhouse-changes-1.9.0.sql (100%) rename inlong-audit/sql/{ => audit-store}/mysql-changes-1.9.0.sql (100%) diff --git a/inlong-audit/sql/audit-service/apcache_inlong_audit_aggregate.sql b/inlong-audit/sql/audit-service/apcache_inlong_audit_aggregate.sql new file mode 100644 index 00000000000..57943555336 --- /dev/null +++ b/inlong-audit/sql/audit-service/apcache_inlong_audit_aggregate.sql @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +SET NAMES utf8; +SET FOREIGN_KEY_CHECKS = 0; +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + +-- ---------------------------- +-- Database for InLong Audit +-- ---------------------------- +CREATE DATABASE IF NOT EXISTS apache_inlong_audit; + +USE apache_inlong_audit; + +-- ---------------------------- +-- Table structure for audit_data_temp +-- You can create daily partitions or hourly partitions through the log_ts field. +-- The specific partition type is determined based on the actual data volume. +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `audit_data_temp` +( + `log_ts` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'log timestamp', + `inlong_group_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'The target inlong group id', + `inlong_stream_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'The target inlong stream id', + `audit_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'Audit id', + `audit_tag` varchar(100) DEFAULT '' COMMENT 'Audit tag', + `count` BIGINT NOT NULL DEFAULT '0' COMMENT 'Message count', + `size` BIGINT NOT NULL DEFAULT '0' COMMENT 'Message size', + `delay` BIGINT NOT NULL DEFAULT '0' COMMENT 'Message delay count', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Update time', + PRIMARY KEY (`log_ts`,`inlong_group_id`,`inlong_stream_id`,`audit_id`,`audit_tag`) +) ENGINE = InnoDB +DEFAULT CHARSET = utf8 COMMENT ='Inlong audit data temp table'; + +-- ---------------------------- +-- Table structure for audit_data_day +-- You can create daily partitions through the log_ts field. +-- The specific partition type is determined based on the actual data volume. +-- ---------------------------- +CREATE TABLE IF NOT EXISTS `audit_data_day` +( + `log_ts` date NOT NULL DEFAULT '0000-00-00' COMMENT 'log timestamp', + `inlong_group_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'The target inlong group id', + `inlong_stream_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'The target inlong stream id', + `audit_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'Audit id', + `audit_tag` varchar(100) DEFAULT '' COMMENT 'Audit tag', + `count` BIGINT NOT NULL DEFAULT '0' COMMENT 'Message count', + `size` BIGINT NOT NULL DEFAULT '0' COMMENT 'Message size', + `delay` BIGINT NOT NULL DEFAULT '0' COMMENT 'Message delay count', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Update time', + PRIMARY KEY (`log_ts`,`inlong_group_id`,`inlong_stream_id`,`audit_id`,`audit_tag`) +) ENGINE = InnoDB +DEFAULT CHARSET = utf8 COMMENT ='Inlong audit data day table'; diff --git a/inlong-audit/sql/apache_inlong_audit.sql b/inlong-audit/sql/audit-store/apache_inlong_audit.sql similarity index 100% rename from inlong-audit/sql/apache_inlong_audit.sql rename to inlong-audit/sql/audit-store/apache_inlong_audit.sql diff --git a/inlong-audit/sql/apache_inlong_audit_clickhouse.sql b/inlong-audit/sql/audit-store/apache_inlong_audit_clickhouse.sql similarity index 100% rename from inlong-audit/sql/apache_inlong_audit_clickhouse.sql rename to inlong-audit/sql/audit-store/apache_inlong_audit_clickhouse.sql diff --git a/inlong-audit/sql/clickhouse-changes-1.9.0.sql b/inlong-audit/sql/audit-store/clickhouse-changes-1.9.0.sql similarity index 100% rename from inlong-audit/sql/clickhouse-changes-1.9.0.sql rename to inlong-audit/sql/audit-store/clickhouse-changes-1.9.0.sql diff --git a/inlong-audit/sql/mysql-changes-1.9.0.sql b/inlong-audit/sql/audit-store/mysql-changes-1.9.0.sql similarity index 100% rename from inlong-audit/sql/mysql-changes-1.9.0.sql rename to inlong-audit/sql/audit-store/mysql-changes-1.9.0.sql