初始化promeclient
Former-commit-id: 65192221776602c864603b6dbf9de9cbbd9de853
This commit is contained in:
parent
9acf1a1151
commit
2321650bb1
|
@ -24,4 +24,9 @@ func AddCronGroup(svc *svc.ServiceContext) {
|
||||||
ClearMetricsData(svc)
|
ClearMetricsData(svc)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 同步任务信息到core端
|
||||||
|
svc.Cron.AddFunc("*/5 * * * * ?", func() {
|
||||||
|
SyncParticipantRpc(svc)
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) [2023] [pcm]
|
||||||
|
[pcm-coordinator] is licensed under Mulan PSL v2.
|
||||||
|
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||||
|
You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
http://license.coscl.org.cn/MulanPSL2
|
||||||
|
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||||
|
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||||
|
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||||
|
See the Mulan PSL v2 for more details.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
package cron
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/constants"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
|
||||||
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/tracker"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SyncParticipantRpc(svc *svc.ServiceContext) {
|
||||||
|
// 查询出所有p端信息
|
||||||
|
var participants []*models.ScParticipantPhyInfo
|
||||||
|
svc.DbEngin.Where("type in (?)", []string{constants.CLOUD, constants.SEALOS}).Find(&participants)
|
||||||
|
if len(participants) != 0 {
|
||||||
|
for _, participant := range participants {
|
||||||
|
if len(participant.MetricsUrl) != 0 {
|
||||||
|
// 初始化p端prometheus client
|
||||||
|
promClient, err := tracker.NewPrometheus(participant.MetricsUrl)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
svc.PromClient[participant.Id] = promClient
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue