From 0c84cad8e5cb992dbe79324ed9606072adcbce99 Mon Sep 17 00:00:00 2001 From: "saimu.msm" Date: Tue, 1 Aug 2023 15:56:50 +0800 Subject: [PATCH] create metricinfo --- .../holoinsight/server/common/dao/entity/MetricInfo.java | 2 ++ .../server/common/dao/entity/dto/MetricInfoDTO.java | 2 ++ .../db/migration/V14__230801_ADD_metricinfo_COLUMN.sql | 9 +++++++++ .../server/home/task/AbstractMetricCrawlerBuilder.java | 7 +++++-- .../home/task/crawler/ApmMetricCrawlerBuilder.java | 3 ++- .../home/task/crawler/JvmMetricCrawlerBuilder.java | 3 ++- .../home/task/crawler/MysqlMetricCrawlerBuilder.java | 3 ++- .../home/task/crawler/PortCheckMetricCrawlerBuilder.java | 3 ++- .../home/task/crawler/SystemMetricCrawlerBuilder.java | 3 ++- 9 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 server/extension/extension-common-flyway/src/main/resources/db/migration/V14__230801_ADD_metricinfo_COLUMN.sql diff --git a/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/MetricInfo.java b/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/MetricInfo.java index 1bb7ff292..80b6750a9 100644 --- a/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/MetricInfo.java +++ b/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/MetricInfo.java @@ -50,6 +50,8 @@ public class MetricInfo { public boolean deleted; + public String storageTenant; + @TableField(value = "`gmt_create`") public Date gmtCreate; diff --git a/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/dto/MetricInfoDTO.java b/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/dto/MetricInfoDTO.java index 984a4f899..662510461 100644 --- a/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/dto/MetricInfoDTO.java +++ b/server/common/common-dao/src/main/java/io/holoinsight/server/common/dao/entity/dto/MetricInfoDTO.java @@ -45,6 +45,8 @@ public class MetricInfoDTO { public String ref; public String extInfo; + public String storageTenant; + public Date gmtCreate; public Date gmtModified; diff --git a/server/extension/extension-common-flyway/src/main/resources/db/migration/V14__230801_ADD_metricinfo_COLUMN.sql b/server/extension/extension-common-flyway/src/main/resources/db/migration/V14__230801_ADD_metricinfo_COLUMN.sql new file mode 100644 index 000000000..68c55966a --- /dev/null +++ b/server/extension/extension-common-flyway/src/main/resources/db/migration/V14__230801_ADD_metricinfo_COLUMN.sql @@ -0,0 +1,9 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +-- ---------------------------- +-- Table structure for metric_info +-- ---------------------------- +ALTER TABLE `metric_info` + ADD COLUMN `storage_tenant` VARCHAR(200) NULL AFTER `ext_info`; diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/AbstractMetricCrawlerBuilder.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/AbstractMetricCrawlerBuilder.java index 1498f03e9..909f711d6 100644 --- a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/AbstractMetricCrawlerBuilder.java +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/AbstractMetricCrawlerBuilder.java @@ -40,7 +40,8 @@ public List buildEntity(IntegrationProductDTO integrationProduct) { if (!CollectionUtils.isEmpty(model.getMetricInfoList())) { metricInfoList.addAll(model.getMetricInfoList()); } - List list = getMetricInfoList(model.getMetric(), model.getTags()); + List list = + getMetricInfoList(model.getMetric(), model.getTags(), model.getMetricInfoTemplate()); if (!CollectionUtils.isEmpty(list)) { metricInfoList.addAll(list); } @@ -50,7 +51,8 @@ public List buildEntity(IntegrationProductDTO integrationProduct) { return metricInfoList; } - protected abstract List getMetricInfoList(String metric, List tags); + protected abstract List getMetricInfoList(String metric, List tags, + MetricInfo metricInfoTemplate); public List getMetricInfoModel(String product) { @@ -68,6 +70,7 @@ public static class MetricInfoModel { public String metric; public List tags = new ArrayList<>(); public List metricInfoList = new ArrayList<>(); + public MetricInfo metricInfoTemplate; } public MetricInfo genMetricInfo(String tenant, String workspace, String organization, diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/ApmMetricCrawlerBuilder.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/ApmMetricCrawlerBuilder.java index b64e610d6..8453f3043 100644 --- a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/ApmMetricCrawlerBuilder.java +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/ApmMetricCrawlerBuilder.java @@ -84,7 +84,8 @@ public List buildEntity(IntegrationProductDTO integrationProduct) { } @Override - protected List getMetricInfoList(String metric, List tags) { + protected List getMetricInfoList(String metric, List tags, + MetricInfo metricInfoTemplate) { return null; } } diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/JvmMetricCrawlerBuilder.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/JvmMetricCrawlerBuilder.java index 91778321f..468f320d1 100644 --- a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/JvmMetricCrawlerBuilder.java +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/JvmMetricCrawlerBuilder.java @@ -29,7 +29,8 @@ public class JvmMetricCrawlerBuilder extends AbstractMetricCrawlerBuilder { @Override - protected List getMetricInfoList(String metric, List tags) { + protected List getMetricInfoList(String metric, List tags, + MetricInfo metricInfoTemplate) { List metricInfoList = new ArrayList<>(); metricInfoList.add(genMetricInfo(GLOBAL_TENANT, GLOBAL_WORKSPACE, GLOBAL_ORGANIZATION, "jvm", diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/MysqlMetricCrawlerBuilder.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/MysqlMetricCrawlerBuilder.java index ec0946c92..15d06b59d 100644 --- a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/MysqlMetricCrawlerBuilder.java +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/MysqlMetricCrawlerBuilder.java @@ -33,7 +33,8 @@ @MetricCrawler(code = "io.holoinsight.plugin.MysqlPlugin") public class MysqlMetricCrawlerBuilder extends AbstractMetricCrawlerBuilder { @Override - protected List getMetricInfoList(String metric, List tags) { + protected List getMetricInfoList(String metric, List tags, + MetricInfo metricInfoTemplate) { List metricInfoList = new ArrayList<>(); Map> listMap = J.fromJson(metricData, diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/PortCheckMetricCrawlerBuilder.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/PortCheckMetricCrawlerBuilder.java index 5f9766894..4fead3bca 100644 --- a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/PortCheckMetricCrawlerBuilder.java +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/PortCheckMetricCrawlerBuilder.java @@ -28,7 +28,8 @@ public class PortCheckMetricCrawlerBuilder extends AbstractMetricCrawlerBuilder { @Override - protected List getMetricInfoList(String metric, List tags) { + protected List getMetricInfoList(String metric, List tags, + MetricInfo metricInfoTemplate) { List metricInfoList = new ArrayList<>(); metricInfoList.add(genMetricInfo(GLOBAL_TENANT, GLOBAL_WORKSPACE, GLOBAL_ORGANIZATION, diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/SystemMetricCrawlerBuilder.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/SystemMetricCrawlerBuilder.java index 682a74dbc..bb3cbaaf0 100644 --- a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/SystemMetricCrawlerBuilder.java +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/crawler/SystemMetricCrawlerBuilder.java @@ -25,7 +25,8 @@ public class SystemMetricCrawlerBuilder extends AbstractMetricCrawlerBuilder { @Override - protected List getMetricInfoList(String metric, List tags) { + protected List getMetricInfoList(String metric, List tags, + MetricInfo metricInfoTemplate) { List metricInfoList = new ArrayList<>(); metricInfoList.add(genMetricInfo(GLOBAL_TENANT, GLOBAL_WORKSPACE, GLOBAL_ORGANIZATION, "system", "CPU", "cpu_util", "k8s_pod_cpu_util", "cpu 使用率", PERCENT_UNIT, 60, tags));