Skip to content

Commit 734cf0b

Browse files
authored
Add index stats info to bucket index (cortexproject#5506)
* add index stats info to bucket index Signed-off-by: Ben Ye <[email protected]> * update changelog Signed-off-by: Ben Ye <[email protected]> --------- Signed-off-by: Ben Ye <[email protected]>
1 parent 4ee4773 commit 734cf0b

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* [CHANGE] Store Gateway: Rename `cortex_bucket_store_cached_series_fetch_duration_seconds` to `cortex_bucket_store_series_fetch_duration_seconds` and `cortex_bucket_store_cached_postings_fetch_duration_seconds` to `cortex_bucket_store_postings_fetch_duration_seconds`. Add new metric `cortex_bucket_store_chunks_fetch_duration_seconds`. #5448
1818
* [CHANGE] Store Gateway: Remove `idle_timeout`, `max_conn_age`, `pool_size`, `min_idle_conns` fields for Redis index cache and caching bucket. #5448
1919
* [CHANGE] Store Gateway: Add flag `-store-gateway.sharding-ring.zone-stable-shuffle-sharding` to enable store gateway to use zone stable shuffle sharding. #5489
20+
* [CHANGE] Bucket Index: Add `series_max_size` and `chunk_max_size` to bucket index. #5489
2021
* [FEATURE] Store Gateway: Add `max_downloaded_bytes_per_request` to limit max bytes to download per store gateway request.
2122
* [FEATURE] Added 2 flags `-alertmanager.alertmanager-client.grpc-max-send-msg-size` and ` -alertmanager.alertmanager-client.grpc-max-recv-msg-size` to configure alert manager grpc client message size limits. #5338
2223
* [FEATURE] Query Frontend: Add `cortex_rejected_queries_total` metric for throttled queries. #5356

pkg/storage/tsdb/bucketindex/index.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ type Block struct {
8080
SegmentsFormat string `json:"segments_format,omitempty"`
8181
SegmentsNum int `json:"segments_num,omitempty"`
8282

83+
// Max size in bytes of series and chunk in the block.
84+
SeriesMaxSize int64 `json:"series_max_size,omitempty"`
85+
ChunkMaxSize int64 `json:"chunk_max_size,omitempty"`
86+
8387
// UploadedAt is a unix timestamp (seconds precision) of when the block has been completed to be uploaded
8488
// to the storage.
8589
UploadedAt int64 `json:"uploaded_at"`
@@ -113,6 +117,10 @@ func (m *Block) ThanosMeta(userID string) *metadata.Meta {
113117
cortex_tsdb.TenantIDExternalLabel: userID,
114118
},
115119
SegmentFiles: m.thanosMetaSegmentFiles(),
120+
IndexStats: metadata.IndexStats{
121+
SeriesMaxSize: m.SeriesMaxSize,
122+
ChunkMaxSize: m.ChunkMaxSize,
123+
},
116124
},
117125
}
118126
}
@@ -143,6 +151,8 @@ func BlockFromThanosMeta(meta metadata.Meta) *Block {
143151
MaxTime: meta.MaxTime,
144152
SegmentsFormat: segmentsFormat,
145153
SegmentsNum: segmentsNum,
154+
SeriesMaxSize: meta.Thanos.IndexStats.SeriesMaxSize,
155+
ChunkMaxSize: meta.Thanos.IndexStats.ChunkMaxSize,
146156
}
147157
}
148158

pkg/storage/tsdb/bucketindex/index_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,37 @@ func TestBlockFromThanosMeta(t *testing.T) {
201201
SegmentsNum: 3,
202202
},
203203
},
204+
"meta.json with Files and Index Stats": {
205+
meta: metadata.Meta{
206+
BlockMeta: tsdb.BlockMeta{
207+
ULID: blockID,
208+
MinTime: 10,
209+
MaxTime: 20,
210+
},
211+
Thanos: metadata.Thanos{
212+
Files: []metadata.File{
213+
{RelPath: "index"},
214+
{RelPath: "chunks/000001"},
215+
{RelPath: "chunks/000002"},
216+
{RelPath: "chunks/000003"},
217+
{RelPath: "tombstone"},
218+
},
219+
IndexStats: metadata.IndexStats{
220+
SeriesMaxSize: 1000,
221+
ChunkMaxSize: 1000,
222+
},
223+
},
224+
},
225+
expected: Block{
226+
ID: blockID,
227+
MinTime: 10,
228+
MaxTime: 20,
229+
SegmentsFormat: SegmentsFormat1Based6Digits,
230+
SegmentsNum: 3,
231+
SeriesMaxSize: 1000,
232+
ChunkMaxSize: 1000,
233+
},
234+
},
204235
}
205236

206237
for testName, testData := range tests {
@@ -314,6 +345,35 @@ func TestBlock_ThanosMeta(t *testing.T) {
314345
},
315346
},
316347
},
348+
"block with index stats": {
349+
block: Block{
350+
ID: blockID,
351+
MinTime: 10,
352+
MaxTime: 20,
353+
SegmentsFormat: SegmentsFormatUnknown,
354+
SegmentsNum: 0,
355+
SeriesMaxSize: 1000,
356+
ChunkMaxSize: 500,
357+
},
358+
expected: &metadata.Meta{
359+
BlockMeta: tsdb.BlockMeta{
360+
ULID: blockID,
361+
MinTime: 10,
362+
MaxTime: 20,
363+
Version: metadata.TSDBVersion1,
364+
},
365+
Thanos: metadata.Thanos{
366+
Version: metadata.ThanosVersion1,
367+
Labels: map[string]string{
368+
"__org_id__": userID,
369+
},
370+
IndexStats: metadata.IndexStats{
371+
SeriesMaxSize: 1000,
372+
ChunkMaxSize: 500,
373+
},
374+
},
375+
},
376+
},
317377
}
318378

319379
for testName, testData := range tests {

0 commit comments

Comments
 (0)