thanos-io/thanos · error
aggregate does not exist
Error message
aggregate %s does not exist
What it means
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.
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.
Example fix
// client side: request only aggregates the data provides
aggs := []storepb.Aggr{storepb.Aggr_SUM, storepb.Aggr_MIN, storepb.Aggr_MAX}
// instead of unconditionally including storepb.Aggr_COUNT Defensive patterns
Strategy: fallback
Validate before calling
// client-side: request only aggregates known to exist for the block resolution aggrs := availableAggregatesForResolution(blockMeta.Resolution) // exclude COUNT if unavailable
Try / catch
resp, err := client.Series(ctx, req)
if err != nil && strings.Contains(err.Error(), "aggregate count does not exist") {
req.Aggregates = removeAggr(req.Aggregates, storepb.Aggr_COUNT)
resp, err = client.Series(ctx, req)
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- raw resolution must be higher than the minimum block size…
- 5m resolution retention must be higher than the minimum…
- sync before first pass of downsampling
- first pass of downsampling failed
- sync before second pass of downsampling
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/13b819685c66f462.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/store/bucket.go:1438
Data: b,
Type: chunkToStoreEncoding(in.Encoding()),
Hash: hashChunk(hasher, b, calculateChecksum),
}
return nil
}
if in.Encoding() != downsample.ChunkEncAggr {
return errors.Errorf("unsupported chunk encoding %d", in.Encoding())
}
ac := downsample.AggrChunk(in.Bytes())
for _, at := range aggrs {
switch at {
case storepb.Aggr_COUNT:
x, err := ac.Get(downsample.AggrCount)
if err != nil {
return errors.Errorf("aggregate %s does not exist", downsample.AggrCount)
}
b, err := save(x.Bytes())
if err != nil {
return err
}
out.Count = &storepb.Chunk{Type: chunkToStoreEncoding(x.Encoding()), Data: b, Hash: hashChunk(hasher, b, calculateChecksum)}
case storepb.Aggr_SUM:
x, err := ac.Get(downsample.AggrSum)
if err != nil {
return errors.Errorf("aggregate %s does not exist", downsample.AggrSum)
}
b, err := save(x.Bytes())
if err != nil {
return err
}
out.Sum = &storepb.Chunk{Type: chunkToStoreEncoding(x.Encoding()), Data: b, Hash: hashChunk(hasher, b, calculateChecksum)}
case storepb.Aggr_MIN:
x, err := ac.Get(downsample.AggrMin)View on GitHub (pinned to 35b8b99117)