This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 7ded6c1ca [ISSUE #3801] support clickhouse-logging-pugin (#3832)
7ded6c1ca is described below
commit 7ded6c1cadb896923ade3f4ec0b8c814f3be71a8
Author: zhengpeng <[email protected]>
AuthorDate: Thu Sep 1 22:24:06 2022 +0800
[ISSUE #3801] support clickhouse-logging-pugin (#3832)
* #3801 support clickhouse-logging-pugin.
* #3801 support clickhouse-logging-pugin notes.
* Empty Commit to setup deployments
* merge sql
* Empty Commit to setup deployments
* pom version
* feature: merge master and sql
---
db/init/mysql/schema.sql | 7 +-
db/init/oracle/schema.sql | 19 +++
db/init/pg/create-table.sql | 6 +
db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql | 14 +-
db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql | 21 ++-
db/upgrade/2.5.0-upgrade-2.5.1-pg.sql | 14 +-
pom.xml | 1 +
.../src/main/resources/sql-script/h2/schema.sql | 7 +
shenyu-bootstrap/pom.xml | 8 ++
.../org/apache/shenyu/common/enums/PluginEnum.java | 5 +
.../org/apache/shenyu/common/utils/DateUtils.java | 6 +-
.../shenyu/examples/common/aop/package-info.java | 21 +++
shenyu-plugin/shenyu-plugin-logging/pom.xml | 1 +
.../shenyu-plugin-logging-clickhouse/pom.xml | 56 ++++++++
.../clickhouse/LoggingClickHousePlugin.java | 70 ++++++++++
.../client/ClickHouseLogCollectClient.java | 155 +++++++++++++++++++++
.../collector/ClickHouseLogCollector.java | 42 ++++++
.../config/ClickHouseLogCollectConfig.java | 154 ++++++++++++++++++++
.../constant/ClickHouseLoggingConstant.java | 67 +++++++++
.../LoggingClickHousePluginDataHandler.java | 80 +++++++++++
.../clickhouse/LoggingClickHousePluginTest.java | 107 ++++++++++++++
.../client/ClickHouseLogCollectClientTest.java | 104 ++++++++++++++
.../collector/ClickHouseLogCollectorTest.java | 35 +++++
.../config/ClickHouseLogCollectConfigTest.java | 115 +++++++++++++++
.../LoggingClickHousePluginDataHandlerTest.java | 55 ++++++++
.../common/constant/GenericLoggingConstant.java | 11 ++
.../logging/common/entity/ShenyuRequestLog.java | 25 ++++
.../shenyu-spring-boot-starter-plugin/pom.xml | 1 +
.../pom.xml | 51 +++++++
.../LoggingClickHousePluginConfiguration.java | 52 +++++++
.../src/main/resources/META-INF/spring.factories | 19 +++
.../src/main/resources/META-INF/spring.provides | 0
.../LoggingClickHousePluginConfigurationTest.java | 50 +++++++
33 files changed, 1369 insertions(+), 10 deletions(-)
diff --git a/db/init/mysql/schema.sql b/db/init/mysql/schema.sql
index c839b5281..adc84f1f4 100644
--- a/db/init/mysql/schema.sql
+++ b/db/init/mysql/schema.sql
@@ -598,6 +598,7 @@ INSERT INTO `plugin` VALUES ('33',
'loggingKafka','{\"host\":\"localhost\", \"po
INSERT INTO `plugin` VALUES ('34', 'loggingAliyunSls','{\"projectName\":
\"shenyu\", \"logStoreName\": \"shenyu-logstore\", \"topic\":
\"shenyu-topic\"}', 'Logging', 175, 0, '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO `plugin` VALUES ('35', 'loggingPulsar',
'{\"topic":\"shenyu-access-logging\", \"serviceUrl\":
\"pulsar://localhost:6650\"}', 'Logging', 185, 0, '2022-06-30 21:00:00',
'2022-06-30 21:00:00');
INSERT INTO `plugin` VALUES ('36', 'loggingTencentCls','{\"endpoint\":
\"ap-guangzhou.cls.tencentcs.com\", \"topic\": \"shenyu-topic\"}', 'Logging',
176, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
+INSERT INTO `plugin` VALUES ('38', 'loggingClickHouse',
'{\"host\":\"127.0.0.1\",\"port\":\"8123\",\"databse\":\"shenyu-gateway\",\"username\":\"foo\",\"password\":\"bar\"}',
'Logging', 195, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
-- ----------------------------
-- Table structure for plugin_handle
@@ -834,7 +835,11 @@ INSERT INTO `plugin_handle` VALUES ('1529402613204172923',
'36', 'retries', 'ret
INSERT INTO `plugin_handle` VALUES ('1529402613204172924', '36',
'maxReservedAttempts', 'maxReservedAttempts', 1, 3, 13,
'{\"required\":\"0\",\"defaultValue\":11}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO `plugin_handle` VALUES ('1529402613204172925', '36',
'baseRetryBackoffMs', 'baseRetryBackoffMs', 1, 3, 14,
'{\"required\":\"0\",\"defaultValue\":100}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO `plugin_handle` VALUES ('1529402613204172926', '36',
'maxRetryBackoffMs', 'maxRetryBackoffMs', 1, 3, 15,
'{\"required\":\"0\",\"defaultValue\":50000}', '2022-06-30 21:00:00',
'2022-06-30 21:00:00');
-
+INSERT INTO `plugin_handle` VALUES ('1529402613204172798', '38', 'host',
'host', 2, 3, 1, '{"required":"0","defaultValue":"127.0.0.1"}', '2022-06-19
22:00:00', '2022-06-19 22:00:00');
+INSERT INTO `plugin_handle` VALUES ('1529402613204172799', '38', 'port',
'port', 2, 3, 2, '{"required":"0","defaultValue":"8123"}', '2022-06-19
22:00:00', '2022-06-19 22:00:00');
+INSERT INTO `plugin_handle` VALUES ('1556899301440503808', '38', 'database',
'database', 2, 2, 0,
'{"required":"0","defaultValue":"shenyu-gateway","placeholder":"database"}',
'2022-06-19 22:00:00', '2022-06-19 22:00:00');
+INSERT INTO `plugin_handle` VALUES ('1556899400849702912', '38', 'username',
'username', 2, 2, 0,
'{"required":"0","defaultValue":"foo","placeholder":"username"}', '2022-06-19
22:00:00', '2022-06-19 22:00:00');
+INSERT INTO `plugin_handle` VALUES ('1556899492809818112', '38', 'password',
'password', 2, 2, 0,
'{"required":"0","defaultValue":"bar","placeholder":"password"}', '2022-06-19
22:00:00', '2022-06-19 22:00:00');
-- ----------------------------
-- Table structure for resource
-- ----------------------------
diff --git a/db/init/oracle/schema.sql b/db/init/oracle/schema.sql
index 6207917bb..66acfe0a2 100644
--- a/db/init/oracle/schema.sql
+++ b/db/init/oracle/schema.sql
@@ -856,6 +856,7 @@ INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO
plugin (id, name, conf
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('34', 'loggingAliyunSls', '{"projectName":
"shenyu", "logStoreName": "shenyu-logstore", "topic": "shenyu-topic"}',
'Logging', 175, '0');
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('35', 'loggingPulsar',
'{"topic":"shenyu-access-logging", "serviceUrl": "pulsar://localhost:6650"}',
'Logging', 185, '0')
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('36', 'loggingTencentCls', '{"endpoint":
"ap-guangzhou.cls.tencentcs.com", "topic": "shenyu-topic"}', 'Logging', 176,
'0');
+INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('38', 'loggingClickHouse',
'{"host":"127.0.0.1","port":"8123","databse":"shenyu-gateway","username":"foo","password":"bar"}',
'Logging', 195, '0');
@@ -1492,6 +1493,24 @@ values ('1518229897214468216', '36',
'baseRetryBackoffMs', 'baseRetryBackoffMs',
insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
values ('1518229897214468217', '36', 'maxRetryBackoffMs', 'maxRetryBackoffMs',
1, 3, 15, '{\"required\":\"0\",\"defaultValue\":50000}');
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1529402613204172798', '38', 'host', 'host', 2, 3, 1,
'{"required":"0","defaultValue":"127.0.0.1"}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1529402613204172799', '38', 'port', 'port', 2, 3, 1,
'{"required":"0","defaultValue":"8123"}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1556899301440503808', '38', 'database', 'database', 2, 2, 0,
'{"required":"0","defaultValue":"shenyu-gateway","placeholder":"database"}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1556899400849702912', '38', 'username', 'username', 2, 2, 0,
'{"required":"0","defaultValue":"foo","placeholder":"username"}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1556899492809818112', '38', 'password', 'password', 2, 2, 0,
'{"required":"0","defaultValue":"bar","placeholder":"password"}');
+
+
+
+
/** insert resource for resource */
INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX("resource" (id)) */ INTO "resource"
(id, parent_id, title, name, url, component, resource_type, sort, icon,
is_leaf, is_route, perms, status)
VALUES('1346775491550474240','','SHENYU.MENU.PLUGIN.LIST','plug','/plug','PluginList','0','0','dashboard','0','0','','1');
diff --git a/db/init/pg/create-table.sql b/db/init/pg/create-table.sql
index 9bd00cdae..941aa2c46 100644
--- a/db/init/pg/create-table.sql
+++ b/db/init/pg/create-table.sql
@@ -675,6 +675,7 @@ INSERT INTO "public"."plugin" VALUES ('33', 'loggingKafka',
'{"topic":"shenyu-ac
INSERT INTO "public"."plugin" VALUES ('34', 'loggingAliyunSls',
'{"projectName": "shenyu", "logStoreName": "shenyu-logstore", "topic":
"shenyu-topic"}', 'Logging', 175, 0, '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO "public"."plugin" VALUES ('35', 'loggingPulsar',
'{"topic":"shenyu-access-logging", "serviceUrl": "pulsar://localhost:6650"}',
'Logging', 185, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
INSERT INTO "public"."plugin" VALUES ('36', 'loggingTencentCls', '{"endpoint":
"ap-guangzhou.cls.tencentcs.com", "topic": "shenyu-topic"}', 'Logging', 176, 0,
'2022-06-30 21:00:00', '2022-06-30 21:00:00');
+INSERT INTO "public"."plugin" VALUES ('38', 'loggingClickHouse',
'{"host":"127.0.0.1","port":"8123","databse":"shenyu-gateway","username":"foo","password":"bar"}',
'Logging', 195, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
-- ----------------------------
-- Table structure for plugin_handle
@@ -922,6 +923,11 @@ INSERT INTO "public"."plugin_handle" VALUES
('1529403902783524989', '36', 'retri
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524990', '36',
'maxReservedAttempts', 'maxReservedAttempts', 1, 3, 13,
'{\"required\":\"0\",\"defaultValue\":11}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524991', '36',
'baseRetryBackoffMs', 'baseRetryBackoffMs', 1, 3, 14,
'{\"required\":\"0\",\"defaultValue\":100}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524992', '36',
'maxRetryBackoffMs', 'maxRetryBackoffMs', 1, 3, 15,
'{\"required\":\"0\",\"defaultValue\":50000}', '2022-06-30 21:00:00',
'2022-06-30 21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172798', '38',
'host', 'host', 2, 3, 1, '{"required":"0","defaultValue":"127.0.0.1"}',
'2022-06-30 21:00:00', '2022-06-30 21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172799', '38',
'port', 'port', 2, 3, 2, '{"required":"0","defaultValue":"8123"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1556899301440503808', '38',
'database', 'database', 2, 2, 0,
'{"required":"0","defaultValue":"shenyu-gateway","placeholder":"database"}',
'2022-06-30 21:00:00', '2022-06-30 21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1556899400849702912', '38',
'username', 'username', 2, 2, 0,
'{"required":"0","defaultValue":"foo","placeholder":"username"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1556899492809818112', '38',
'password', 'password', 2, 2, 0,
'{"required":"0","defaultValue":"bar","placeholder":"password"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
-- ----------------------------
-- Table structure for resource
diff --git a/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
b/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
index c149180ec..88710c40a 100644
--- a/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
+++ b/db/upgrade/2.5.0-upgrade-2.5.1-mysql.sql
@@ -18,6 +18,10 @@
/* insert plugin for loggingPulsar */
INSERT INTO `plugin` VALUES ('35', 'loggingPulsar',
'{\"topic":\"shenyu-access-logging\", \"serviceUrl\":
\"pulsar://localhost:6650\"}', 'Logging', 185, 0, '2022-06-30 21:00:00',
'2022-06-30 21:00:00');
+-- insert loggingTencentCls plugin
+INSERT INTO `plugin` VALUES ('36', 'loggingTencentCls','{\"endpoint\":
\"ap-guangzhou.cls.tencentcs.com\, \"topic\": \"shenyu-topic\"}', 'Logging',
176, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
+/* insert plugin for loggingClickHouse */
+INSERT INTO `plugin` VALUES ('38', 'loggingClickHouse',
'{\"host\":\"127.0.0.1\",\"port\":\"8123\",\"databse\":\"shenyu-gateway\",\"username\":\"foo\",\"password\":\"bar\"}',
'Logging', 195, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
/* insert plugin_handle data for plugin loggingPulsar */
INSERT INTO `plugin_handle` VALUES ('1529402613204172906', '35', 'topic',
'topic', 2, 3, 1,
'{\"required\":\"1\",\"defaultValue\":\"shenyu-access-logging\"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
@@ -26,10 +30,8 @@ INSERT INTO `plugin_handle` VALUES ('1529402613204172908',
'35', 'sampleRate', '
INSERT INTO `plugin_handle` VALUES ('1529402613204172909', '35',
'maxResponseBody', 'maxResponseBody', 1, 3, 5,
'{\"required\":\"0\",\"defaultValue\":524288}', '2022-06-30 21:00:00',
'2022-06-30 21:00:00');
INSERT INTO `plugin_handle` VALUES ('1529402613204172910', '35',
'maxRequestBody', 'maxRequestBody', 1, 3, 6,
'{\"required\":\"0\",\"defaultValue\":524288}', '2022-06-30 21:00:00',
'2022-06-30 21:00:00');
INSERT INTO `plugin_handle` VALUES ('1529402613204172911', '35',
'compressAlg', 'compressAlg', 3, 3, 7,
'{\"required\":\"0\",\"defaultValue\":\"none\"}', '2022-06-30 21:00:00',
'2022-06-30 21:00:00');
-
--- insert loggingTencentCls plugin
-INSERT INTO `plugin` VALUES ('36', 'loggingTencentCls','{\"endpoint\":
\"ap-guangzhou.cls.tencentcs.com\, \"topic\": \"shenyu-topic\"}', 'Logging',
176, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
INSERT INTO `plugin_handle` VALUES ('1529402613204172912', '36', 'secretId',
'secretId', 2, 3, 1,
'{\"required\":\"1\",\"defaultValue\":\"\",\"placeholder\":\"\"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
+/* insert plugin_handle data for plugin loggingTencentCls */
INSERT INTO `plugin_handle` VALUES ('1529402613204172913', '36', 'secretKey',
'secretKey', 2, 3, 2,
'{\"required\":\"1\",\"defaultValue\":\"\",\"placeholder\":\"\"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
INSERT INTO `plugin_handle` VALUES ('1529402613204172914', '36', 'endpoint',
'endpoint', 2, 3, 3,
'{\"required\":\"1\",\"defaultValue\":\"\",\"placeholder\":\"\"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
INSERT INTO `plugin_handle` VALUES ('1529402613204172915', '36', 'topic',
'topic', 2, 3, 4,
'{\"required\":\"1\",\"defaultValue\":\"\",\"placeholder\":\"\"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
@@ -44,3 +46,9 @@ INSERT INTO `plugin_handle` VALUES ('1529402613204172923',
'36', 'retries', 'ret
INSERT INTO `plugin_handle` VALUES ('1529402613204172924', '36',
'maxReservedAttempts', 'maxReservedAttempts', 1, 3, 13,
'{\"required\":\"0\",\"defaultValue\":11}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO `plugin_handle` VALUES ('1529402613204172925', '36',
'baseRetryBackoffMs', 'baseRetryBackoffMs', 1, 3, 14,
'{\"required\":\"0\",\"defaultValue\":100}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO `plugin_handle` VALUES ('1529402613204172926', '36',
'maxRetryBackoffMs', 'maxRetryBackoffMs', 1, 3, 15,
'{\"required\":\"0\",\"defaultValue\":50000}', '2022-06-30 21:00:00',
'2022-06-30 21:00:00');
+/* insert plugin_handle data for plugin loggingClickHouse */
+INSERT INTO `plugin_handle` VALUES ('1529402613204172798', '38', 'host',
'host', 2, 3, 1, '{"required":"0","defaultValue":"127.0.0.1"}', '2022-06-19
22:00:00', '2022-06-19 22:00:00');
+INSERT INTO `plugin_handle` VALUES ('1529402613204172799', '38', 'port',
'port', 2, 3, 2, '{"required":"0","defaultValue":"8123"}', '2022-06-19
22:00:00', '2022-06-19 22:00:00');
+INSERT INTO `plugin_handle` VALUES ('1556899301440503808', '38', 'database',
'database', 2, 2, 0,
'{"required":"0","defaultValue":"shenyu-gateway","placeholder":"database"}',
'2022-06-19 22:00:00', '2022-06-19 22:00:00');
+INSERT INTO `plugin_handle` VALUES ('1556899400849702912', '38', 'username',
'username', 2, 2, 0,
'{"required":"0","defaultValue":"foo","placeholder":"username"}', '2022-06-19
22:00:00', '2022-06-19 22:00:00');
+INSERT INTO `plugin_handle` VALUES ('1556899492809818112', '38', 'password',
'password', 2, 2, 0,
'{"required":"0","defaultValue":"bar","placeholder":"password"}', '2022-06-19
22:00:00', '2022-06-19 22:00:00');
\ No newline at end of file
diff --git a/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
b/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
index 7ec13f274..99d440e9f 100644
--- a/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
+++ b/db/upgrade/2.5.0-upgrade-2.5.1-oracle.sql
@@ -14,7 +14,7 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
--- this file works for PostgreSQL, can not use "`" syntax.
+-- this file works for Oracle, can not use "`" syntax.
-- Note: it doesn't matter if you don't execute this SQL
-- Note: because most users have changed ZK configuration, this SQL is
annotated to prevent erroneous execution
@@ -68,3 +68,22 @@ values ('1518229897214468216', '36', 'baseRetryBackoffMs',
'baseRetryBackoffMs',
insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
values ('1518229897214468217', '36', 'maxRetryBackoffMs', 'maxRetryBackoffMs',
1, 3, 15, '{\"required\":\"0\",\"defaultValue\":50000}');
-- insert loggingTencentCls plugin End
+
+-- insert loggingClickHouse plugin start
+INSERT /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin(id)) */ INTO plugin (id, name,
config, role, sort, enabled) VALUES ('38', 'loggingClickHouse',
'{"host":"127.0.0.1","port":"8123","databse":"shenyu-gateway","username":"foo","password":"bar"}',
'Logging', 195, '0');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1529402613204172798', '38', 'host', 'host', 2, 3, 1,
'{"required":"0","defaultValue":"127.0.0.1"}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1529402613204172799', '38', 'port', 'port', 2, 3, 1,
'{"required":"0","defaultValue":"8123"}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1556899301440503808', '38', 'database', 'database', 2, 2, 0,
'{"required":"0","defaultValue":"shenyu-gateway","placeholder":"database"}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1556899400849702912', '38', 'username', 'username', 2, 2, 0,
'{"required":"0","defaultValue":"foo","placeholder":"username"}');
+
+insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(plugin_handle(plugin_id, field, type))
*/ into plugin_handle (ID, PLUGIN_ID, FIELD, LABEL, DATA_TYPE, TYPE, SORT,
EXT_OBJ)
+values ('1556899492809818112', '38', 'password', 'password', 2, 2, 0,
'{"required":"0","defaultValue":"bar","placeholder":"password"}');
+-- insert loggingClickHouse plugin End
\ No newline at end of file
diff --git a/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
b/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
index db437103e..4ad76ace5 100644
--- a/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
+++ b/db/upgrade/2.5.0-upgrade-2.5.1-pg.sql
@@ -18,6 +18,10 @@
/* insert plugin for loggingPulsar */
INSERT INTO "public"."plugin" VALUES ('35', 'loggingPulsar',
'{"topic":"shenyu-access-logging", "serviceUrl": "pulsar://localhost:6650"}',
'Logging', 185, 0, '2022-05-25 18:08:01', '2022-05-25 18:08:01');
+-- insert loggingTencentCls plugin
+INSERT INTO "public"."plugin" VALUES ('36', 'loggingTencentCls',
'{"endpoint\": \"ap-guangzhou.cls.tencentcs.com\, \"topic\": \"shenyu-topic"}',
'Logging', 176, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
+/* insert plugin for loggingClickHouse */
+INSERT INTO "public"."plugin" VALUES ('38', 'loggingClickHouse',
'{"host":"127.0.0.1","port":"8123","databse":"shenyu-gateway","username":"foo","password":"bar"}',
'Logging', 195, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
/* insert plugin_handle data for plugin loggingPulsar */
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524972', '35',
'topic', 'topic', 2, 3, 1,
'{"required":"1","defaultValue":"shenyu-access-logging"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
@@ -26,9 +30,7 @@ INSERT INTO "public"."plugin_handle" VALUES
('1529403902783524974', '35', 'sampl
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524975', '35',
'maxResponseBody', 'maxResponseBody', 1, 3, 5,
'{"required":"0","defaultValue":524288}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524976', '35',
'maxRequestBody', 'maxRequestBody', 1, 3, 6,
'{"required":"0","defaultValue":524288}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524977', '35',
'compressAlg', 'compressAlg', 3, 3, 7,
'{"required":"0","defaultValue":"none"}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
-
--- insert loggingTencentCls plugin
-INSERT INTO "public"."plugin" VALUES ('36', 'loggingTencentCls',
'{"endpoint\": \"ap-guangzhou.cls.tencentcs.com\, \"topic\": \"shenyu-topic"}',
'Logging', 176, 0, '2022-06-30 21:00:00', '2022-06-30 21:00:00');
+/* insert plugin_handle data for plugin loggingTencentCls */
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524978', '36',
'secretId', 'secretId', 2, 3, 1,
'{\"required\":\"1\",\"defaultValue\":\"\",\"placeholder\":\"\"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524979', '36',
'secretKey', 'secretKey', 2, 3, 2,
'{\"required\":\"1\",\"defaultValue\":\"\",\"placeholder\":\"\"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524980', '36',
'endpoint', 'endpoint', 2, 3, 3,
'{\"required\":\"1\",\"defaultValue\":\"\",\"placeholder\":\"\"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
@@ -44,3 +46,9 @@ INSERT INTO "public"."plugin_handle" VALUES
('1529403902783524989', '36', 'retri
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524990', '36',
'maxReservedAttempts', 'maxReservedAttempts', 1, 3, 13,
'{\"required\":\"0\",\"defaultValue\":11}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524991', '36',
'baseRetryBackoffMs', 'baseRetryBackoffMs', 1, 3, 14,
'{\"required\":\"0\",\"defaultValue\":100}', '2022-06-30 21:00:00', '2022-06-30
21:00:00');
INSERT INTO "public"."plugin_handle" VALUES ('1529403902783524992', '36',
'maxRetryBackoffMs', 'maxRetryBackoffMs', 1, 3, 15,
'{\"required\":\"0\",\"defaultValue\":50000}', '2022-06-30 21:00:00',
'2022-06-30 21:00:00');
+/* insert plugin_handle data for plugin loggingClickHouse */
+INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172798', '38',
'host', 'host', 2, 3, 1, '{"required":"0","defaultValue":"127.0.0.1"}',
'2022-06-30 21:00:00', '2022-06-30 21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1529402613204172799', '38',
'port', 'port', 2, 3, 2, '{"required":"0","defaultValue":"8123"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1556899301440503808', '38',
'database', 'database', 2, 2, 0,
'{"required":"0","defaultValue":"shenyu-gateway","placeholder":"database"}',
'2022-06-30 21:00:00', '2022-06-30 21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1556899400849702912', '38',
'username', 'username', 2, 2, 0,
'{"required":"0","defaultValue":"foo","placeholder":"username"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
+INSERT INTO "public"."plugin_handle" VALUES ('1556899492809818112', '38',
'password', 'password', 2, 2, 0,
'{"required":"0","defaultValue":"bar","placeholder":"password"}', '2022-06-30
21:00:00', '2022-06-30 21:00:00');
diff --git a/pom.xml b/pom.xml
index b75250b57..58b6bb969 100644
--- a/pom.xml
+++ b/pom.xml
@@ -132,6 +132,7 @@
<jakarta.json-api.version>2.0.1</jakarta.json-api.version>
<elasticsearch-rest-client.version>8.2.3</elasticsearch-rest-client.version>
<kafka-clients.version>3.2.0</kafka-clients.version>
+
<clickhouse-http-client.version>0.3.2-patch11</clickhouse-http-client.version>
<!--maven plugin version-->
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.7</jacoco-maven-plugin.version>
diff --git a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
index 6efa3fa38..3d1cca95f 100755
--- a/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
+++ b/shenyu-admin/src/main/resources/sql-script/h2/schema.sql
@@ -391,6 +391,7 @@ INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`,
`config`, `enabled`)
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,
`enabled`) VALUES ('34', 'loggingAliyunSls', 'Logging', 175, '{"projectName":
"shenyu", "logStoreName": "shenyu-logstore", "topic": "shenyu-topic"}', '0');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,
`enabled`) VALUES ('35', 'loggingPulsar', 'Logging', 185,
'{"topic":"shenyu-access-logging", "serviceUrl": "pulsar://localhost:6650"}',
'0');
INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,
`enabled`) VALUES ('36', 'loggingTencentCls', 'Logging', 176, '{"endpoint":
"ap-guangzhou.cls.tencentcs.com", "topic": "shenyu-topic"}', '0');
+INSERT IGNORE INTO `plugin` (`id`, `name`, `role`, `sort`, `config`,
`enabled`) VALUES ('38', 'loggingClickHouse', 'Logging', 195,
'{"host":"127.0.0.1","port":"8123","databse":"shenyu-gateway","username":"foo","password":"bar"}',
'0');
/*insert plugin_handle data for sentinel*/
@@ -609,6 +610,12 @@ INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172924', '36', 'maxReservedAttempts', 'maxReservedAttempts', 1,
3, 13, '{"required":"0","defaultValue":11}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172925', '36', 'baseRetryBackoffMs', 'baseRetryBackoffMs', 1, 3,
14, '{"required":"0","defaultValue":100}');
INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172926', '36', 'maxRetryBackoffMs', 'maxRetryBackoffMs', 1, 3,
15, '{"required":"0","defaultValue":50000}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172798', '38', 'host', 'host', 2, 3, 1,
'{"required":"0","defaultValue":"127.0.0.1"}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1529402613204172799', '38', 'port', 'port', 2, 3, 1,
'{"required":"0","defaultValue":"8123"}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1556899301440503808', '38', 'database', 'database', 2, 2, 0,
'{"required":"0","defaultValue":"shenyu-gateway","placeholder":"database"}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1556899400849702912', '38', 'username', 'username', 2, 2, 0,
'{"required":"0","defaultValue":"foo","placeholder":"username"}');
+INSERT IGNORE INTO plugin_handle (`id`,
`plugin_id`,`field`,`label`,`data_type`,`type`,`sort`,`ext_obj`) VALUES
('1556899492809818112', '38', 'password', 'password', 2, 2, 0,
'{"required":"1","defaultValue":"bar","placeholder":"password"}');
+
/** insert resource for resource */
INSERT IGNORE INTO `resource` (`id`, `parent_id`, `title`, `name`, `url`,
`component`, `resource_type`, `sort`, `icon`, `is_leaf`, `is_route`, `perms`,
`status`)
VALUES('1346775491550474240','','SHENYU.MENU.PLUGIN.LIST','plug','/plug','PluginList','0','0','dashboard','0','0','','1');
diff --git a/shenyu-bootstrap/pom.xml b/shenyu-bootstrap/pom.xml
index 90d0bc8e2..2bc54d1b0 100644
--- a/shenyu-bootstrap/pom.xml
+++ b/shenyu-bootstrap/pom.xml
@@ -511,6 +511,14 @@
</dependency>
<!-- shenyu logging-tencentcls plugin end -->
+ <!-- shenyu logging-clickhouse plugin start -->
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+
<artifactId>shenyu-spring-boot-starter-plugin-logging-clickhouse</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu logging-clickhouse plugin end -->
+
</dependencies>
<profiles>
<profile>
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
index 6f4cd19c6..4d229d095 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/enums/PluginEnum.java
@@ -161,6 +161,11 @@ public enum PluginEnum {
* Logging ElasticSearch plugin enum.
*/
LOGGING_ELASTIC_SEARCH(190, 0, "loggingElasticSearch"),
+
+ /**
+ * Logging ClickHouse plugin enum.
+ */
+ LOGGING_CLICK_HOUSE(195, 0, "loggingClickHouse"),
/**
* Divide plugin enum.
diff --git
a/shenyu-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java
b/shenyu-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java
index 901fcc263..c6eae614c 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java
@@ -29,7 +29,9 @@ import java.time.temporal.ChronoUnit;
public final class DateUtils {
public static final String DATE_FORMAT_DATETIME = "yyyy-MM-dd HH:mm:ss";
-
+
+ public static final String DATE_FORMAT_DATETIME_MILLISECOND = "yyyy-MM-dd
HH:mm:ss.SSS";
+
private static final DateTimeFormatter DATE_TIME_FORMATTER =
DateTimeFormatter.ofPattern(DATE_FORMAT_DATETIME);
private DateUtils() {
@@ -46,7 +48,7 @@ public final class DateUtils {
public static LocalDateTime parseLocalDateTime(final String dataTime) {
return LocalDateTime.parse(dataTime,
DateTimeFormatter.ofPattern(DATE_FORMAT_DATETIME));
}
-
+
/**
* Parse local date time local date time.
*
diff --git
a/shenyu-examples/shenyu-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/package-info.java
b/shenyu-examples/shenyu-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/package-info.java
new file mode 100644
index 000000000..05699a0bb
--- /dev/null
+++
b/shenyu-examples/shenyu-examples-common/src/main/java/org/apache/shenyu/examples/common/aop/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * package-info.
+ */
+package org.apache.shenyu.examples.common.aop;
diff --git a/shenyu-plugin/shenyu-plugin-logging/pom.xml
b/shenyu-plugin/shenyu-plugin-logging/pom.xml
index 07d130657..9307776bd 100644
--- a/shenyu-plugin/shenyu-plugin-logging/pom.xml
+++ b/shenyu-plugin/shenyu-plugin-logging/pom.xml
@@ -35,5 +35,6 @@
<module>shenyu-plugin-logging-aliyun-sls</module>
<module>shenyu-plugin-logging-pulsar</module>
<module>shenyu-plugin-logging-tencent-cls</module>
+ <module>shenyu-plugin-logging-clickhouse</module>
</modules>
</project>
\ No newline at end of file
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/pom.xml
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/pom.xml
new file mode 100644
index 000000000..9c5488f95
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/pom.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>shenyu-plugin-logging</artifactId>
+ <groupId>org.apache.shenyu</groupId>
+ <version>2.5.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>shenyu-plugin-logging-clickhouse</artifactId>
+ <dependencies>
+
+ <dependency>
+ <groupId>com.clickhouse</groupId>
+ <artifactId>clickhouse-http-client</artifactId>
+ <version>${clickhouse-http-client.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-plugin-logging-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/LoggingClickHousePlugin.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/LoggingClickHousePlugin.java
new file mode 100644
index 000000000..e02e3ad1d
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/LoggingClickHousePlugin.java
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse;
+
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.plugin.api.ShenyuPluginChain;
+import
org.apache.shenyu.plugin.logging.clickhouse.collector.ClickHouseLogCollector;
+import org.apache.shenyu.plugin.logging.common.AbstractLoggingPlugin;
+import org.apache.shenyu.plugin.logging.common.body.LoggingServerHttpRequest;
+import org.apache.shenyu.plugin.logging.common.body.LoggingServerHttpResponse;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+/**
+ * LoggingClickHousePlugin.
+ */
+public class LoggingClickHousePlugin extends AbstractLoggingPlugin {
+
+ @Override
+ public Mono<Void> doLogExecute(final ServerWebExchange exchange, final
ShenyuPluginChain chain,
+ final SelectorData selector, final RuleData
rule,
+ final ServerHttpRequest request, final
ShenyuRequestLog requestInfo) {
+ LoggingServerHttpRequest loggingServerHttpRequest = new
LoggingServerHttpRequest(request, requestInfo);
+ LoggingServerHttpResponse loggingServerHttpResponse = new
LoggingServerHttpResponse(exchange.getResponse(),
+ requestInfo, ClickHouseLogCollector.getInstance());
+ ServerWebExchange webExchange =
exchange.mutate().request(loggingServerHttpRequest)
+ .response(loggingServerHttpResponse).build();
+ loggingServerHttpResponse.setExchange(webExchange);
+ return
chain.execute(webExchange).doOnError(loggingServerHttpResponse::logError);
+ }
+
+ /**
+ * get plugin order.
+ *
+ * @return order
+ */
+ @Override
+ public int getOrder() {
+ return PluginEnum.LOGGING_CLICK_HOUSE.getCode();
+ }
+
+ /**
+ * get plugin name.
+ *
+ * @return plugin name
+ */
+ @Override
+ public String named() {
+ return PluginEnum.LOGGING_CLICK_HOUSE.getName();
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/client/ClickHouseLogCollectClient.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/client/ClickHouseLogCollectClient.java
new file mode 100644
index 000000000..729e4e805
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/client/ClickHouseLogCollectClient.java
@@ -0,0 +1,155 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse.client;
+
+import com.clickhouse.client.ClickHouseCredentials;
+import com.clickhouse.client.ClickHouseFormat;
+import com.clickhouse.client.ClickHouseProtocol;
+import com.clickhouse.client.ClickHouseRequest;
+import com.clickhouse.client.ClickHouseNode;
+import com.clickhouse.client.ClickHouseClient;
+import com.clickhouse.client.ClickHouseValue;
+import com.clickhouse.client.data.ClickHouseIntegerValue;
+import com.clickhouse.client.data.ClickHouseLongValue;
+import com.clickhouse.client.data.ClickHouseOffsetDateTimeValue;
+import com.clickhouse.client.data.ClickHouseStringValue;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.shenyu.common.utils.DateUtils;
+import
org.apache.shenyu.plugin.logging.clickhouse.constant.ClickHouseLoggingConstant;
+import org.apache.shenyu.plugin.logging.common.client.LogConsumeClient;
+import org.apache.shenyu.plugin.logging.common.constant.GenericLoggingConstant;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.TimeZone;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * queue-based logging collector.
+ */
+public class ClickHouseLogCollectClient implements LogConsumeClient {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(ClickHouseLogCollectClient.class);
+
+ private final AtomicBoolean isStarted = new AtomicBoolean(false);
+
+ private ClickHouseClient client;
+
+ private ClickHouseNode endpoint;
+
+ @Override
+ public void consume(final List<ShenyuRequestLog> logs) throws Exception {
+ if (CollectionUtils.isNotEmpty(logs)) {
+ Object[][] datas = new Object[logs.size()][];
+ for (int i = 0; i < logs.size(); i++) {
+ Object[] data = new Object[]{
+
DateUtils.parseLocalDateTime(logs.get(i).getTimeLocal(),
DateUtils.DATE_FORMAT_DATETIME_MILLISECOND),
+ logs.get(i).getClientIp(),
+ logs.get(i).getMethod(),
+ logs.get(i).getRequestHeader(),
+ logs.get(i).getResponseHeader(),
+ logs.get(i).getQueryParams(),
+ logs.get(i).getRequestBody(),
+ logs.get(i).getRequestUri(),
+ logs.get(i).getResponseBody(),
+ logs.get(i).getResponseContentLength(),
+ logs.get(i).getRpcType(),
+ logs.get(i).getStatus(),
+ logs.get(i).getUpstreamIp(),
+ logs.get(i).getUpstreamResponseTime(),
+ logs.get(i).getUserAgent(),
+ logs.get(i).getHost(),
+ logs.get(i).getModule(),
+ logs.get(i).getTraceId(),
+ logs.get(i).getPath(),
+ };
+ datas[i] = data;
+ }
+ ClickHouseClient.send(endpoint,
ClickHouseLoggingConstant.PRE_INSERT_SQL,
+ new ClickHouseValue[]{
+ ClickHouseOffsetDateTimeValue.ofNull(3,
TimeZone.getTimeZone("Asia/Shanghai")),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseIntegerValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseIntegerValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseLongValue.ofNull(false),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ ClickHouseStringValue.ofNull(),
+ },
+ datas).get();
+ }
+ }
+
+ @Override
+ public void close() {
+ if (Objects.nonNull(client) && isStarted.get()) {
+ client.close();
+ isStarted.set(false);
+ }
+ }
+
+ /**
+ * init client .
+ *
+ * @param properties properties.
+ */
+ public void initClient(final Properties properties) {
+ if (MapUtils.isEmpty(properties)) {
+ LOG.error("clickhouse properties is empty. failed init clickhouse
client");
+ return;
+ }
+ if (isStarted.get()) {
+ close();
+ }
+ final String username =
properties.getProperty(GenericLoggingConstant.USERNAME);
+ final String password =
properties.getProperty(GenericLoggingConstant.PASSWORD);
+ endpoint = ClickHouseNode.builder()
+ .host(properties.getProperty(GenericLoggingConstant.HOST))
+ .port(ClickHouseProtocol.HTTP,
Integer.valueOf(properties.getProperty(GenericLoggingConstant.PORT)))
+
.database(properties.getProperty(GenericLoggingConstant.DEFAULT_SOURCE))
+
.credentials(ClickHouseCredentials.fromUserAndPassword(username, password))
+ .build();
+ try {
+ client = ClickHouseClient.builder().build();
+ ClickHouseRequest<?> request =
client.connect(endpoint).format(ClickHouseFormat.TabSeparatedWithNamesAndTypes);
+
request.query(ClickHouseLoggingConstant.CREATE_DATABASE_SQL).executeAndWait();
+
request.query(ClickHouseLoggingConstant.CREATE_TABLE_SQL).executeAndWait();
+ } catch (Exception e) {
+ LOG.error("inti ClickHouseLogClient error" + e);
+ }
+ isStarted.set(true);
+ Runtime.getRuntime().addShutdownHook(new Thread(this::close));
+
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/collector/ClickHouseLogCollector.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/collector/ClickHouseLogCollector.java
new file mode 100644
index 000000000..784ce0409
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/collector/ClickHouseLogCollector.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse.collector;
+
+import
org.apache.shenyu.plugin.logging.clickhouse.handler.LoggingClickHousePluginDataHandler;
+import org.apache.shenyu.plugin.logging.common.client.LogConsumeClient;
+import org.apache.shenyu.plugin.logging.common.collector.AbstractLogCollector;
+import org.apache.shenyu.plugin.logging.common.collector.LogCollector;
+
+public class ClickHouseLogCollector extends AbstractLogCollector {
+
+ private static final LogCollector INSTANCE = new ClickHouseLogCollector();
+
+ /**
+ * get LogCollector Instance.
+ *
+ * @return LogCollector instance
+ */
+ public static LogCollector getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ protected LogConsumeClient getLogConsumeClient() {
+ return
LoggingClickHousePluginDataHandler.getClickHouseLogCollectClient();
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/config/ClickHouseLogCollectConfig.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/config/ClickHouseLogCollectConfig.java
new file mode 100644
index 000000000..cf0aa5ad3
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/config/ClickHouseLogCollectConfig.java
@@ -0,0 +1,154 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse.config;
+
+import java.util.Optional;
+
+/**
+ * ClickHouseLogCollectConfig.
+ */
+public class ClickHouseLogCollectConfig {
+
+ public static final ClickHouseLogCollectConfig INSTANCE = new
ClickHouseLogCollectConfig();
+
+ private ClickHouseLogConfig clickHouseLogConfig;
+
+ /**
+ * get click house log config.
+ *
+ * @return click house log config.
+ */
+ public ClickHouseLogConfig getClickHouseLogConfig() {
+ return Optional.ofNullable(clickHouseLogConfig).orElse(new
ClickHouseLogConfig());
+ }
+
+ /**
+ * set click house log config.
+ *
+ * @param clickHouseLogConfig log config.
+ */
+ public void setClickHouseLogConfig(final ClickHouseLogConfig
clickHouseLogConfig) {
+ this.clickHouseLogConfig = clickHouseLogConfig;
+ }
+
+ /**
+ * click house log config.
+ */
+ public static class ClickHouseLogConfig {
+ private String host;
+
+ private String port;
+
+ private String username;
+
+ private String password;
+
+ private String database;
+
+ /**
+ * get host.
+ *
+ * @return host
+ */
+ public String getHost() {
+ return host;
+ }
+
+ /**
+ * set host.
+ *
+ * @param host set host.
+ */
+ public void setHost(final String host) {
+ this.host = host;
+ }
+
+ /**
+ * get port.
+ *
+ * @return port
+ */
+ public String getPort() {
+ return port;
+ }
+
+ /**
+ * set port.
+ *
+ * @param port set port.
+ */
+ public void setPort(final String port) {
+ this.port = port;
+ }
+
+ /**
+ * get username.
+ *
+ * @return username.
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * set username.
+ *
+ * @param username set username.
+ */
+ public void setUsername(final String username) {
+ this.username = username;
+ }
+
+ /**
+ * get password.
+ *
+ * @return password.
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * set password.
+ *
+ * @param password password.
+ */
+ public void setPassword(final String password) {
+ this.password = password;
+ }
+
+ /**
+ * get database.
+ *
+ * @return database.
+ */
+ public String getDatabase() {
+ return database;
+ }
+
+ /**
+ * set database.
+ *
+ * @param database database.
+ */
+ public void setDatabase(final String database) {
+ this.database = database;
+ }
+ }
+
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/constant/ClickHouseLoggingConstant.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/constant/ClickHouseLoggingConstant.java
new file mode 100644
index 000000000..e8cda4369
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/constant/ClickHouseLoggingConstant.java
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse.constant;
+
+/**
+ * clickHouse logging Constant.
+ */
+public class ClickHouseLoggingConstant {
+
+ /**
+ * The constant CREATE_DATABASE_SQL.
+ */
+ public static final String CREATE_DATABASE_SQL = "create database if not
exists `shenyu-gateway`";
+
+ /**
+ * The constant CREATE_TABLE_SQL.
+ */
+ public static final String CREATE_TABLE_SQL = "create table if not exists
`shenyu-gateway`.request_log(\n"
+ + " timeLocal DateTime64,\n"
+ + " clientIp String,\n"
+ + " method String,\n"
+ + " requestHeader String,\n"
+ + " responseHeader String,\n"
+ + " queryParams String,\n"
+ + " requestBody String,\n"
+ + " requestUri String,\n"
+ + " responseBody String,\n"
+ + " responseContentLength UInt64,\n"
+ + " rpcType String,\n"
+ + " status UInt8,\n"
+ + " upstreamIp String,\n"
+ + " upstreamResponseTime UInt128,\n"
+ + " userAgent String,\n"
+ + " host String,\n"
+ + " module String,\n"
+ + " traceId String,\n"
+ + " path String\n"
+ + ") ENGINE = MergeTree()\n"
+ + "ORDER BY
(timeLocal,clientIp,method,rpcType,upstreamIp,upstreamResponseTime)\n"
+ + ";";
+
+ /**
+ * The constant PRE_INSERT_SQL.
+ */
+ public static final String PRE_INSERT_SQL = "INSERT INTO
`shenyu-gateway`.request_log "
+ + "(timeLocal, clientIp, method, requestHeader, responseHeader,
queryParams, "
+ + "requestBody, requestUri, responseBody, responseContentLength,
rpcType, status, upstreamIp, upstreamResponseTime, userAgent, host, module,
traceId, path) "
+ + "VALUES "
+ + "(:timeLocal, :clientIp,:method, :requestHeader,
:responseHeader, :queryParams,"
+ + " :requestBody, :requestUri, :responseBody,
:responseContentLength, :rpcType, :status, :upstreamIp, :upstreamResponseTime,
:userAgent, :host, :module, :traceId, :path);";
+
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/handler/LoggingClickHousePluginDataHandler.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/handler/LoggingClickHousePluginDataHandler.java
new file mode 100644
index 000000000..4a798a48d
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/plugin/logging/clickhouse/handler/LoggingClickHousePluginDataHandler.java
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse.handler;
+
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.common.utils.GsonUtils;
+import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
+import
org.apache.shenyu.plugin.logging.clickhouse.client.ClickHouseLogCollectClient;
+import
org.apache.shenyu.plugin.logging.clickhouse.collector.ClickHouseLogCollector;
+import
org.apache.shenyu.plugin.logging.clickhouse.config.ClickHouseLogCollectConfig;
+import org.apache.shenyu.plugin.logging.common.client.LogConsumeClient;
+import org.apache.shenyu.plugin.logging.common.constant.GenericLoggingConstant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Properties;
+
+/**
+ * The type logging pulsar plugin data handler.
+ */
+public class LoggingClickHousePluginDataHandler implements PluginDataHandler {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(LoggingClickHousePluginDataHandler.class);
+
+ private static final ClickHouseLogCollectClient
CLICK_HOUSE_LOG_COLLECT_CLIENT = new ClickHouseLogCollectClient();
+
+ /**
+ * getClickHouseLogCollectClient.
+ *
+ * @return LogConsumeClient
+ */
+ public static LogConsumeClient getClickHouseLogCollectClient() {
+ return CLICK_HOUSE_LOG_COLLECT_CLIENT;
+ }
+
+ @Override
+ public void handlerPlugin(final PluginData pluginData) {
+ LOG.info("handler loggingClickHouse Plugin data:{}",
GsonUtils.getGson().toJson(pluginData));
+ if (pluginData.getEnabled()) {
+ ClickHouseLogCollectConfig.ClickHouseLogConfig globalLogConfig =
GsonUtils.getInstance().fromJson(pluginData.getConfig(),
ClickHouseLogCollectConfig.ClickHouseLogConfig.class);
+
ClickHouseLogCollectConfig.INSTANCE.setClickHouseLogConfig(globalLogConfig);
+ Properties properties = new Properties();
+ properties.setProperty(GenericLoggingConstant.HOST,
globalLogConfig.getHost());
+ properties.setProperty(GenericLoggingConstant.PORT,
globalLogConfig.getPort());
+ properties.setProperty(GenericLoggingConstant.DEFAULT_SOURCE,
globalLogConfig.getDatabase());
+ properties.setProperty(GenericLoggingConstant.USERNAME,
globalLogConfig.getUsername());
+ properties.setProperty(GenericLoggingConstant.PASSWORD,
globalLogConfig.getPassword());
+ CLICK_HOUSE_LOG_COLLECT_CLIENT.initClient(properties);
+ ClickHouseLogCollector.getInstance().start();
+ } else {
+ try {
+ ClickHouseLogCollector.getInstance().close();
+ } catch (Exception e) {
+ LOG.error("close log collector error", e);
+ }
+ }
+ }
+
+ @Override
+ public String pluginNamed() {
+ return PluginEnum.LOGGING_CLICK_HOUSE.getName();
+ }
+
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/LoggingClickHousePluginTest.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/LoggingClickHousePluginTest.java
new file mode 100644
index 000000000..f3e80bc9f
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/LoggingClickHousePluginTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse;
+
+import org.apache.shenyu.common.constant.Constants;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.plugin.api.RemoteAddressResolver;
+import org.apache.shenyu.plugin.api.ShenyuPluginChain;
+import org.apache.shenyu.plugin.api.context.ShenyuContext;
+import org.apache.shenyu.plugin.api.utils.SpringBeanUtils;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentMatchers;
+import org.mockito.Mockito;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
+import org.springframework.mock.web.server.MockServerWebExchange;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+import reactor.test.StepVerifier;
+
+import java.net.InetSocketAddress;
+
+/**
+ * The Test Case For LoggingClickHousePlugin.
+ */
+@ExtendWith(MockitoExtension.class)
+public class LoggingClickHousePluginTest {
+
+ private LoggingClickHousePlugin loggingClickHousePlugin;
+
+ private ServerWebExchange exchange;
+
+ private RuleData ruleData;
+
+ private ShenyuPluginChain chain;
+
+ private SelectorData selectorData;
+
+ private ServerHttpRequest request;
+
+ private ShenyuRequestLog requestLog;
+
+ @BeforeEach
+ public void setUp() {
+ this.loggingClickHousePlugin = new LoggingClickHousePlugin();
+ this.ruleData = Mockito.mock(RuleData.class);
+ this.chain = Mockito.mock(ShenyuPluginChain.class);
+ this.selectorData = Mockito.mock(SelectorData.class);
+ this.request = Mockito.mock(ServerHttpRequest.class);
+ this.requestLog = new ShenyuRequestLog();
+ MockServerHttpRequest request = MockServerHttpRequest
+ .get("localhost")
+ .remoteAddress(new InetSocketAddress(9999))
+ .header("X-source", "mock test")
+ .queryParam("queryParam", "Hello,World")
+ .build();
+ ConfigurableApplicationContext context =
Mockito.mock(ConfigurableApplicationContext.class);
+ SpringBeanUtils.getInstance().setApplicationContext(context);
+ RemoteAddressResolver remoteAddressResolver = new
RemoteAddressResolver() {
+ };
+
Mockito.lenient().when(context.getBean(RemoteAddressResolver.class)).thenReturn(remoteAddressResolver);
+ this.exchange = Mockito.spy(MockServerWebExchange.from(request));
+ ShenyuContext shenyuContext = Mockito.mock(ShenyuContext.class);
+ exchange.getAttributes().put(Constants.CONTEXT, shenyuContext);
+ }
+
+ @Test
+ public void testDoExecute() {
+
Mockito.when(chain.execute(ArgumentMatchers.any())).thenReturn(Mono.empty());
+ Mono<Void> result = loggingClickHousePlugin.doLogExecute(exchange,
chain, selectorData, ruleData, request, requestLog);
+ StepVerifier.create(result).expectSubscription().verifyComplete();
+ }
+
+ @Test
+ public void testGetOrder() {
+ Assertions.assertEquals(loggingClickHousePlugin.getOrder(),
PluginEnum.LOGGING_CLICK_HOUSE.getCode());
+ }
+
+ @Test
+ public void testNamed() {
+ Assertions.assertEquals(loggingClickHousePlugin.named(),
PluginEnum.LOGGING_CLICK_HOUSE.getName());
+ }
+
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/client/ClickHouseLogCollectClientTest.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/client/ClickHouseLogCollectClientTest.java
new file mode 100644
index 000000000..dd0d81db5
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/client/ClickHouseLogCollectClientTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse.client;
+
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.utils.GsonUtils;
+import
org.apache.shenyu.plugin.logging.clickhouse.config.ClickHouseLogCollectConfig;
+import org.apache.shenyu.plugin.logging.common.constant.GenericLoggingConstant;
+import org.apache.shenyu.plugin.logging.common.entity.ShenyuRequestLog;
+import org.junit.After;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+
+/**
+ * test cases for ClickHouseLogCollectClient.
+ */
+public class ClickHouseLogCollectClientTest {
+
+ private final PluginData pluginData = new PluginData();
+
+ private final Properties properties = new Properties();
+
+ private final List<ShenyuRequestLog> logs = new ArrayList<>();
+
+ private final ShenyuRequestLog shenyuRequestLog = new ShenyuRequestLog();
+
+ private ClickHouseLogCollectConfig.ClickHouseLogConfig clickHouseLogConfig;
+
+ private ClickHouseLogCollectClient clickHouseLogCollectClient;
+
+ @BeforeEach
+ public void setUp() {
+ clickHouseLogCollectClient = new ClickHouseLogCollectClient();
+ pluginData.setEnabled(true);
+
pluginData.setConfig("{\"host\":\"127.0.0.1\",\"port\":\"8123\",\"database\":\"shenyu-gateway\",\"username\":\"foo\",\"password\":\"bar\"}");
+ clickHouseLogConfig =
GsonUtils.getInstance().fromJson(pluginData.getConfig(),
ClickHouseLogCollectConfig.ClickHouseLogConfig.class);
+ properties.setProperty(GenericLoggingConstant.HOST,
clickHouseLogConfig.getHost());
+ properties.setProperty(GenericLoggingConstant.PORT,
clickHouseLogConfig.getPort());
+ properties.setProperty(GenericLoggingConstant.DEFAULT_SOURCE,
clickHouseLogConfig.getDatabase());
+ properties.setProperty(GenericLoggingConstant.USERNAME,
clickHouseLogConfig.getUsername());
+ properties.setProperty(GenericLoggingConstant.PASSWORD,
clickHouseLogConfig.getPassword());
+ shenyuRequestLog.setClientIp("127.0.0.1");
+ shenyuRequestLog.setTimeLocal("2022-08-10 16:21:05.508");
+ shenyuRequestLog.setMethod("/http/shenyu/client/post/hi");
+
shenyuRequestLog.setRequestHeader("{\"content-length\":\"0\",\"Accept\":\"application/json\",\"Connection\":\"Keep-Alive\",\"User-Agent\":\"Apache-HttpClient/4.5.13
(Java/11.0.10)\","
+ +
"\"Host\":\"localhost:9195\",\"Accept-Encoding\":\"gzip,deflate\",\"Content-Type\":\"application/json\"}");
+
shenyuRequestLog.setResponseHeader("{\"content-length\":\"65\",\"transfer-encoding\":\"chunked\",\"Content-Type\":\"application/json;charset=UTF-8\"}");
+ shenyuRequestLog.setQueryParams("name=Tom");
+ shenyuRequestLog.setRequestBody("");
+
shenyuRequestLog.setRequestUri("http://localhost:9195/http/shenyu/client/post/hi?name=Tom");
+ shenyuRequestLog.setResponseBody("[post method result]:hi! Tom! I'm
Shenyu-Gateway System. Welcome!");
+ shenyuRequestLog.setResponseContentLength(65);
+ shenyuRequestLog.setRpcType("http");
+ shenyuRequestLog.setStatus(200);
+ shenyuRequestLog.setUpstreamIp("192.168.30.64");
+ shenyuRequestLog.setUpstreamResponseTime(302L);
+ shenyuRequestLog.setUserAgent("Apache-HttpClient/4.5.13
(Java/11.0.10)");
+ shenyuRequestLog.setHost("localhost:9195");
+ shenyuRequestLog.setModule("/http");
+ shenyuRequestLog.setTraceId("");
+ shenyuRequestLog.setPath("/http/shenyu/client/post/hi");
+ logs.add(shenyuRequestLog);
+ }
+
+ @Test
+ public void testConsume() {
+ String msg = "";
+
ClickHouseLogCollectConfig.INSTANCE.setClickHouseLogConfig(clickHouseLogConfig);
+ clickHouseLogCollectClient.initClient(properties);
+ try {
+ clickHouseLogCollectClient.consume(logs);
+ } catch (Exception e) {
+ msg = "false";
+ }
+ Assertions.assertEquals(msg, "false");
+ }
+
+ @After
+ public void clean() {
+ clickHouseLogCollectClient.close();
+ }
+
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/collector/ClickHouseLogCollectorTest.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/collector/ClickHouseLogCollectorTest.java
new file mode 100644
index 000000000..e1df05a42
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/collector/ClickHouseLogCollectorTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse.collector;
+
+import
org.apache.shenyu.plugin.logging.clickhouse.client.ClickHouseLogCollectClient;
+import org.apache.shenyu.plugin.logging.common.client.LogConsumeClient;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+/**
+ * The Test Case For ClickHouseLogCollector.
+ */
+public final class ClickHouseLogCollectorTest {
+
+ @Test
+ public void testGetLogConsumeClient() {
+ LogConsumeClient logConsumeClient = new
ClickHouseLogCollector().getLogConsumeClient();
+ Assertions.assertEquals(ClickHouseLogCollectClient.class,
logConsumeClient.getClass());
+ }
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/config/ClickHouseLogCollectConfigTest.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/config/ClickHouseLogCollectConfigTest.java
new file mode 100644
index 000000000..c348c0726
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/config/ClickHouseLogCollectConfigTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse.config;
+
+import org.apache.shenyu.plugin.logging.common.constant.GenericLoggingConstant;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * The Test Case For ClickHouseLogCollectConfig.
+ */
+public class ClickHouseLogCollectConfigTest {
+
+ private ClickHouseLogCollectConfig clickHouseLogCollectConfig = new
ClickHouseLogCollectConfig();
+
+ private ClickHouseLogCollectConfig.ClickHouseLogConfig clickHouseLogConfig
= new ClickHouseLogCollectConfig.ClickHouseLogConfig();
+
+ @BeforeEach
+ public void setUp() {
+ clickHouseLogConfig.setHost("127.0.0.1");
+ clickHouseLogConfig.setPort("8123");
+ clickHouseLogConfig.setUsername("foo");
+ clickHouseLogConfig.setPassword("bar");
+ clickHouseLogConfig.setDatabase(GenericLoggingConstant.DEFAULT_SOURCE);
+ }
+
+ @Test
+ public void testSetClickHouseLogConfig() {
+ clickHouseLogCollectConfig.setClickHouseLogConfig(clickHouseLogConfig);
+ Assertions.assertNull(null);
+ }
+
+ @Test
+ public void testGetClickHouseLogConfig() {
+ ClickHouseLogCollectConfig.ClickHouseLogConfig clickHouseLogConfig =
clickHouseLogCollectConfig.getClickHouseLogConfig();
+ Assertions.assertEquals(clickHouseLogConfig, clickHouseLogConfig);
+ }
+
+ @Test
+ public void testSetHost() {
+ clickHouseLogConfig.setHost("127.0.0.1");
+ Assertions.assertNull(null);
+ }
+
+ @Test
+ public void testGetHost() {
+ final String host = clickHouseLogConfig.getHost();
+ Assertions.assertEquals("127.0.0.1", host);
+ }
+
+ @Test
+ public void testSetPort() {
+ clickHouseLogConfig.setPort("8123");
+ Assertions.assertNull(null);
+ }
+
+ @Test
+ public void testGetPort() {
+ final String port = clickHouseLogConfig.getPort();
+ Assertions.assertEquals("8123", port);
+ }
+
+ @Test
+ public void testSetUsername() {
+ clickHouseLogConfig.setUsername("foo");
+ Assertions.assertNull(null);
+ }
+
+ @Test
+ public void testGetUsername() {
+ final String username = clickHouseLogConfig.getUsername();
+ Assertions.assertEquals("foo", username);
+ }
+
+ @Test
+ public void testSetPassword() {
+ clickHouseLogConfig.setPassword("bar");
+ Assertions.assertNull(null);
+ }
+
+ @Test
+ public void testGetPassword() {
+ final String password = clickHouseLogConfig.getPassword();
+ Assertions.assertEquals("bar", password);
+ }
+
+ @Test
+ public void testSetDatabase() {
+ clickHouseLogConfig.setDatabase(GenericLoggingConstant.DEFAULT_SOURCE);
+ Assertions.assertNull(null);
+ }
+
+ @Test
+ public void testGetDatabase() {
+ final String database = clickHouseLogConfig.getDatabase();
+ Assertions.assertEquals(GenericLoggingConstant.DEFAULT_SOURCE,
database);
+ }
+
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/handler/LoggingClickHousePluginDataHandlerTest.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/handler/LoggingClickHousePluginDataHandlerTest.java
new file mode 100644
index 000000000..97e73dab8
--- /dev/null
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/plugin/logging/clickhouse/handler/LoggingClickHousePluginDataHandlerTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.plugin.logging.clickhouse.handler;
+
+import org.apache.shenyu.common.dto.PluginData;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * The Test Case For ClickHousePluginDataHandler.
+ */
+public final class LoggingClickHousePluginDataHandlerTest {
+
+ private LoggingClickHousePluginDataHandler
loggingClickHousePluginDataHandler;
+
+ @BeforeEach
+ public void setUp() {
+ loggingClickHousePluginDataHandler = new
LoggingClickHousePluginDataHandler();
+ }
+
+ @Test
+ public void testHandlerPlugin() {
+ PluginData pluginData = new PluginData();
+
pluginData.setConfig("{\"host\":\"127.0.0.1\",\"port\":\"8123\",\"database\":\"shenyu-gateway\",\"username\":\"foo\",\"password\":\"bar\"}");
+ pluginData.setEnabled(true);
+ pluginData.setId("37");
+ pluginData.setName("loggingClickHouse");
+ pluginData.setRole("Logging");
+ pluginData.setSort(195);
+ loggingClickHousePluginDataHandler.handlerPlugin(pluginData);
+ Assertions.assertNull(null);
+ }
+
+ @Test
+ public void testPluginNamed() {
+
Assertions.assertEquals(loggingClickHousePluginDataHandler.pluginNamed(),
"loggingClickHouse");
+ }
+
+}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/constant/GenericLoggingConstant.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/constant/GenericLoggingConstant.java
index 542f31a45..80c3bca59 100644
---
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/constant/GenericLoggingConstant.java
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/constant/GenericLoggingConstant.java
@@ -186,4 +186,15 @@ public class GenericLoggingConstant {
* The constant PRODUCER_GROUP.
*/
public static final String PRODUCER_GROUP = "producerGroup";
+
+ /**
+ * The constant USERNAME.
+ */
+ public static final String USERNAME = "username";
+
+ /**
+ * The constant PASSWORD.
+ */
+ public static final String PASSWORD = "password";
+
}
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/entity/ShenyuRequestLog.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/entity/ShenyuRequestLog.java
index 94ac04234..617069ab6 100644
---
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/entity/ShenyuRequestLog.java
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/entity/ShenyuRequestLog.java
@@ -404,4 +404,29 @@ public class ShenyuRequestLog {
public void setPath(final String path) {
this.path = path;
}
+
+ @Override
+ public String toString() {
+ return "ShenyuRequestLog{"
+ + "timeLocal='" + timeLocal + '\''
+ + ", clientIp='" + clientIp + '\''
+ + ", method=" + method
+ + ", requestHeader=" + requestHeader
+ + ", responseHeader=" + responseHeader
+ + ", queryParams=" + queryParams
+ + ", requestBody=" + requestBody
+ + ", requestUri=" + requestUri
+ + ", responseBody=" + responseBody
+ + ", responseContentLength=" + responseContentLength
+ + ", rpcType=" + rpcType
+ + ", status=" + status
+ + ", upstreamIp=" + upstreamIp
+ + ", upstreamResponseTime=" + upstreamResponseTime
+ + ", userAgent=" + userAgent
+ + ", host=" + host
+ + ", module=" + module
+ + ", traceId=" + traceId
+ + ", path=" + path
+ + '}';
+ }
}
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/pom.xml
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/pom.xml
index 8c7e76746..5a574cc5c 100644
--- a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/pom.xml
+++ b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/pom.xml
@@ -66,5 +66,6 @@
<module>shenyu-spring-boot-starter-plugin-logging-aliyun-sls</module>
<module>shenyu-spring-boot-starter-plugin-logging-pulsar</module>
<module>shenyu-spring-boot-starter-plugin-logging-tencent-cls</module>
+ <module>shenyu-spring-boot-starter-plugin-logging-clickhouse</module>
</modules>
</project>
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/pom.xml
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/pom.xml
new file mode 100644
index 000000000..3e507e385
--- /dev/null
+++
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>shenyu-spring-boot-starter-plugin</artifactId>
+ <groupId>org.apache.shenyu</groupId>
+ <version>2.5.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>shenyu-spring-boot-starter-plugin-logging-clickhouse</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-plugin-logging-clickhouse</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/springboot/starter/plugin/logging/clickhouse/LoggingClickHousePluginConfiguration.java
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/springboot/starter/plugin/logging/clickhouse/LoggingClickHousePluginConfiguration.java
new file mode 100644
index 000000000..246de5b7d
--- /dev/null
+++
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/main/java/org/apache/shenyu/springboot/starter/plugin/logging/clickhouse/LoggingClickHousePluginConfiguration.java
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.springboot.starter.plugin.logging.clickhouse;
+
+import org.apache.shenyu.plugin.api.ShenyuPlugin;
+import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
+import org.apache.shenyu.plugin.logging.clickhouse.LoggingClickHousePlugin;
+import
org.apache.shenyu.plugin.logging.clickhouse.handler.LoggingClickHousePluginDataHandler;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * config logging Pulsar plugin.
+ */
+@Configuration
+@ConditionalOnProperty(value = {"shenyu.plugins.logging-clickhouse.enabled"},
havingValue = "true", matchIfMissing = true)
+public class LoggingClickHousePluginConfiguration {
+
+ /**
+ * loggingClickHousePluginDataHandler.
+ * @return loggingClickHousePluginDataHandler.
+ */
+ @Bean
+ public PluginDataHandler loggingClickHousePluginDataHandler() {
+ return new LoggingClickHousePluginDataHandler();
+ }
+
+ /**
+ * loggingClickHousePlugin.
+ * @return loggingClickHousePlugin.
+ */
+ @Bean
+ public ShenyuPlugin loggingClickHousePlugin() {
+ return new LoggingClickHousePlugin();
+ }
+}
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/main/resources/META-INF/spring.factories
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/main/resources/META-INF/spring.factories
new file mode 100644
index 000000000..9ec850a21
--- /dev/null
+++
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.shenyu.springboot.starter.plugin.logging.clickhouse.LoggingClickHousePluginConfiguration
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/main/resources/META-INF/spring.provides
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/main/resources/META-INF/spring.provides
new file mode 100644
index 000000000..e69de29bb
diff --git
a/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/springboot/starter/plugin/logging/clickhouse/LoggingClickHousePluginConfigurationTest.java
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/springboot/starter/plugin/logging/clickhouse/LoggingClickHousePluginConfigurationTest.java
new file mode 100644
index 000000000..16425e743
--- /dev/null
+++
b/shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-logging-clickhouse/src/test/java/org/apache/shenyu/springboot/starter/plugin/logging/clickhouse/LoggingClickHousePluginConfigurationTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+package org.apache.shenyu.springboot.starter.plugin.logging.clickhouse;
+
+import org.apache.shenyu.common.enums.PluginEnum;
+import org.apache.shenyu.plugin.api.ShenyuPlugin;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.autoconfigure.AutoConfigurations;
+import
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.context.annotation.Configuration;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * Test case for {@link LoggingClickHousePluginConfiguration}.
+ */
+@Configuration
+@EnableConfigurationProperties
+public class LoggingClickHousePluginConfigurationTest {
+
+ @Test
+ public void testLoggingPlugin() {
+ new ApplicationContextRunner()
+
.withConfiguration(AutoConfigurations.of(LoggingClickHousePluginConfiguration.class))
+ .withBean(LoggingClickHousePluginConfigurationTest.class)
+ .withPropertyValues("debug=true")
+ .run(context -> {
+ ShenyuPlugin plugin =
context.getBean("loggingClickHousePlugin", ShenyuPlugin.class);
+ assertNotNull(plugin);
+
assertThat(plugin.named()).isEqualTo(PluginEnum.LOGGING_CLICK_HOUSE.getName());
+ });
+ }
+}