diff --git a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsClusterDataStorage.java b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsClusterDataStorage.java index 5371a26e1c3..dc27adac273 100644 --- a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsClusterDataStorage.java +++ b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsClusterDataStorage.java @@ -287,13 +287,13 @@ public void destroy() { public Map> getHistoryMetricData(String instance, String app, String metrics, String metric, String history) { String labelName = metrics + SPILT + metric; - if (CommonConstants.PROMETHEUS.equals(app)) { + if (app.startsWith(CommonConstants.PROMETHEUS_APP_PREFIX)) { labelName = metrics; } String timeSeriesSelector = Stream.of( - LABEL_KEY_NAME + "=\"" + labelName + "\"", - LABEL_KEY_INSTANCE + "=\"" + instance + "\"", - CommonConstants.PROMETHEUS.equals(app) ? null : MONITOR_METRIC_KEY + "=\"" + metric + "\"" + LABEL_KEY_NAME + "=\"" + labelName + "\"", + LABEL_KEY_INSTANCE + "=\"" + instance + "\"", + app.startsWith(CommonConstants.PROMETHEUS_APP_PREFIX) ? null : MONITOR_METRIC_KEY + "=\"" + metric + "\"" ).filter(Objects::nonNull).collect(Collectors.joining(",")); Map> instanceValuesMap = new HashMap<>(8); try { @@ -388,13 +388,13 @@ public Map> getHistoryIntervalMetricData(String instance, St startTime = dateTime.toEpochSecond(); } String labelName = metrics + SPILT + metric; - if (CommonConstants.PROMETHEUS.equals(app)) { + if (app.startsWith(CommonConstants.PROMETHEUS_APP_PREFIX)) { labelName = metrics; } String timeSeriesSelector = Stream.of( - LABEL_KEY_NAME + "=\"" + labelName + "\"", - LABEL_KEY_INSTANCE + "=\"" + instance + "\"", - CommonConstants.PROMETHEUS.equals(app) ? null : MONITOR_METRIC_KEY + "=\"" + metric + "\"" + LABEL_KEY_NAME + "=\"" + labelName + "\"", + LABEL_KEY_INSTANCE + "=\"" + instance + "\"", + app.startsWith(CommonConstants.PROMETHEUS_APP_PREFIX) ? null : MONITOR_METRIC_KEY + "=\"" + metric + "\"" ).filter(Objects::nonNull).collect(Collectors.joining(",")); Map> instanceValuesMap = new HashMap<>(8); try { diff --git a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsDataStorage.java b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsDataStorage.java index 5267e9fe9c0..5714e42186e 100644 --- a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsDataStorage.java +++ b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/tsdb/vm/VictoriaMetricsDataStorage.java @@ -265,12 +265,12 @@ public void destroy() { @Override public Map> getHistoryMetricData(String instance, String app, String metrics, String metric, String history) { String labelName = metrics + SPILT + metric; - if (CommonConstants.PROMETHEUS.equals(app)) { + if (app.startsWith(CommonConstants.PROMETHEUS_APP_PREFIX)) { labelName = metrics; } String timeSeriesSelector = LABEL_KEY_NAME + "=\"" + labelName + "\"" - + "," + LABEL_KEY_INSTANCE + "=\"" + instance + "\"" - + (CommonConstants.PROMETHEUS.equals(app) ? "" : "," + MONITOR_METRIC_KEY + "=\"" + metric + "\""); + + "," + LABEL_KEY_INSTANCE + "=\"" + instance + "\"" + + (app.startsWith(CommonConstants.PROMETHEUS_APP_PREFIX) ? "" : "," + MONITOR_METRIC_KEY + "=\"" + metric + "\""); Map> instanceValuesMap = new HashMap<>(8); try { HttpHeaders headers = new HttpHeaders(); @@ -362,12 +362,12 @@ public Map> getHistoryIntervalMetricData(String instance, St startTime = dateTime.toEpochSecond(); } String labelName = metrics + SPILT + metric; - if (CommonConstants.PROMETHEUS.equals(app)) { + if (app.startsWith(CommonConstants.PROMETHEUS_APP_PREFIX)) { labelName = metrics; } String timeSeriesSelector = LABEL_KEY_NAME + "=\"" + labelName + "\"" - + "," + LABEL_KEY_INSTANCE + "=\"" + instance + "\"" - + (CommonConstants.PROMETHEUS.equals(app) ? "" : "," + MONITOR_METRIC_KEY + "=\"" + metric + "\""); + + "," + LABEL_KEY_INSTANCE + "=\"" + instance + "\"" + + (app.startsWith(CommonConstants.PROMETHEUS_APP_PREFIX) ? "" : "," + MONITOR_METRIC_KEY + "=\"" + metric + "\""); Map> instanceValuesMap = new HashMap<>(8); try { HttpHeaders headers = new HttpHeaders(); diff --git a/web-app/src/app/routes/monitor/monitor-data-chart/monitor-data-chart.component.ts b/web-app/src/app/routes/monitor/monitor-data-chart/monitor-data-chart.component.ts index 9b7b2b9ebf0..d98c6962778 100644 --- a/web-app/src/app/routes/monitor/monitor-data-chart/monitor-data-chart.component.ts +++ b/web-app/src/app/routes/monitor/monitor-data-chart/monitor-data-chart.component.ts @@ -46,6 +46,8 @@ export class MonitorDataChartComponent implements OnInit, OnDestroy { @Input() instance!: string; @Input() + monitorName!: string; + @Input() app!: string; @Input() metrics!: string; @@ -264,7 +266,14 @@ export class MonitorDataChartComponent implements OnInit, OnDestroy { // load historical metrics data this.loading = `${this.i18nSvc.fanyi('monitor.detail.chart.data-loading')}`; let metricData$ = this.monitorSvc - .getMonitorMetricHistoryData(this.instance, this.app, this.metrics, this.metric, this.timePeriod, isInterval) + .getMonitorMetricHistoryData( + this.instance, + this.app == 'prometheus' ? `_prometheus_${this.monitorName}` : this.app, + this.metrics, + this.metric, + this.timePeriod, + isInterval + ) .pipe( finalize(() => { if (!this.worker$) { diff --git a/web-app/src/app/routes/monitor/monitor-detail/monitor-detail.component.html b/web-app/src/app/routes/monitor/monitor-detail/monitor-detail.component.html index 9daf780eebd..db7d95407d2 100755 --- a/web-app/src/app/routes/monitor/monitor-detail/monitor-detail.component.html +++ b/web-app/src/app/routes/monitor/monitor-detail/monitor-detail.component.html @@ -93,6 +93,7 @@ [unit]="item.unit" [monitorId]="monitorId" [instance]="monitor.instance" + [monitorName]="monitor.name" >