(ctx context.Context, clusterIds ...string)
| 968 | } |
| 969 | |
| 970 | func (i *imlMonitorStatisticModule) genCommonWheres(ctx context.Context, clusterIds ...string) ([]monitor.MonWhereItem, error) { |
| 971 | |
| 972 | clusters, err := i.clusterService.List(ctx, clusterIds...) |
| 973 | if err != nil { |
| 974 | return nil, err |
| 975 | } |
| 976 | clusterIds = utils.SliceToSlice(clusters, func(item *cluster.Cluster) string { |
| 977 | return item.Uuid |
| 978 | }) |
| 979 | |
| 980 | wheres := make([]monitor.MonWhereItem, 0, 1) |
| 981 | nodes, err := i.clusterService.Nodes(ctx, clusterIds...) |
| 982 | if err != nil { |
| 983 | return nil, err |
| 984 | } |
| 985 | nodeIds := utils.SliceToSlice(nodes, func(s *cluster.Node) string { |
| 986 | return s.Name |
| 987 | }) |
| 988 | wheres = append(wheres, monitor.MonWhereItem{ |
| 989 | Key: "node", |
| 990 | Operation: "in", |
| 991 | Values: nodeIds, |
| 992 | }) |
| 993 | |
| 994 | return wheres, nil |
| 995 | } |
| 996 | |
| 997 | func (i *imlMonitorStatisticModule) statistics(ctx context.Context, clusterId string, groupBy string, start, end time.Time, wheres []monitor.MonWhereItem, limit int) (map[string]monitor.MonCommonData, error) { |
| 998 | statisticMap, _ := i.monitorStatisticCacheService.GetStatisticsCache(ctx, clusterId, start, end, groupBy, wheres, limit) |
no test coverage detected