diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b8a42c8f..0b0350004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/VERSION b/VERSION index 9e29315ac..895eb8a3b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.50.0 +2.50.1 diff --git a/model/metadata/metadata.go b/model/metadata/metadata.go index f6f2827a4..1b7e63e0f 100644 --- a/model/metadata/metadata.go +++ b/model/metadata/metadata.go @@ -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"` } diff --git a/web/api/v1/api_test.go b/web/api/v1/api_test.go index c9ab84087..c3f88e20d 100644 --- a/web/api/v1/api_test.go +++ b/web/api/v1/api_test.go @@ -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)) + } }) } }) diff --git a/web/ui/module/codemirror-promql/package.json b/web/ui/module/codemirror-promql/package.json index fb199ff5d..89aa2e9ea 100644 --- a/web/ui/module/codemirror-promql/package.json +++ b/web/ui/module/codemirror-promql/package.json @@ -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": { diff --git a/web/ui/module/lezer-promql/package.json b/web/ui/module/lezer-promql/package.json index 8490a3720..16f3f4263 100644 --- a/web/ui/module/lezer-promql/package.json +++ b/web/ui/module/lezer-promql/package.json @@ -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", diff --git a/web/ui/package-lock.json b/web/ui/package-lock.json index 62aad7972..c241d42e5 100644 --- a/web/ui/package-lock.json +++ b/web/ui/package-lock.json @@ -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", diff --git a/web/ui/package.json b/web/ui/package.json index af6bc6ddd..a28cb8065 100644 --- a/web/ui/package.json +++ b/web/ui/package.json @@ -28,5 +28,5 @@ "ts-jest": "^29.1.1", "typescript": "^4.9.5" }, - "version": "0.50.0" + "version": "0.50.1" } diff --git a/web/ui/react-app/package.json b/web/ui/react-app/package.json index 1164b0f77..113b2298c 100644 --- a/web/ui/react-app/package.json +++ b/web/ui/react-app/package.json @@ -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",