mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: 404 error status when no alertmanager configuration (#32651)
This commit is contained in:
parent
bc60991fae
commit
a80f31a5c8
@ -60,14 +60,15 @@ func (srv AlertmanagerSrv) RouteDeleteSilence(c *models.ReqContext) response.Res
|
|||||||
|
|
||||||
func (srv AlertmanagerSrv) RouteGetAlertingConfig(c *models.ReqContext) response.Response {
|
func (srv AlertmanagerSrv) RouteGetAlertingConfig(c *models.ReqContext) response.Response {
|
||||||
query := ngmodels.GetLatestAlertmanagerConfigurationQuery{}
|
query := ngmodels.GetLatestAlertmanagerConfigurationQuery{}
|
||||||
err := srv.store.GetLatestAlertmanagerConfiguration(&query)
|
if err := srv.store.GetLatestAlertmanagerConfiguration(&query); err != nil {
|
||||||
if err != nil {
|
if errors.Is(err, store.ErrNoAlertmanagerConfiguration) {
|
||||||
|
return response.Error(http.StatusNotFound, err.Error(), nil)
|
||||||
|
}
|
||||||
return response.Error(http.StatusInternalServerError, "failed to get latest configuration", err)
|
return response.Error(http.StatusInternalServerError, "failed to get latest configuration", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := apimodels.PostableUserConfig{}
|
cfg := apimodels.PostableUserConfig{}
|
||||||
err = yaml.Unmarshal([]byte(query.Result.AlertmanagerConfiguration), &cfg)
|
if err := yaml.Unmarshal([]byte(query.Result.AlertmanagerConfiguration), &cfg); err != nil {
|
||||||
if err != nil {
|
|
||||||
return response.Error(http.StatusInternalServerError, "failed to unmarshal alertmanager configuration", err)
|
return response.Error(http.StatusInternalServerError, "failed to unmarshal alertmanager configuration", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user