From f5c01c8640291b92d2d4be452ef1e993fb8dfd7c Mon Sep 17 00:00:00 2001 From: Guillaume audic Date: Fri, 22 Jul 2022 13:47:58 +0000 Subject: [PATCH] fix(api): When querying api query on endpoint alerts return a json struct with alerts in lowercase. To be same result as prometheus api Signed-off-by: audig docs(changelog): Add link to MR #5534 --- CHANGELOG.md | 1 + pkg/api/query/v1.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e90aaf13257..a4b2cde1099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re ### Fixed - [#5502](https://github.com/thanos-io/thanos/pull/5502) Receive: Handle exemplar storage errors as conflict error. +- [#5534](https://github.com/thanos-io/thanos/pull/5534) Query: Set struct return by query api alerts same as prometheus api ### Added diff --git a/pkg/api/query/v1.go b/pkg/api/query/v1.go index 7a8fbf5fca1..fbc9a181693 100644 --- a/pkg/api/query/v1.go +++ b/pkg/api/query/v1.go @@ -794,7 +794,9 @@ func NewAlertsHandler(client rules.UnaryClient, enablePartialResponse bool) func return nil, nil, &api.ApiError{Typ: api.ErrorInternal, Err: errors.Errorf("error retrieving rules: %v", err)} } - var resp struct{ Alerts []*rulespb.AlertInstance } + var resp struct { + Alerts []*rulespb.AlertInstance `json:"alerts"` + } for _, g := range groups.Groups { for _, r := range g.Rules { a := r.GetAlert()