{"record":{"id":"4f595f56f644d46b","repo":"jaegertracing/jaeger","slug":"date-histogram-aggregation-not-found-in-bucket-q","errorCode":null,"errorMessage":"date_histogram aggregation not found in bucket %q","messagePattern":"date_histogram aggregation not found in bucket %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/metricstore/elasticsearch/to_domain.go","lineNumber":99,"sourceCode":"\n\treturn metricsData, nil\n}\n\nfunc buildServiceLabels(serviceNames []string) []*metrics.Label {\n\tlabels := make([]*metrics.Label, len(serviceNames))\n\tfor i, name := range serviceNames {\n\t\tlabels[i] = &metrics.Label{Name: \"service_name\", Value: name}\n\t}\n\treturn labels\n}\n\nfunc (t *Translator) processOperationBucket(bucket esclient.AggregationBucket, baseLabels []*metrics.Label) (*metrics.Metric, error) {\n\tkey := bucket.Key\n\n\t// Extract nested date_histogram buckets\n\tdateHistAgg, found := bucket.DateHistogram(dateHistAggName)\n\tif !found {\n\t\treturn nil, fmt.Errorf(\"date_histogram aggregation not found in bucket %q\", key)\n\t}\n\n\t// Combine base labels with operation label\n\tlabels := append(baseLabels, toDomainLabels(key)...)\n\n\treturn &metrics.Metric{\n\t\tLabels:       labels,\n\t\tMetricPoints: toDomainMetricPoints(t.bucketsToPointsFunc(dateHistAgg.Buckets)),\n\t}, nil\n}\n\n// toDomainLabels converts the bucket key to Jaeger metric labels.\nfunc toDomainLabels(key string) []*metrics.Label {\n\treturn []*metrics.Label{\n\t\t{\n\t\t\tName:  \"operation\",\n\t\t\tValue: key,\n\t\t},","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/metricstore/elasticsearch/to_domain.go#L81-L117","documentation":"processOperationBucket extracts the nested date_histogram sub-aggregation (dateHistAggName) from each operation terms bucket. When the bucket does not contain that sub-aggregation, the per-operation metric cannot be assembled and this error is returned with the bucket's operation key for diagnosis.","triggerScenarios":"A terms bucket from a GroupByOperation query whose DateHistogram(dateHistAggName) lookup returns found=false — the sub-aggregation is absent from that bucket in the ES response.","commonSituations":"Buckets produced by an ES aggregation job configured without the histogram sub-agg; truncated/partial ES responses; querying different indices with differing mapping shapes.","solutions":["Re-enable or fix the ES metrics rollup so every operation bucket includes the date_histogram sub-aggregation.","Skip/exclude the offending operation or narrow the time range to complete data.","Confirm dateHistAggName matches the sub-aggregation name used by the query builder."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if _, found := bucket.DateHistogram(dateHistAggName); !found {\n  return nil, nil // caller skips this operation\n}","typeGuard":"func bucketHasDateHistogram(b esclient.AggregationBucket) bool {\n  _, found := b.DateHistogram(dateHistAggName)\n  return found\n}","tryCatchPattern":"m, err := t.processOperationBucket(bucket, labels)\nif err != nil {\n  log.Printf(\"op %q has no histogram data: %v\", bucket.Key, err)\n  continue\n}","preventionTips":["Verify the rollup job writes the date_histogram sub-agg for every operation bucket.","Pin query-builder and translator to the same dateHistAggName constant.","Test translator against recorded ES responses from the target cluster version."],"tags":["elasticsearch","metrics","aggregation","date-histogram"],"backgroundTag":"aggregation-not-found","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}