This commit is contained in:
zhangwei 2024-05-16 15:45:30 +08:00
parent aa559a966b
commit 318eb76d0c
1 changed files with 6 additions and 9 deletions

View File

@ -42,19 +42,16 @@ func syncClusterAlertRecords() {
for k, v := range apiserver.ApiServer.MonitoringClientMap {
wg.Add(1)
go func(key string, client monitoring.Interface) {
defer wg.Done()
rules, err := client.GetExceptionRules()
if err != nil {
logx.Error(err)
return
}
res[k] = rules
res[key] = rules
}(k, v)
}
wg.Wait()
// push data
req := SyncClusterAlertReq{
AlertRecordsMap: res,
@ -82,17 +79,17 @@ func syncClusterLoadRecords() {
for clusterName, client := range apiserver.ApiServer.MonitoringClientMap {
wg.Add(1)
go func(clusterName string, client monitoring.Interface) {
go func(name string, client monitoring.Interface) {
defer wg.Done()
// prometheus data
clusterResourceLoad, err := fetchClusterResourceLoad(clusterName, client)
clusterResourceLoad, err := fetchClusterResourceLoad(name, client)
if err != nil {
logx.Error(err)
return
}
// pod utilisation
if _, ok := apiserver.ApiServer.ClientSetMap[clusterName]; ok {
podUtilisation, count, total, err := v1.PodUtilisation(apiserver.ApiServer.ClientSetMap[clusterName])
if _, ok := apiserver.ApiServer.ClientSetMap[name]; ok {
podUtilisation, count, total, err := v1.PodUtilisation(apiserver.ApiServer.ClientSetMap[name])
if err != nil {
logx.Error(err)
}