jaegertracing/jaeger · error

%s aggregation not found

Error message

%s aggregation not found

What it means

When GroupByOperation is enabled, toDomainMetrics expects a terms aggregation keyed by aggName in the SearchResponse. If result.Aggregations.Terms(aggName) reports not-found — the aggregation is absent because the response has no such terms aggregation — the translator cannot build per-operation metrics and returns this error naming the expected aggregation.

Source

Thrown at internal/storage/metricstore/elasticsearch/to_domain.go:70

	labels := buildServiceLabels(m.ServiceNames)

	if !m.GroupByOperation {
		buckets, err := extractBuckets(result)
		if err != nil {
			return nil, err
		}
		return []*metrics.Metric{
			{
				Labels:       labels,
				MetricPoints: toDomainMetricPoints(t.bucketsToPointsFunc(buckets)),
			},
		}, nil
	}

	// Handle grouped results when groupByOp is true
	agg, found := result.Aggregations.Terms(aggName)
	if !found {
		return nil, fmt.Errorf("%s aggregation not found", aggName)
	}

	var metricsData []*metrics.Metric
	for _, bucket := range agg.Buckets {
		metric, err := t.processOperationBucket(bucket, labels)
		if err != nil {
			return nil, fmt.Errorf("failed to process bucket: %w", err)
		}
		metricsData = append(metricsData, metric)
	}

	return metricsData, nil
}

func buildServiceLabels(serviceNames []string) []*metrics.Label {
	labels := make([]*metrics.Label, len(serviceNames))
	for i, name := range serviceNames {
		labels[i] = &metrics.Label{Name: "service_name", Value: name}

View on GitHub (pinned to 806f444784)

Solutions

  1. Verify the query time range actually contains span data for the requested service.
  2. Ensure the queryBuilder builds the terms aggregation (operation grouping) whenever GroupByOperation is true.
  3. Check that aggName constant matches the name the query builder registers.
Defensive patterns

Strategy: type-guard

Validate before calling

if _, found := result.Aggregations.Terms(aggName); !found {
  return metrics.EmptyFamily(params) // no data in range
}

Type guard

func hasTermsAgg(resp *esclient.SearchResponse, name string) bool {
  _, found := resp.Aggregations.Terms(name)
  return found
}

Try / catch

fam, err := translator.ToDomainMetricsFamily(params, result)
if err != nil && strings.HasSuffix(err.Error(), "aggregation not found") {
  return &metrics.MetricFamily{}, nil // empty result, not an error
}

Prevention

When it happens

Trigger: ToDomainMetricsFamily with GroupByOperation=true on a response whose aggregations lack the operation terms aggregation (empty result set, wrong index, or query built without the terms agg).

Common situations: Querying a time range with no spans so ES returns an empty/absent aggregation; ES version differences that omit empty aggregations; mismatch between the query builder's aggregation name and the translator's expected aggName constant.

Related errors


AI-assisted analysis of jaegertracing/jaeger@806f444784 (2026-09-01). Data as JSON: /api/errors/ae17a8dfe00656cd. Report an issue: GitHub.