From 9589e016011fc0966fd94089a040037ec9bd269e Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Fri, 8 Dec 2023 10:15:08 +0800 Subject: [PATCH] bugfix metrics tags value store jpa data-storage error (#1403) Signed-off-by: tomsun28 --- script/assembly/collector/assembly-linux-amd64.xml | 2 +- script/assembly/collector/assembly-linux-arm64.xml | 2 +- script/assembly/collector/assembly-macos-amd64.xml | 2 +- script/assembly/collector/assembly-macos-arm64.xml | 2 +- script/assembly/collector/assembly-windows-64.xml | 2 +- script/assembly/server/assembly-linux-amd64.xml | 2 +- script/assembly/server/assembly-linux-arm64.xml | 2 +- script/assembly/server/assembly-macos-amd64.xml | 2 +- script/assembly/server/assembly-macos-arm64.xml | 2 +- script/assembly/server/assembly-windows-64.xml | 2 +- .../store/HistoryJpaDatabaseDataStorage.java | 11 +++++++---- 11 files changed, 17 insertions(+), 14 deletions(-) diff --git a/script/assembly/collector/assembly-linux-amd64.xml b/script/assembly/collector/assembly-linux-amd64.xml index 53c3f95eb5f..ce1f4f41642 100644 --- a/script/assembly/collector/assembly-linux-amd64.xml +++ b/script/assembly/collector/assembly-linux-amd64.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 "> - linux_amd64_1.4.2 + linux_amd64_1.4.3 tar.gz diff --git a/script/assembly/collector/assembly-linux-arm64.xml b/script/assembly/collector/assembly-linux-arm64.xml index a60dd7fd454..89d3ad21ced 100644 --- a/script/assembly/collector/assembly-linux-arm64.xml +++ b/script/assembly/collector/assembly-linux-arm64.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 "> - linux_arm64_1.4.2 + linux_arm64_1.4.3 tar.gz diff --git a/script/assembly/collector/assembly-macos-amd64.xml b/script/assembly/collector/assembly-macos-amd64.xml index c389c829f21..ffdcffe7ed2 100644 --- a/script/assembly/collector/assembly-macos-amd64.xml +++ b/script/assembly/collector/assembly-macos-amd64.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 "> - macos_amd64_1.4.2 + macos_amd64_1.4.3 tar.gz diff --git a/script/assembly/collector/assembly-macos-arm64.xml b/script/assembly/collector/assembly-macos-arm64.xml index b58c4a37115..cf4a13cbf02 100644 --- a/script/assembly/collector/assembly-macos-arm64.xml +++ b/script/assembly/collector/assembly-macos-arm64.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 "> - macos_arm64_1.4.2 + macos_arm64_1.4.3 tar.gz diff --git a/script/assembly/collector/assembly-windows-64.xml b/script/assembly/collector/assembly-windows-64.xml index 6a1d6cbeda8..e0074d2ae4b 100644 --- a/script/assembly/collector/assembly-windows-64.xml +++ b/script/assembly/collector/assembly-windows-64.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 "> - windows64_1.4.2 + windows64_1.4.3 zip diff --git a/script/assembly/server/assembly-linux-amd64.xml b/script/assembly/server/assembly-linux-amd64.xml index efa26d9dbbc..a95923867a6 100644 --- a/script/assembly/server/assembly-linux-amd64.xml +++ b/script/assembly/server/assembly-linux-amd64.xml @@ -19,7 +19,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 "> - linux_amd64_1.4.2 + linux_amd64_1.4.3 tar.gz diff --git a/script/assembly/server/assembly-linux-arm64.xml b/script/assembly/server/assembly-linux-arm64.xml index 4e4e61132ea..9e2c5adb88c 100644 --- a/script/assembly/server/assembly-linux-arm64.xml +++ b/script/assembly/server/assembly-linux-arm64.xml @@ -19,7 +19,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 "> - linux_arm64_1.4.2 + linux_arm64_1.4.3 tar.gz diff --git a/script/assembly/server/assembly-macos-amd64.xml b/script/assembly/server/assembly-macos-amd64.xml index 1182e380206..3748e21b7cb 100644 --- a/script/assembly/server/assembly-macos-amd64.xml +++ b/script/assembly/server/assembly-macos-amd64.xml @@ -19,7 +19,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 "> - macos_amd64_1.4.2 + macos_amd64_1.4.3 tar.gz diff --git a/script/assembly/server/assembly-macos-arm64.xml b/script/assembly/server/assembly-macos-arm64.xml index c0577af270a..ffe77c624ff 100644 --- a/script/assembly/server/assembly-macos-arm64.xml +++ b/script/assembly/server/assembly-macos-arm64.xml @@ -19,7 +19,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 "> - macos_arm64_1.4.2 + macos_arm64_1.4.3 tar.gz diff --git a/script/assembly/server/assembly-windows-64.xml b/script/assembly/server/assembly-windows-64.xml index b988bcd77f2..767a53e65a2 100644 --- a/script/assembly/server/assembly-windows-64.xml +++ b/script/assembly/server/assembly-windows-64.xml @@ -19,7 +19,7 @@ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 "> - windows64_1.4.2 + windows64_1.4.3 zip diff --git a/warehouse/src/main/java/org/dromara/hertzbeat/warehouse/store/HistoryJpaDatabaseDataStorage.java b/warehouse/src/main/java/org/dromara/hertzbeat/warehouse/store/HistoryJpaDatabaseDataStorage.java index 017f1dc60d9..f937cbf23dc 100644 --- a/warehouse/src/main/java/org/dromara/hertzbeat/warehouse/store/HistoryJpaDatabaseDataStorage.java +++ b/warehouse/src/main/java/org/dromara/hertzbeat/warehouse/store/HistoryJpaDatabaseDataStorage.java @@ -134,6 +134,12 @@ void saveData(CollectRep.MetricsData metricsData) { .time(metricsData.getTime()); for (CollectRep.ValueRow valueRow : metricsData.getValuesList()) { Map labels = new HashMap<>(8); + for (int i = 0; i < fieldsList.size(); i++) { + CollectRep.Field field = fieldsList.get(i); + if (field.getLabel() && !CommonConstants.NULL_VALUE.equals(valueRow.getColumns(i))) { + labels.put(field.getName(), valueRow.getColumns(i)); + } + } for (int i = 0; i < fieldsList.size(); i++) { CollectRep.Field field = fieldsList.get(i); // ignore string value store in db @@ -141,6 +147,7 @@ void saveData(CollectRep.MetricsData metricsData) { continue; } historyBuilder.metric(field.getName()); + historyBuilder.instance(JsonUtil.toJson(labels)); if (!CommonConstants.NULL_VALUE.equals(valueRow.getColumns(i))) { if (field.getType() == CommonConstants.TYPE_NUMBER) { historyBuilder.metricType(CommonConstants.TYPE_NUMBER) @@ -149,9 +156,6 @@ void saveData(CollectRep.MetricsData metricsData) { historyBuilder.metricType(CommonConstants.TYPE_STRING) .str(formatStrValue(valueRow.getColumns(i))); } - if (field.getLabel()) { - labels.put(field.getName(), valueRow.getColumns(i)); - } } else { if (field.getType() == CommonConstants.TYPE_NUMBER) { historyBuilder.metricType(CommonConstants.TYPE_NUMBER).dou(null); @@ -161,7 +165,6 @@ void saveData(CollectRep.MetricsData metricsData) { } historyList.add(historyBuilder.build()); } - historyBuilder.instance(JsonUtil.toJson(labels)); } historyDao.saveAll(historyList); } catch (Exception e) {