Merge pull request #13641 from bboreham/pick-13633

Cut 2.50.1 with metadata api bugfix (cherry-picked #13633)
This commit is contained in:
Bryan Boreham 2024-02-26 11:31:35 +00:00 committed by GitHub
commit 8c9b028536
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 39 additions and 18 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## 2.50.1 / 2024-02-26
* [BUGFIX] API: Fix metadata API using wrong field names. #13633
## 2.50.0 / 2024-02-22
* [CHANGE] Remote Write: Error `storage.ErrTooOldSample` is now generating HTTP error 400 instead of HTTP error 500. #13335

View File

@ -1 +1 @@
2.50.0
2.50.1

View File

@ -17,7 +17,7 @@ import "github.com/prometheus/common/model"
// Metadata stores a series' metadata information.
type Metadata struct {
Type model.MetricType
Unit string
Help string
Type model.MetricType `json:"type"`
Unit string `json:"unit"`
Help string `json:"help"`
}

View File

@ -1066,6 +1066,7 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
response interface{}
responseLen int
responseMetadataTotal int
responseAsJSON string
errType errorType
sorter func(interface{})
metadata []targetMetadata
@ -1736,6 +1737,9 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
"prometheus_engine_query_duration_seconds": {{Type: model.MetricTypeSummary, Help: "Query timings", Unit: ""}},
"go_info": {{Type: model.MetricTypeGauge, Help: "Information about the Go environment.", Unit: ""}},
},
responseAsJSON: `{"prometheus_engine_query_duration_seconds":[{"type":"summary","unit":"",
"help":"Query timings"}], "go_info":[{"type":"gauge","unit":"",
"help":"Information about the Go environment."}]}`,
},
// With duplicate metadata for a metric that comes from different targets.
{
@ -1767,6 +1771,8 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
response: map[string][]metadata.Metadata{
"go_threads": {{Type: model.MetricTypeGauge, Help: "Number of OS threads created"}},
},
responseAsJSON: `{"go_threads": [{"type":"gauge","unit":"",
"help":"Number of OS threads created"}]}`,
},
// With non-duplicate metadata for the same metric from different targets.
{
@ -1801,6 +1807,9 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
{Type: model.MetricTypeGauge, Help: "Number of OS threads that were created."},
},
},
responseAsJSON: `{"go_threads": [{"type":"gauge","unit":"",
"help":"Number of OS threads created"},{"type":"gauge","unit":"",
"help":"Number of OS threads that were created."}]}`,
sorter: func(m interface{}) {
v := m.(map[string][]metadata.Metadata)["go_threads"]
@ -1828,7 +1837,7 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
{
Metric: "prometheus_engine_query_duration_seconds",
Type: model.MetricTypeSummary,
Help: "Query Timmings.",
Help: "Query Timings.",
Unit: "",
},
},
@ -1884,6 +1893,7 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
{Type: model.MetricTypeSummary, Help: "A summary of the GC invocation durations."},
},
},
responseAsJSON: `{"go_gc_duration_seconds":[{"help":"A summary of the GC invocation durations.","type":"summary","unit":""}],"go_threads": [{"type":"gauge","unit":"","help":"Number of OS threads created"}]}`,
},
// With a limit for the number of metadata per metric and per metric.
{
@ -2007,6 +2017,7 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
{Type: model.MetricTypeGauge, Help: "Number of OS threads that were created."},
},
},
responseAsJSON: `{"go_threads": [{"type":"gauge","unit":"","help":"Number of OS threads created"},{"type":"gauge","unit":"","help":"Number of OS threads that were created."}]}`,
sorter: func(m interface{}) {
v := m.(map[string][]metadata.Metadata)["go_threads"]
@ -2880,6 +2891,12 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
}
assertAPIResponse(t, res.data, test.response)
}
if test.responseAsJSON != "" {
s, err := json.Marshal(res.data)
require.NoError(t, err)
require.JSONEq(t, test.responseAsJSON, string(s))
}
})
}
})

View File

@ -1,6 +1,6 @@
{
"name": "@prometheus-io/codemirror-promql",
"version": "0.50.0",
"version": "0.50.1",
"description": "a CodeMirror mode for the PromQL language",
"types": "dist/esm/index.d.ts",
"module": "dist/esm/index.js",
@ -29,7 +29,7 @@
},
"homepage": "https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql/README.md",
"dependencies": {
"@prometheus-io/lezer-promql": "0.50.0",
"@prometheus-io/lezer-promql": "0.50.1",
"lru-cache": "^7.18.3"
},
"devDependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@prometheus-io/lezer-promql",
"version": "0.50.0",
"version": "0.50.1",
"description": "lezer-based PromQL grammar",
"main": "dist/index.cjs",
"type": "module",

View File

@ -1,12 +1,12 @@
{
"name": "prometheus-io",
"version": "0.50.0",
"version": "0.50.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "prometheus-io",
"version": "0.50.0",
"version": "0.50.1",
"workspaces": [
"react-app",
"module/*"
@ -30,10 +30,10 @@
},
"module/codemirror-promql": {
"name": "@prometheus-io/codemirror-promql",
"version": "0.50.0",
"version": "0.50.1",
"license": "Apache-2.0",
"dependencies": {
"@prometheus-io/lezer-promql": "0.50.0",
"@prometheus-io/lezer-promql": "0.50.1",
"lru-cache": "^7.18.3"
},
"devDependencies": {
@ -69,7 +69,7 @@
},
"module/lezer-promql": {
"name": "@prometheus-io/lezer-promql",
"version": "0.50.0",
"version": "0.50.1",
"license": "Apache-2.0",
"devDependencies": {
"@lezer/generator": "^1.5.1",
@ -19233,7 +19233,7 @@
},
"react-app": {
"name": "@prometheus-io/app",
"version": "0.50.0",
"version": "0.50.1",
"dependencies": {
"@codemirror/autocomplete": "^6.11.1",
"@codemirror/commands": "^6.3.2",
@ -19251,7 +19251,7 @@
"@lezer/lr": "^1.3.14",
"@nexucis/fuzzy": "^0.4.1",
"@nexucis/kvsearch": "^0.8.1",
"@prometheus-io/codemirror-promql": "0.50.0",
"@prometheus-io/codemirror-promql": "0.50.1",
"bootstrap": "^4.6.2",
"css.escape": "^1.5.1",
"downshift": "^7.6.2",

View File

@ -28,5 +28,5 @@
"ts-jest": "^29.1.1",
"typescript": "^4.9.5"
},
"version": "0.50.0"
"version": "0.50.1"
}

View File

@ -1,6 +1,6 @@
{
"name": "@prometheus-io/app",
"version": "0.50.0",
"version": "0.50.1",
"private": true,
"dependencies": {
"@codemirror/autocomplete": "^6.11.1",
@ -19,7 +19,7 @@
"@lezer/lr": "^1.3.14",
"@nexucis/fuzzy": "^0.4.1",
"@nexucis/kvsearch": "^0.8.1",
"@prometheus-io/codemirror-promql": "0.50.0",
"@prometheus-io/codemirror-promql": "0.50.1",
"bootstrap": "^4.6.2",
"css.escape": "^1.5.1",
"downshift": "^7.6.2",