From d58d46ca8c51903b82211e5a3298a1c722c27019 Mon Sep 17 00:00:00 2001 From: lijiahangmax Date: Mon, 6 Oct 2025 16:18:20 +0800 Subject: [PATCH] =?UTF-8?q?:hammer:=20=E4=BF=AE=E6=94=B9=20influx=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AF=AD=E5=8F=A5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../influxdb/core/query/FluxQueryBuilder.java | 30 +++++-------------- .../request/host/MonitorHostChartRequest.java | 18 +++++------ .../service/impl/MonitorHostServiceImpl.java | 1 + .../compoments/metrics-chart.vue | 1 + 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/orion-visor-framework/orion-visor-spring-boot-starter-influxdb/src/main/java/org/dromara/visor/framework/influxdb/core/query/FluxQueryBuilder.java b/orion-visor-framework/orion-visor-spring-boot-starter-influxdb/src/main/java/org/dromara/visor/framework/influxdb/core/query/FluxQueryBuilder.java index 1e479080..9289e369 100644 --- a/orion-visor-framework/orion-visor-spring-boot-starter-influxdb/src/main/java/org/dromara/visor/framework/influxdb/core/query/FluxQueryBuilder.java +++ b/orion-visor-framework/orion-visor-spring-boot-starter-influxdb/src/main/java/org/dromara/visor/framework/influxdb/core/query/FluxQueryBuilder.java @@ -24,6 +24,7 @@ package org.dromara.visor.framework.influxdb.core.query; import cn.orionsec.kit.lang.utils.collect.Collections; import cn.orionsec.kit.lang.utils.collect.Lists; +import cn.orionsec.kit.lang.utils.collect.Maps; import org.dromara.visor.common.constant.Const; import java.time.Instant; @@ -194,7 +195,7 @@ public class FluxQueryBuilder { if (values.size() == 1) { return this.tag(key, Collections.first(values)); } - // + // 使用 or 拼接 Collection conditions = values.stream() .map(value -> String.format("r[\"%s\"] == \"%s\"", key, value)) .collect(Collectors.toList()); @@ -204,33 +205,18 @@ public class FluxQueryBuilder { } /** - * 过滤多个 tag - * tag 使用 and - * value 使用 or + * 过滤 tag * * @param tags tags * @return this */ public FluxQueryBuilder tags(Map> tags) { - for (Map.Entry> entry : tags.entrySet()) { - String key = entry.getKey(); - Collection values = entry.getValue(); - if (Collections.isEmpty(values)) { - continue; - } - if (values.size() == 1) { - // 单值直接用等号 - String singleValue = values.iterator().next(); - this.appendFilter(String.format("r[\"%s\"] == \"%s\"", key, singleValue)); - } else { - // 多值用 OR - Collection conditions = values.stream() - .map(v -> String.format("r[\"%s\"] == \"%s\"", key, v)) - .collect(Collectors.toList()); - this.appendFilter("(" + String.join(" or ", conditions) + ")"); - } + if (Maps.isEmpty(tags)) { + return this; + } + for (Map.Entry> entry : tags.entrySet()) { + this.tag(entry.getKey(), entry.getValue()); } - this.closeFilter(); return this; } diff --git a/orion-visor-modules/orion-visor-module-monitor/orion-visor-module-monitor-service/src/main/java/org/dromara/visor/module/monitor/entity/request/host/MonitorHostChartRequest.java b/orion-visor-modules/orion-visor-module-monitor/orion-visor-module-monitor-service/src/main/java/org/dromara/visor/module/monitor/entity/request/host/MonitorHostChartRequest.java index 770a492d..d5245149 100644 --- a/orion-visor-modules/orion-visor-module-monitor/orion-visor-module-monitor-service/src/main/java/org/dromara/visor/module/monitor/entity/request/host/MonitorHostChartRequest.java +++ b/orion-visor-modules/orion-visor-module-monitor/orion-visor-module-monitor-service/src/main/java/org/dromara/visor/module/monitor/entity/request/host/MonitorHostChartRequest.java @@ -59,17 +59,17 @@ public class MonitorHostChartRequest extends BaseQueryRequest { @Schema(description = "时间窗口") private String window; + @Schema(description = "时间区间") + private String range; + + @Schema(description = "时间区间") + private Long start; + + @Schema(description = "时间区间") + private Long end; + @NotBlank @Schema(description = "聚合参数") private String aggregate; - @Schema(description = "聚合参数") - private Long start; - - @Schema(description = "聚合参数") - private Long end; - - @Schema(description = "区间") - private String range; - } diff --git a/orion-visor-modules/orion-visor-module-monitor/orion-visor-module-monitor-service/src/main/java/org/dromara/visor/module/monitor/service/impl/MonitorHostServiceImpl.java b/orion-visor-modules/orion-visor-module-monitor/orion-visor-module-monitor-service/src/main/java/org/dromara/visor/module/monitor/service/impl/MonitorHostServiceImpl.java index f7888f3c..84623030 100644 --- a/orion-visor-modules/orion-visor-module-monitor/orion-visor-module-monitor-service/src/main/java/org/dromara/visor/module/monitor/service/impl/MonitorHostServiceImpl.java +++ b/orion-visor-modules/orion-visor-module-monitor/orion-visor-module-monitor-service/src/main/java/org/dromara/visor/module/monitor/service/impl/MonitorHostServiceImpl.java @@ -372,6 +372,7 @@ public class MonitorHostServiceImpl implements MonitorHostService { } else { Assert.notNull(request.getStart(), ErrorMessage.PARAM_MISSING); Assert.notNull(request.getEnd(), ErrorMessage.PARAM_MISSING); + query.range(request.getStart(), request.getEnd()); } // 设置名称 Set names = null; diff --git a/orion-visor-ui/src/views/monitor/monitor-detail/compoments/metrics-chart.vue b/orion-visor-ui/src/views/monitor/monitor-detail/compoments/metrics-chart.vue index 5ae17b91..6927ccc6 100644 --- a/orion-visor-ui/src/views/monitor/monitor-detail/compoments/metrics-chart.vue +++ b/orion-visor-ui/src/views/monitor/monitor-detail/compoments/metrics-chart.vue @@ -70,6 +70,7 @@ animation: false, tooltip: { trigger: 'axis', + appendToBody: true, backgroundColor: 'rgba(255, 255, 255, 0.9)', textStyle: { color: 'rgba(0, 0, 0, 0.8)',