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 # Changelog
## 2.50.1 / 2024-02-26
* [BUGFIX] API: Fix metadata API using wrong field names. #13633
## 2.50.0 / 2024-02-22 ## 2.50.0 / 2024-02-22
* [CHANGE] Remote Write: Error `storage.ErrTooOldSample` is now generating HTTP error 400 instead of HTTP error 500. #13335 * [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. // Metadata stores a series' metadata information.
type Metadata struct { type Metadata struct {
Type model.MetricType Type model.MetricType `json:"type"`
Unit string Unit string `json:"unit"`
Help string Help string `json:"help"`
} }

View file

@ -1066,6 +1066,7 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
response interface{} response interface{}
responseLen int responseLen int
responseMetadataTotal int responseMetadataTotal int
responseAsJSON string
errType errorType errType errorType
sorter func(interface{}) sorter func(interface{})
metadata []targetMetadata 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: ""}}, "prometheus_engine_query_duration_seconds": {{Type: model.MetricTypeSummary, Help: "Query timings", Unit: ""}},
"go_info": {{Type: model.MetricTypeGauge, Help: "Information about the Go environment.", 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. // 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{ response: map[string][]metadata.Metadata{
"go_threads": {{Type: model.MetricTypeGauge, Help: "Number of OS threads created"}}, "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. // 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."}, {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{}) { sorter: func(m interface{}) {
v := m.(map[string][]metadata.Metadata)["go_threads"] 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", Metric: "prometheus_engine_query_duration_seconds",
Type: model.MetricTypeSummary, Type: model.MetricTypeSummary,
Help: "Query Timmings.", Help: "Query Timings.",
Unit: "", 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."}, {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. // 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."}, {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{}) { sorter: func(m interface{}) {
v := m.(map[string][]metadata.Metadata)["go_threads"] 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) 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", "name": "@prometheus-io/codemirror-promql",
"version": "0.50.0", "version": "0.50.1",
"description": "a CodeMirror mode for the PromQL language", "description": "a CodeMirror mode for the PromQL language",
"types": "dist/esm/index.d.ts", "types": "dist/esm/index.d.ts",
"module": "dist/esm/index.js", "module": "dist/esm/index.js",
@ -29,7 +29,7 @@
}, },
"homepage": "https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql/README.md", "homepage": "https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql/README.md",
"dependencies": { "dependencies": {
"@prometheus-io/lezer-promql": "0.50.0", "@prometheus-io/lezer-promql": "0.50.1",
"lru-cache": "^7.18.3" "lru-cache": "^7.18.3"
}, },
"devDependencies": { "devDependencies": {

View file

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

View file

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

View file

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

View file

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