Alerting: Fix notification channel migration and handle case when Alertmanager default configuration is absent (#35086) (#35246)

* Fix dashboard alert and nootifier migration for MySQL

* Fix POSTing Alertmanager configuration if no current configuration exists

in case the default configuration has not be stored yet
or has failed to get stored

* Change CreatedAt field type

(cherry picked from commit 15c55b0115)

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2021-06-04 16:41:28 +03:00
committed by GitHub
co-authored by Sofia Papagiannaki
parent da8d9e6854
commit 7eda7945d3
4 changed files with 12 additions and 11 deletions
+7 -4
View File
@@ -192,11 +192,14 @@ func (srv AlertmanagerSrv) RoutePostAlertingConfig(c *models.ReqContext, body ap
}
}
currentConfig, err := notifier.Load([]byte(query.Result.AlertmanagerConfiguration))
if err != nil {
return ErrResp(http.StatusInternalServerError, err, "failed to load lastest configuration")
currentReceiverMap := make(map[string]*apimodels.PostableGrafanaReceiver)
if query.Result != nil {
currentConfig, err := notifier.Load([]byte(query.Result.AlertmanagerConfiguration))
if err != nil {
return ErrResp(http.StatusInternalServerError, err, "failed to load lastest configuration")
}
currentReceiverMap = currentConfig.GetGrafanaReceiverMap()
}
currentReceiverMap := currentConfig.GetGrafanaReceiverMap()
// Copy the previously known secure settings
for i, r := range body.AlertmanagerConfig.Receivers {