mirror of
https://github.com/dromara/hertzbeat.git
synced 2026-09-17 09:40:58 +00:00
[fix] Update the correct replacement of outdated functions and placeholders (#3516)
Co-authored-by: Calvin <zhengqiwei@apache.org> Co-authored-by: aias00 <liuhongyu@apache.org>
This commit is contained in:
+4
-4
@@ -98,7 +98,7 @@ public abstract class PromqlQueryExecutor implements QueryExecutor {
|
||||
}
|
||||
HttpEntity<Void> httpEntity = new HttpEntity<>(headers);
|
||||
|
||||
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromHttpUrl(httpPromqlProperties.url + QUERY_PATH);
|
||||
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromUriString(httpPromqlProperties.url + QUERY_PATH);
|
||||
uriComponentsBuilder.queryParam(HTTP_QUERY_PARAM, queryString);
|
||||
URI uri = uriComponentsBuilder.build().toUri();
|
||||
ResponseEntity<PromQlQueryContent> responseEntity = restTemplate.exchange(uri,
|
||||
@@ -150,18 +150,18 @@ public abstract class PromqlQueryExecutor implements QueryExecutor {
|
||||
HttpEntity<Void> httpEntity = new HttpEntity<>(headers);
|
||||
URI uri;
|
||||
if (datasourceQuery.getTimeType().equals(RANGE)) {
|
||||
uri = UriComponentsBuilder.fromHttpUrl(httpPromqlProperties.url() + QUERY_RANGE_PATH)
|
||||
uri = UriComponentsBuilder.fromUriString(httpPromqlProperties.url() + QUERY_RANGE_PATH)
|
||||
.queryParam(HTTP_QUERY_PARAM, datasourceQuery.getExpr())
|
||||
.queryParam(HTTP_START_PARAM, datasourceQuery.getStart())
|
||||
.queryParam(HTTP_END_PARAM, datasourceQuery.getEnd())
|
||||
.queryParam(HTTP_STEP_PARAM, datasourceQuery.getStep())
|
||||
.build().toUri();
|
||||
} else if (datasourceQuery.getTimeType().equals(INSTANT)) {
|
||||
uri = UriComponentsBuilder.fromHttpUrl(httpPromqlProperties.url() + QUERY_PATH)
|
||||
uri = UriComponentsBuilder.fromUriString(httpPromqlProperties.url() + QUERY_PATH)
|
||||
.queryParam(HTTP_QUERY_PARAM, datasourceQuery.getExpr())
|
||||
.build().toUri();
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("no such time type for query id {}.", datasourceQuery.getRefId()));
|
||||
throw new IllegalArgumentException(String.format("no such time type for query id %s.", datasourceQuery.getRefId()));
|
||||
}
|
||||
ResponseEntity<PromQlQueryContent> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, httpEntity,
|
||||
PromQlQueryContent.class);
|
||||
|
||||
+5
-5
@@ -306,7 +306,7 @@ public class VictoriaMetricsClusterDataStorage extends AbstractHistoryDataStorag
|
||||
Duration duration = Duration.ofHours(Long.parseLong(history.replace("h", "")));
|
||||
Instant start = end.minus(duration);
|
||||
String exportUrl = vmClusterProps.select().url() + VM_SELECT_BASE_PATH.formatted(vmClusterProps.accountID(), EXPORT_PATH);
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(exportUrl)
|
||||
URI uri = UriComponentsBuilder.fromUriString(exportUrl)
|
||||
.queryParam("match", URLEncoder.encode("{" + timeSeriesSelector + "}", StandardCharsets.UTF_8))
|
||||
.queryParam("start", String.valueOf(start.getEpochSecond()))
|
||||
.queryParam("end", String.valueOf(end.getEpochSecond()))
|
||||
@@ -404,7 +404,7 @@ public class VictoriaMetricsClusterDataStorage extends AbstractHistoryDataStorag
|
||||
}
|
||||
HttpEntity<Void> httpEntity = new HttpEntity<>(headers);
|
||||
String rangeUrl = VM_SELECT_BASE_PATH.formatted(vmClusterProps.accountID(), QUERY_RANGE_PATH);
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(rangeUrl)
|
||||
URI uri = UriComponentsBuilder.fromUriString(rangeUrl)
|
||||
.queryParam("query", URLEncoder.encode("{" + timeSeriesSelector + "}", StandardCharsets.UTF_8))
|
||||
.queryParam("step", "4h")
|
||||
.queryParam("start", startTime)
|
||||
@@ -444,7 +444,7 @@ public class VictoriaMetricsClusterDataStorage extends AbstractHistoryDataStorag
|
||||
log.error("query metrics data from victoria-metrics failed. {}", responseEntity);
|
||||
}
|
||||
// max
|
||||
uri = UriComponentsBuilder.fromHttpUrl(rangeUrl)
|
||||
uri = UriComponentsBuilder.fromUriString(rangeUrl)
|
||||
.queryParam("query", URLEncoder.encode("max_over_time({" + timeSeriesSelector + "})", StandardCharsets.UTF_8))
|
||||
.queryParam("step", "4h")
|
||||
.queryParam("start", startTime)
|
||||
@@ -482,7 +482,7 @@ public class VictoriaMetricsClusterDataStorage extends AbstractHistoryDataStorag
|
||||
}
|
||||
}
|
||||
// min
|
||||
uri = UriComponentsBuilder.fromHttpUrl(rangeUrl)
|
||||
uri = UriComponentsBuilder.fromUriString(rangeUrl)
|
||||
.queryParam("query", URLEncoder.encode("min_over_time({" + timeSeriesSelector + "})", StandardCharsets.UTF_8))
|
||||
.queryParam("step", "4h")
|
||||
.queryParam("start", startTime)
|
||||
@@ -520,7 +520,7 @@ public class VictoriaMetricsClusterDataStorage extends AbstractHistoryDataStorag
|
||||
}
|
||||
}
|
||||
// avg
|
||||
uri = UriComponentsBuilder.fromHttpUrl(rangeUrl)
|
||||
uri = UriComponentsBuilder.fromUriString(rangeUrl)
|
||||
.queryParam("query", URLEncoder.encode("avg_over_time({" + timeSeriesSelector + "})", StandardCharsets.UTF_8))
|
||||
.queryParam("step", "4h")
|
||||
.queryParam("start", startTime)
|
||||
|
||||
+5
-5
@@ -279,7 +279,7 @@ public class VictoriaMetricsDataStorage extends AbstractHistoryDataStorage {
|
||||
headers.add(HttpHeaders.AUTHORIZATION, NetworkConstants.BASIC + SignConstants.BLANK + encodedAuth);
|
||||
}
|
||||
HttpEntity<Void> httpEntity = new HttpEntity<>(headers);
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(victoriaMetricsProp.url() + EXPORT_PATH)
|
||||
URI uri = UriComponentsBuilder.fromUriString(victoriaMetricsProp.url() + EXPORT_PATH)
|
||||
.queryParam(URLEncoder.encode("match[]", StandardCharsets.UTF_8), URLEncoder.encode("{" + timeSeriesSelector + "}", StandardCharsets.UTF_8))
|
||||
.queryParam("start", URLEncoder.encode("now-" + history, StandardCharsets.UTF_8))
|
||||
.queryParam("end", "now")
|
||||
@@ -374,7 +374,7 @@ public class VictoriaMetricsDataStorage extends AbstractHistoryDataStorage {
|
||||
+ SignConstants.BLANK + encodedAuth);
|
||||
}
|
||||
HttpEntity<Void> httpEntity = new HttpEntity<>(headers);
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(victoriaMetricsProp.url() + QUERY_RANGE_PATH)
|
||||
URI uri = UriComponentsBuilder.fromUriString(victoriaMetricsProp.url() + QUERY_RANGE_PATH)
|
||||
.queryParam(URLEncoder.encode("query", StandardCharsets.UTF_8), URLEncoder.encode("{" + timeSeriesSelector + "}", StandardCharsets.UTF_8))
|
||||
.queryParam("step", "4h")
|
||||
.queryParam("start", startTime)
|
||||
@@ -410,7 +410,7 @@ public class VictoriaMetricsDataStorage extends AbstractHistoryDataStorage {
|
||||
log.error("query metrics data from victoria-metrics failed. {}", responseEntity);
|
||||
}
|
||||
// max
|
||||
uri = UriComponentsBuilder.fromHttpUrl(victoriaMetricsProp.url() + QUERY_RANGE_PATH)
|
||||
uri = UriComponentsBuilder.fromUriString(victoriaMetricsProp.url() + QUERY_RANGE_PATH)
|
||||
.queryParam(URLEncoder.encode("query", StandardCharsets.UTF_8), URLEncoder.encode("max_over_time({" + timeSeriesSelector + "})", StandardCharsets.UTF_8))
|
||||
.queryParam("step", "4h")
|
||||
.queryParam("start", startTime)
|
||||
@@ -445,7 +445,7 @@ public class VictoriaMetricsDataStorage extends AbstractHistoryDataStorage {
|
||||
}
|
||||
}
|
||||
// min
|
||||
uri = UriComponentsBuilder.fromHttpUrl(victoriaMetricsProp.url() + QUERY_RANGE_PATH)
|
||||
uri = UriComponentsBuilder.fromUriString(victoriaMetricsProp.url() + QUERY_RANGE_PATH)
|
||||
.queryParam(URLEncoder.encode("query", StandardCharsets.UTF_8), URLEncoder.encode("min_over_time({" + timeSeriesSelector + "})", StandardCharsets.UTF_8))
|
||||
.queryParam("step", "4h")
|
||||
.queryParam("start", startTime)
|
||||
@@ -480,7 +480,7 @@ public class VictoriaMetricsDataStorage extends AbstractHistoryDataStorage {
|
||||
}
|
||||
}
|
||||
// avg
|
||||
uri = UriComponentsBuilder.fromHttpUrl(victoriaMetricsProp.url() + QUERY_RANGE_PATH)
|
||||
uri = UriComponentsBuilder.fromUriString(victoriaMetricsProp.url() + QUERY_RANGE_PATH)
|
||||
.queryParam(URLEncoder.encode("query", StandardCharsets.UTF_8), URLEncoder.encode("avg_over_time({" + timeSeriesSelector + "})", StandardCharsets.UTF_8))
|
||||
.queryParam("step", "4h")
|
||||
.queryParam("start", startTime)
|
||||
|
||||
Reference in New Issue
Block a user