fix(cloudmon): optimize service metric collect (#21847)

This commit is contained in:
屈轩
2024-12-19 18:48:31 +08:00
committed by GitHub
parent 74f4acedb7
commit 5c46e663a3
+7 -3
View File
@@ -17,7 +17,7 @@ package misc
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"time"
@@ -74,7 +74,11 @@ func CollectServiceMetrics(ctx context.Context, userCred mcclient.TokenCredentia
}
metrics := []influxdb.SMetricData{}
for _, ep := range endpoints {
if utils.IsInStringArray(ep.ServiceType, apis.NO_RESOURCE_SERVICES) || ep.ServiceType == apis.SERVICE_TYPE_IMAGE {
if utils.IsInStringArray(ep.ServiceType, apis.NO_RESOURCE_SERVICES) || utils.IsInStringArray(ep.ServiceType, []string{
apis.SERVICE_TYPE_IMAGE,
apis.SERVICE_TYPE_MONITOR,
apis.SERVICE_TYPE_VICTORIA_METRICS,
}) {
continue
}
url := httputils.JoinPath(ep.Url, "version")
@@ -90,7 +94,7 @@ func CollectServiceMetrics(ctx context.Context, userCred mcclient.TokenCredentia
continue
}
defer resp.Body.Close()
version, _ := ioutil.ReadAll(resp.Body)
version, _ := io.ReadAll(resp.Body)
if len(version) == 0 {
continue
}