SigNoz/signoz · error

group by requires aggregate operator other than noop or rate

Error message

group by requires aggregate operator other than noop or rate

What it means

On metrics queries with group by and no space aggregation specified (legacy v3 payload), the aggregate operator cannot be noop or rate because grouping requires a real aggregate function.

Source

Thrown at pkg/query-service/model/v3/v3.go:1086

		// if len(b.GroupBy) > 0 && panelType == PanelTypeList {
		// 	return fmt.Errorf("group by is not supported for list panel type")
		// }

		if panelType == PanelTypeValue && len(b.GroupBy) > 0 {
			if err := b.SecondaryAggregation.Validate(); err != nil {
				return fmt.Errorf("series aggregation is required for value type panel with group by: %w", err)
			}
		}

		for _, groupBy := range b.GroupBy {
			if err := groupBy.Validate(); err != nil {
				return fmt.Errorf("group by is invalid %w", err)
			}
		}

		if b.DataSource == DataSourceMetrics && len(b.GroupBy) > 0 && b.SpaceAggregation == SpaceAggregationUnspecified {
			if b.AggregateOperator == AggregateOperatorNoOp || b.AggregateOperator == AggregateOperatorRate {
				return fmt.Errorf("group by requires aggregate operator other than noop or rate")
			}
		}
	}

	if b.Having != nil {
		for _, having := range b.Having {
			if err := having.Operator.Validate(); err != nil {
				return fmt.Errorf("having operator is invalid: %w", err)
			}
		}
	}

	for _, selectColumn := range b.SelectColumns {
		if err := selectColumn.Validate(); err != nil {
			return fmt.Errorf("select column is invalid %w", err)
		}
	}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Set spaceAggregation (and timeAggregation) to use the newer v3 metrics payload
  2. Or change aggregateOperator to sum/avg/min/max etc. when grouping

Example fix

// before
{"dataSource":"metrics","aggregateOperator":"rate","groupBy":[{"key":"service_name"}]}
// after
{"dataSource":"metrics","timeAggregation":"rate","spaceAggregation":"sum","groupBy":[{"key":"service_name"}]}
Defensive patterns

Strategy: validation

Validate before calling

if q.DataSource == v3.DataSourceMetrics && len(q.GroupBy) > 0 && q.SpaceAggregation == v3.SpaceAggregationUnspecified {
	if q.AggregateOperator == v3.AggregateOperatorNoOp || q.AggregateOperator == v3.AggregateOperatorRate {
		return errors.New("group by needs a real aggregate operator")
	}
}

Type guard

func metricsGroupBySafe(q v3.BuilderQuery) bool { return !(len(q.GroupBy) > 0 && q.SpaceAggregation == v3.SpaceAggregationUnspecified && (q.AggregateOperator == v3.AggregateOperatorNoOp || q.AggregateOperator == v3.AggregateOperatorRate)) }

Prevention

When it happens

Trigger: dataSource=metrics, groupBy non-empty, spaceAggregation unspecified, aggregateOperator=noop or rate.

Common situations: Legacy v3 payloads that rely on aggregateOperator; migration to spaceAggregation-based payloads fixes it.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/43dd026f7475f298. Report an issue: GitHub.