{"record":{"id":"13b819685c66f462","repo":"thanos-io/thanos","slug":"aggregate-s-does-not-exist","errorCode":null,"errorMessage":"aggregate %s does not exist","messagePattern":"aggregate (.+?) does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/bucket.go","lineNumber":1438,"sourceCode":"\t\t\tData: b,\n\t\t\tType: chunkToStoreEncoding(in.Encoding()),\n\t\t\tHash: hashChunk(hasher, b, calculateChecksum),\n\t\t}\n\t\treturn nil\n\t}\n\n\tif in.Encoding() != downsample.ChunkEncAggr {\n\t\treturn errors.Errorf(\"unsupported chunk encoding %d\", in.Encoding())\n\t}\n\n\tac := downsample.AggrChunk(in.Bytes())\n\n\tfor _, at := range aggrs {\n\t\tswitch at {\n\t\tcase storepb.Aggr_COUNT:\n\t\t\tx, err := ac.Get(downsample.AggrCount)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"aggregate %s does not exist\", downsample.AggrCount)\n\t\t\t}\n\t\t\tb, err := save(x.Bytes())\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tout.Count = &storepb.Chunk{Type: chunkToStoreEncoding(x.Encoding()), Data: b, Hash: hashChunk(hasher, b, calculateChecksum)}\n\t\tcase storepb.Aggr_SUM:\n\t\t\tx, err := ac.Get(downsample.AggrSum)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"aggregate %s does not exist\", downsample.AggrSum)\n\t\t\t}\n\t\t\tb, err := save(x.Bytes())\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tout.Sum = &storepb.Chunk{Type: chunkToStoreEncoding(x.Encoding()), Data: b, Hash: hashChunk(hasher, b, calculateChecksum)}\n\t\tcase storepb.Aggr_MIN:\n\t\t\tx, err := ac.Get(downsample.AggrMin)","sourceCodeStart":1420,"sourceCodeEnd":1456,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/bucket.go#L1420-L1456","documentation":"When serving a downsampled series, the store unpacks an AggrChunk and fetches each requested aggregate sub-chunk. This error means the AggrChunk container does not carry the COUNT aggregate the caller asked for, so the aggregate cannot be returned. AggrChunk sub-chunks are optional; older or partially written downsampled data may omit some.","triggerScenarios":"A Series request with Aggr_COUNT in the requested aggregates, where ac.Get(downsample.AggrCount) returns an error because the AggrChunk's count sub-slot is empty (unset sample count / empty encoding).","commonSituations":"Downsampled blocks produced by older Thanos versions before all aggregates were stored; queries for COUNT against data where only some aggregates were computed; aggregation bitmask in the store API requesting aggregates the block lacks.","solutions":["Verify the downsampled blocks in the bucket actually contain count chunks (thanos tools bucket inspect).","Regenerate downsampled blocks with the compactor so all requested aggregates exist.","Remove COUNT from the requested aggregates (storepb.Aggr_COUNT) for this store view / query path.","Check the store API client's requested_aggs against what the block resolution provides."],"exampleFix":"// client side: request only aggregates the data provides\naggs := []storepb.Aggr{storepb.Aggr_SUM, storepb.Aggr_MIN, storepb.Aggr_MAX}\n// instead of unconditionally including storepb.Aggr_COUNT","handlingStrategy":"fallback","validationCode":"// client-side: request only aggregates known to exist for the block resolution\naggrs := availableAggregatesForResolution(blockMeta.Resolution) // exclude COUNT if unavailable","typeGuard":null,"tryCatchPattern":"resp, err := client.Series(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"aggregate count does not exist\") {\n    req.Aggregates = removeAggr(req.Aggregates, storepb.Aggr_COUNT)\n    resp, err = client.Series(ctx, req)\n}","preventionTips":["Regenerate downsampled blocks after upgrading Thanos so all aggregates exist.","Inspect bucket blocks for missing aggregate slots before querying.","Keep requested aggregates within what the compactor writes."],"tags":["thanos","downsampling","missing-data","grpc"],"backgroundTag":"resource-not-found","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}