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 <l.mierzwa@gmail.com>
This commit is contained in:
Łukasz Mierzwa 2022-01-05 09:09:29 +00:00 committed by GitHub
parent e6e54e8082
commit dc1559e8ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 10 deletions

View File

@ -306,8 +306,6 @@ type RuntimeinfoResult struct {
CWD string `json:"CWD"`
ReloadConfigSuccess bool `json:"reloadConfigSuccess"`
LastConfigTime time.Time `json:"lastConfigTime"`
ChunkCount int `json:"chunkCount"`
TimeSeriesCount int `json:"timeSeriesCount"`
CorruptionCount int `json:"corruptionCount"`
GoroutineCount int `json:"goroutineCount"`
GOMAXPROCS int `json:"GOMAXPROCS"`
@ -434,12 +432,22 @@ type queryResult struct {
// TSDBResult contains the result from querying the tsdb endpoint.
type TSDBResult struct {
HeadStats TSDBHeadStats `json:"headStats"`
SeriesCountByMetricName []Stat `json:"seriesCountByMetricName"`
LabelValueCountByLabelName []Stat `json:"labelValueCountByLabelName"`
MemoryInBytesByLabelName []Stat `json:"memoryInBytesByLabelName"`
SeriesCountByLabelValuePair []Stat `json:"seriesCountByLabelValuePair"`
}
// TSDBHeadStats contains TSDB stats
type TSDBHeadStats struct {
NumSeries int `json:"numSeries"`
NumLabelPairs int `json:"numLabelPairs"`
ChunkCount int `json:"chunkCount"`
MinTime int `json:"minTime"`
MaxTime int `json:"maxTime"`
}
// WalReplayStatus represents the wal replay status.
type WalReplayStatus struct {
Min int `json:"min"`

View File

@ -703,8 +703,6 @@ func TestAPIs(t *testing.T) {
"CWD": "/prometheus",
"reloadConfigSuccess": true,
"lastConfigTime": "2020-05-18T15:52:56Z",
"chunkCount": 72692,
"timeSeriesCount": 18476,
"corruptionCount": 0,
"goroutineCount": 217,
"GOMAXPROCS": 2,
@ -717,8 +715,6 @@ func TestAPIs(t *testing.T) {
CWD: "/prometheus",
ReloadConfigSuccess: true,
LastConfigTime: time.Date(2020, 5, 18, 15, 52, 56, 0, time.UTC),
ChunkCount: 72692,
TimeSeriesCount: 18476,
CorruptionCount: 0,
GoroutineCount: 217,
GOMAXPROCS: 2,
@ -1152,6 +1148,13 @@ func TestAPIs(t *testing.T) {
reqMethod: "GET",
reqPath: "/api/v1/status/tsdb",
inRes: map[string]interface{}{
"headStats": map[string]interface{}{
"numSeries": 18476,
"numLabelPairs": 4301,
"chunkCount": 72692,
"minTime": 1634644800304,
"maxTime": 1634650590304,
},
"seriesCountByMetricName": []interface{}{
map[string]interface{}{
"name": "kubelet_http_requests_duration_seconds_bucket",
@ -1178,6 +1181,13 @@ func TestAPIs(t *testing.T) {
},
},
res: TSDBResult{
HeadStats: TSDBHeadStats{
NumSeries: 18476,
NumLabelPairs: 4301,
ChunkCount: 72692,
MinTime: 1634644800304,
MaxTime: 1634650590304,
},
SeriesCountByMetricName: []Stat{
{
Name: "kubelet_http_requests_duration_seconds_bucket",