This is an automated email from the ASF dual-hosted git repository.
zhaoqingran 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 634006aa7e [refactor] Dynamically concatenate app parameter on the
front end to accommodate Prometheus apps (#4000)
634006aa7e is described below
commit 634006aa7e7bd731ed8239bb45927f21da5f322f
Author: LunaRain_079 <[email protected]>
AuthorDate: Sat Jan 24 23:06:25 2026 +0800
[refactor] Dynamically concatenate app parameter on the front end to
accommodate Prometheus apps (#4000)
Co-authored-by: Duansg <[email protected]>
---
.../tsdb/vm/VictoriaMetricsClusterDataStorage.java | 16 ++++++++--------
.../history/tsdb/vm/VictoriaMetricsDataStorage.java | 12 ++++++------
.../monitor-data-chart/monitor-data-chart.component.ts | 11 ++++++++++-
.../monitor/monitor-detail/monitor-detail.component.html | 1 +
4 files changed, 25 insertions(+), 15 deletions(-)
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 5371a26e1c..dc27adac27 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 class VictoriaMetricsClusterDataStorage extends
AbstractHistoryDataStorag
public Map<String, List<Value>> 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<String, List<Value>> instanceValuesMap = new HashMap<>(8);
try {
@@ -388,13 +388,13 @@ public class VictoriaMetricsClusterDataStorage extends
AbstractHistoryDataStorag
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<String, List<Value>> 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 5267e9fe9c..5714e42186 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 class VictoriaMetricsDataStorage extends
AbstractHistoryDataStorage {
@Override
public Map<String, List<Value>> 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<String, List<Value>> instanceValuesMap = new HashMap<>(8);
try {
HttpHeaders headers = new HttpHeaders();
@@ -362,12 +362,12 @@ public class VictoriaMetricsDataStorage extends
AbstractHistoryDataStorage {
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<String, List<Value>> 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 9b7b2b9ebf..d98c696277 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 9daf780eeb..db7d95407d 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"
></app-monitor-data-chart>
<!-- IO sentinel for lazy loading charts -->
<div id="charts-load-sentinel" style="width: 100%; height:
1px"></div>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]