Skip to content

Commit

Permalink
fix(node): update PromQL query for node core and memory totals
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimbus318 committed Oct 25, 2024
1 parent 72a2f9d commit fbbe003
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/internal/service/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ func (s *NodeService) buildNodeReply(ctx context.Context, node *biz.Node) (*pb.N
func (s *NodeService) queryNodeMetrics(ctx context.Context, nodeName string) (int32, int32, error) {
coreTotal, memoryTotal := int32(0), int32(0)

resp, err := s.ms.QueryInstant(ctx, &pb.QueryInstantRequest{Query: fmt.Sprintf("avg(hami_core_size{node=~\"%s\"})", nodeName)})
resp, err := s.ms.QueryInstant(ctx, &pb.QueryInstantRequest{Query: fmt.Sprintf("avg(sum(hami_core_size{node=~\"%s\"}) by (instance))", nodeName)})
if err == nil && len(resp.Data) > 0 {
coreTotal = int32(resp.Data[0].Value)
}

resp, err = s.ms.QueryInstant(ctx, &pb.QueryInstantRequest{Query: fmt.Sprintf("avg(hami_memory_size{node=~\"%s\"})", nodeName)})
resp, err = s.ms.QueryInstant(ctx, &pb.QueryInstantRequest{Query: fmt.Sprintf("avg(sum(hami_memory_size{node=~\"%s\"}) by (instance))", nodeName)})
if err == nil && len(resp.Data) > 0 {
memoryTotal = int32(resp.Data[0].Value)
}
Expand Down

0 comments on commit fbbe003

Please sign in to comment.