Alerting: log errors happening in the API on server side (#43192) (#43205)

* Alerting: log errors happening in the API on server side

* adapt tests to reflect changed payload

(cherry picked from commit b605340668)

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2021-12-16 14:02:49 +01:00
committed by GitHub
parent ec980bf19e
commit b78aca6e23
6 changed files with 29 additions and 29 deletions
@@ -88,7 +88,7 @@ func TestAlertmanagerConfigurationIsTransactional(t *testing.T) {
}
`
resp := postRequest(t, alertConfigURL, payload, http.StatusBadRequest) // nolint
require.JSONEq(t, `{"message":"failed to save and apply Alertmanager configuration: failed to build integration map: the receiver is invalid: failed to validate receiver \"slack.receiver\" of type \"slack\": token must be specified when using the Slack chat API"}`, getBody(t, resp.Body))
require.JSONEq(t, `{"message": "API error","error":"failed to save and apply Alertmanager configuration: failed to build integration map: the receiver is invalid: failed to validate receiver \"slack.receiver\" of type \"slack\": token must be specified when using the Slack chat API"}`, getBody(t, resp.Body))
resp = getRequest(t, alertConfigURL, http.StatusOK) // nolint
require.JSONEq(t, defaultAlertmanagerConfigJSON, getBody(t, resp.Body))
@@ -208,7 +208,7 @@ func TestAlertmanagerConfigurationPersistSecrets(t *testing.T) {
`
resp := postRequest(t, alertConfigURL, payload, http.StatusBadRequest) // nolint
require.JSONEq(t, `{"message": "unknown receiver: invalid"}`, getBody(t, resp.Body))
require.JSONEq(t, `{"message": "API error","error": "unknown receiver: invalid"}`, getBody(t, resp.Body))
}
// The secure settings must be present