监控接口添加集群id

This commit is contained in:
zhangwei 2025-06-06 13:20:38 +08:00
parent 583e07bc08
commit df82e4b59d
1 changed files with 2 additions and 0 deletions

View File

@ -19,6 +19,7 @@ type ClustersLoadLogic struct {
}
type ClusterInfo struct {
ClusterId int64 `json:"clusterId"`
ClusterName string `json:"clusterName"`
Metrics []tracker.Metric `json:"metrics"`
}
@ -41,6 +42,7 @@ func (l *ClustersLoadLogic) ClustersLoad(req *types.ClustersLoadReq) (resp *type
metrics := []string{"cluster_cpu_utilisation", "cluster_cpu_avail", "cluster_cpu_total", "cluster_memory_total", "cluster_memory_avail", "cluster_memory_utilisation", "cluster_disk_utilisation", "cluster_disk_avail", "cluster_disk_total", "cluster_pod_utilisation", "cluster_node_count"}
data := l.svcCtx.PromClient.GetNamedMetrics(metrics, time.Now(), tracker.ClusterOption{ClusterName: cluster.Name.String})
clusterInfo := ClusterInfo{
ClusterId: cluster.Id,
ClusterName: cluster.Name.String,
Metrics: data,
}