Skip to content

Commit dc1559e

Browse files
authored
Update /api/v1/status/tsdb to include headStats (#925)
Current structs for v1 HTTP API assume that there is chunkCount and timeSeriesCount on /api/v1/status/runtimeinfo, which seems to be gone for at least a few releases. /api/v1/status/tsdb now holds an extra headStats block with chunkCount, numSeries and a few other fields. Update API models and tests to reflect this change. Signed-off-by: Łukasz Mierzwa <[email protected]>
1 parent e6e54e8 commit dc1559e

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

api/prometheus/v1/api.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,6 @@ type RuntimeinfoResult struct {
306306
CWD string `json:"CWD"`
307307
ReloadConfigSuccess bool `json:"reloadConfigSuccess"`
308308
LastConfigTime time.Time `json:"lastConfigTime"`
309-
ChunkCount int `json:"chunkCount"`
310-
TimeSeriesCount int `json:"timeSeriesCount"`
311309
CorruptionCount int `json:"corruptionCount"`
312310
GoroutineCount int `json:"goroutineCount"`
313311
GOMAXPROCS int `json:"GOMAXPROCS"`
@@ -434,10 +432,20 @@ type queryResult struct {
434432

435433
// TSDBResult contains the result from querying the tsdb endpoint.
436434
type TSDBResult struct {
437-
SeriesCountByMetricName []Stat `json:"seriesCountByMetricName"`
438-
LabelValueCountByLabelName []Stat `json:"labelValueCountByLabelName"`
439-
MemoryInBytesByLabelName []Stat `json:"memoryInBytesByLabelName"`
440-
SeriesCountByLabelValuePair []Stat `json:"seriesCountByLabelValuePair"`
435+
HeadStats TSDBHeadStats `json:"headStats"`
436+
SeriesCountByMetricName []Stat `json:"seriesCountByMetricName"`
437+
LabelValueCountByLabelName []Stat `json:"labelValueCountByLabelName"`
438+
MemoryInBytesByLabelName []Stat `json:"memoryInBytesByLabelName"`
439+
SeriesCountByLabelValuePair []Stat `json:"seriesCountByLabelValuePair"`
440+
}
441+
442+
// TSDBHeadStats contains TSDB stats
443+
type TSDBHeadStats struct {
444+
NumSeries int `json:"numSeries"`
445+
NumLabelPairs int `json:"numLabelPairs"`
446+
ChunkCount int `json:"chunkCount"`
447+
MinTime int `json:"minTime"`
448+
MaxTime int `json:"maxTime"`
441449
}
442450

443451
// WalReplayStatus represents the wal replay status.

api/prometheus/v1/api_test.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,6 @@ func TestAPIs(t *testing.T) {
703703
"CWD": "/prometheus",
704704
"reloadConfigSuccess": true,
705705
"lastConfigTime": "2020-05-18T15:52:56Z",
706-
"chunkCount": 72692,
707-
"timeSeriesCount": 18476,
708706
"corruptionCount": 0,
709707
"goroutineCount": 217,
710708
"GOMAXPROCS": 2,
@@ -717,8 +715,6 @@ func TestAPIs(t *testing.T) {
717715
CWD: "/prometheus",
718716
ReloadConfigSuccess: true,
719717
LastConfigTime: time.Date(2020, 5, 18, 15, 52, 56, 0, time.UTC),
720-
ChunkCount: 72692,
721-
TimeSeriesCount: 18476,
722718
CorruptionCount: 0,
723719
GoroutineCount: 217,
724720
GOMAXPROCS: 2,
@@ -1152,6 +1148,13 @@ func TestAPIs(t *testing.T) {
11521148
reqMethod: "GET",
11531149
reqPath: "/api/v1/status/tsdb",
11541150
inRes: map[string]interface{}{
1151+
"headStats": map[string]interface{}{
1152+
"numSeries": 18476,
1153+
"numLabelPairs": 4301,
1154+
"chunkCount": 72692,
1155+
"minTime": 1634644800304,
1156+
"maxTime": 1634650590304,
1157+
},
11551158
"seriesCountByMetricName": []interface{}{
11561159
map[string]interface{}{
11571160
"name": "kubelet_http_requests_duration_seconds_bucket",
@@ -1178,6 +1181,13 @@ func TestAPIs(t *testing.T) {
11781181
},
11791182
},
11801183
res: TSDBResult{
1184+
HeadStats: TSDBHeadStats{
1185+
NumSeries: 18476,
1186+
NumLabelPairs: 4301,
1187+
ChunkCount: 72692,
1188+
MinTime: 1634644800304,
1189+
MaxTime: 1634650590304,
1190+
},
11811191
SeriesCountByMetricName: []Stat{
11821192
{
11831193
Name: "kubelet_http_requests_duration_seconds_bucket",

0 commit comments

Comments
 (0)