apache/skywalking · error · IllegalExpressionException
Unsupported aggregateLabels function.
Error message
Unsupported aggregateLabels function.
What it means
IllegalExpressionException from AggregateLabelsOp when the aggregateLabels(...) function receives a funcType token other than AVG, SUM, MAX or MIN. The grammar may lex the function name, but the runtime dispatch switch only implements those four aggregations, so any other token reaching dispatch is rejected as unsupported.
Source
Thrown at oap-server/mqe-rt/src/main/java/org/apache/skywalking/mqe/rt/operation/AggregateLabelsOp.java:55
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;
public class AggregateLabelsOp {
public static ExpressionResult doAggregateLabelsOp(ExpressionResult result,
int funcType,
List<String> labelNames) throws IllegalExpressionException {
switch (funcType) {
case MQEParser.AVG:
return aggregateLabeledValueResult(result, labelNames, AvgAggregateLabelsFunc::new);
case MQEParser.SUM:
return aggregateLabeledValueResult(result, labelNames, SumAggregateLabelsFunc::new);
case MQEParser.MAX:
return aggregateLabeledValueResult(result, labelNames, MaxAggregateLabelsFunc::new);
case MQEParser.MIN:
return aggregateLabeledValueResult(result, labelNames, MinAggregateLabelsFunc::new);
default:
throw new IllegalExpressionException("Unsupported aggregateLabels function.");
}
}
private static ExpressionResult aggregateLabeledValueResult(ExpressionResult expResult,
List<String> labelNames,
AggregateLabelsFuncFactory factory) {
List<MQEValues> results = expResult.getResults();
if (CollectionUtils.isEmpty(results)) {
return expResult;
}
LinkedHashMap<List<KeyValue>, List<MQEValues>> groupedResult = results.stream().collect(groupingBy(mqeValues -> getLabels(labelNames, mqeValues),
LinkedHashMap::new,
toList()));
if (groupedResult.size() == 1 && groupedResult.keySet().iterator().next().isEmpty()) {
expResult.setLabeledResult(false);
}
expResult.getResults().clear();View on GitHub (pinned to 102af09b4a)
Solutions
- Replace the function with one of AVG, SUM, MAX, MIN
- If you need a count, restructure the query (count is not supported across labels; consider a different metric or relabel/k8s labels at ingest)
- Check the MQE doc for your OAP version to confirm supported aggregateLabels functions
- Upgrade OAP if a newer release added the function you need
Example fix
# before aggregate_labels(service_percentile.p99(dt5m), COUNT) # after aggregate_labels(service_percentile.p99(dt5m), AVG)
Defensive patterns
Strategy: validation
Validate before calling
private static final Set<String> SUPPORTED = Set.of("AVG", "SUM", "MAX", "MIN");
void assertAggregateLabelsFunc(String func) {
if (!SUPPORTED.contains(func.toUpperCase())) throw new IllegalArgumentException("Unsupported aggregateLabels function: " + func);
} Type guard
boolean isSupportedAggregateLabelsFunc(String f) {
return f != null && java.util.Set.of("AVG","SUM","MAX","MIN").contains(f.toUpperCase(Locale.ROOT));
} Prevention
- Restrict aggregateLabels functions to AVG/SUM/MAX/MIN
- Check the MQE doc for the deployed OAP version
- Don't assume PromQL aggregation semantics in MQE
When it happens
Trigger: Writing aggregate_labels(metric, <FUNC>) with a FUNC the runtime does not implement (e.g. COUNT, MEDIAN, P99 or a typo). Whether it fails at parse (unknown function) or here (known token, unimplemented) depends on the grammar version, but the outcome is the same rejection.
Common situations: PromQL-trained users expecting by(cluster) style aggregation with arbitrary functions; requesting COUNT of labeled values which MQE deliberately omits; UI autocompleting a function the deployed OAP version doesn't support yet.
Related errors
- Unsupported aggregation operation.
- LATEST can only be used in time series result.
- Unsupported binary operation: {}
- Unsupported bool operation: {}
- Unsupported compare operation: {}
AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14).
Data as JSON: /api/errors/6645fddfb6d38f20.
Report an issue: GitHub.