This is an automated email from the ASF dual-hosted git repository.

gongchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/master by this push:
     new 67f525a603 [fix] update table name generation to include application 
context (#4001)
67f525a603 is described below

commit 67f525a60391d6d0ba5748af071c5e0617e426b8
Author: Logic <[email protected]>
AuthorDate: Sat Jan 24 23:26:08 2026 +0800

    [fix] update table name generation to include application context (#4001)
    
    Co-authored-by: Tomsun28 <[email protected]>
---
 .../store/history/tsdb/greptime/GreptimeDbDataStorage.java | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git 
a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/greptime/GreptimeDbDataStorage.java
 
b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/greptime/GreptimeDbDataStorage.java
index 8443fd255a..a3130736bc 100644
--- 
a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/greptime/GreptimeDbDataStorage.java
+++ 
b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/greptime/GreptimeDbDataStorage.java
@@ -43,6 +43,7 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -143,7 +144,8 @@ public class GreptimeDbDataStorage extends 
AbstractHistoryDataStorage {
             return;
         }
         String instance = metricsData.getInstance();
-        String tableName = getTableName(metricsData.getMetrics());
+        String app = metricsData.getApp();
+        String tableName = getTableName(app, metricsData.getMetrics());
         TableSchema.Builder tableSchemaBuilder = 
TableSchema.newBuilder(tableName);
 
         tableSchemaBuilder.addTag("instance", DataType.String)
@@ -220,8 +222,8 @@ public class GreptimeDbDataStorage extends 
AbstractHistoryDataStorage {
         return getHistoryData(start, end, step, instance, app, metrics, 
metric);
     }
 
-    private String getTableName(String metrics) {
-        return metrics;
+    private String getTableName(String app, String metrics) {
+        return app + "_" + metrics;
     }
 
     @Override
@@ -246,7 +248,7 @@ public class GreptimeDbDataStorage extends 
AbstractHistoryDataStorage {
         long effectiveStart = values.get(0).getTime() / 1000;
         long effectiveEnd = values.get(values.size() - 1).getTime() / 1000 + 
Duration.ofHours(4).getSeconds();
 
-        String name = getTableName(metrics);
+        String name = getTableName(app, metrics);
         String timeSeriesSelector = name + "{" + LABEL_KEY_INSTANCE + "=\"" + 
instance + "\"";
         if (!CommonConstants.PROMETHEUS.equals(app)) {
             timeSeriesSelector = timeSeriesSelector + "," + LABEL_KEY_FIELD + 
"=\"" + metric + "\"";
@@ -330,7 +332,7 @@ public class GreptimeDbDataStorage extends 
AbstractHistoryDataStorage {
      * @return history metric data
      */
     private Map<String, List<Value>> getHistoryData(long start, long end, 
String step, String instance, String app, String metrics, String metric) {
-        String name = getTableName(metrics);
+        String name = getTableName(app, metrics);
         String timeSeriesSelector = LABEL_KEY_NAME + "=\"" + name + "\""
                 + "," + LABEL_KEY_INSTANCE + "=\"" + instance + "\"";
         if (!CommonConstants.PROMETHEUS.equals(app)) {
@@ -764,7 +766,7 @@ public class GreptimeDbDataStorage extends 
AbstractHistoryDataStorage {
         try {
             StringBuilder sql = new StringBuilder("DELETE FROM 
").append(LOG_TABLE_NAME).append(" WHERE time_unix_nano IN (");
             sql.append(timeUnixNanos.stream()
-                    .filter(time -> time != null)
+                    .filter(Objects::nonNull)
                     .map(String::valueOf)
                     .collect(Collectors.joining(", ")));
             sql.append(")");


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to