Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions api/prometheus/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,14 +696,8 @@ type TSDBHeadStats struct {
MaxTime int `json:"maxTime"`
}

// TSDBBlocksResult contains the results from querying the tsdb blocks endpoint.
type TSDBBlocksResult struct {
Status string `json:"status"`
Data TSDBBlocksData `json:"data"`
}

// TSDBBlocksData contains the metadata for the tsdb blocks.
type TSDBBlocksData struct {
type TSDBBlocksResult struct {
Blocks []TSDBBlocksBlockMetadata `json:"blocks"`
}

Expand All @@ -724,10 +718,18 @@ type TSDBBlocksStats struct {
NumChunks int `json:"numChunks"`
}

// TSDBBlocksCompactionParent contains details on parent blocks for a single tsdb block.
type TSDBBlocksCompactionParent struct {
Ulid string `json:"ulid"`
MinTime int64 `json:"minTime"`
MaxTime int64 `json:"maxTime"`
}

// TSDBBlocksCompaction contains block compaction details for a single block.
type TSDBBlocksCompaction struct {
Level int `json:"level"`
Sources []string `json:"sources"`
Level int `json:"level"`
Sources []string `json:"sources"`
Parents []TSDBBlocksCompactionParent `json:"parents,omitempty"`
}

// WalReplayStatus represents the wal replay status.
Expand Down
66 changes: 30 additions & 36 deletions api/prometheus/v1/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1206,48 +1206,42 @@ func TestAPIs(t *testing.T) {
reqMethod: "GET",
reqPath: "/api/v1/status/tsdb/blocks",
inRes: map[string]interface{}{
"status": "success",
"data": map[string]interface{}{
"blocks": []interface{}{
map[string]interface{}{
"ulid": "01JZ8JKZY6XSK3PTDP9ZKRWT60",
"minTime": 1750860620060,
"maxTime": 1750867200000,
"stats": map[string]interface{}{
"numSamples": 13701,
"numSeries": 716,
"numChunks": 716,
},
"compaction": map[string]interface{}{
"level": 1,
"sources": []interface{}{
"01JZ8JKZY6XSK3PTDP9ZKRWT60",
},
"blocks": []interface{}{
map[string]interface{}{
"ulid": "01JZ8JKZY6XSK3PTDP9ZKRWT60",
"minTime": 1750860620060,
"maxTime": 1750867200000,
"stats": map[string]interface{}{
"numSamples": 13701,
"numSeries": 716,
"numChunks": 716,
},
"compaction": map[string]interface{}{
"level": 1,
"sources": []interface{}{
"01JZ8JKZY6XSK3PTDP9ZKRWT60",
},
"version": 1,
},
"version": 1,
},
},
},
res: TSDBBlocksResult{
Status: "success",
Data: TSDBBlocksData{
Blocks: []TSDBBlocksBlockMetadata{{
Ulid: "01JZ8JKZY6XSK3PTDP9ZKRWT60",
MinTime: 1750860620060,
MaxTime: 1750867200000,
Version: 1,
Stats: TSDBBlocksStats{
NumSamples: 13701,
NumSeries: 716,
NumChunks: 716,
},
Compaction: TSDBBlocksCompaction{
Level: 1,
Sources: []string{"01JZ8JKZY6XSK3PTDP9ZKRWT60"},
},
}},
},
Blocks: []TSDBBlocksBlockMetadata{{
Ulid: "01JZ8JKZY6XSK3PTDP9ZKRWT60",
MinTime: 1750860620060,
MaxTime: 1750867200000,
Version: 1,
Stats: TSDBBlocksStats{
NumSamples: 13701,
NumSeries: 716,
NumChunks: 716,
},
Compaction: TSDBBlocksCompaction{
Level: 1,
Sources: []string{"01JZ8JKZY6XSK3PTDP9ZKRWT60"},
},
}},
},
},

Expand Down
Loading