diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.go index c537cac8ef..2bf15b90cd 100644 --- a/pkg/query-service/app/clickhouseReader/reader.go +++ b/pkg/query-service/app/clickhouseReader/reader.go @@ -4161,7 +4161,7 @@ func readRowsForTimeSeriesResult(rows driver.Rows, vars []interface{}, columnNam // ("order", "/fetch/{Id}") // ("order", "/order") seriesToPoints := make(map[string][]v3.Point) - + var keys []string // seriesToAttrs is a mapping of key to a map of attribute key to attribute value // for each series. This is used to populate the series' attributes // For instance, for the above example, the seriesToAttrs will be @@ -4182,12 +4182,15 @@ func readRowsForTimeSeriesResult(rows driver.Rows, vars []interface{}, columnNam groupBy, groupAttributes, metricPoint := readRow(vars, columnNames) sort.Strings(groupBy) key := strings.Join(groupBy, "") + if _, exists := seriesToAttrs[key]; !exists { + keys = append(keys, key) + } seriesToAttrs[key] = groupAttributes seriesToPoints[key] = append(seriesToPoints[key], metricPoint) } var seriesList []*v3.Series - for key := range seriesToPoints { + for _, key := range keys { points := seriesToPoints[key] // find the grouping sets point for the series