mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Proxy RouteDeleteAlertingConfig through MultiOrgAlertmanager (#93549)
Proxy RouteDeleteAlertingConfig through MultiOrgAlertmanager
This commit is contained in:
parent
ccf6fbebfa
commit
7398fe3fcb
@ -65,14 +65,10 @@ func (srv AlertmanagerSrv) RouteGetAMStatus(c *contextmodel.ReqContext) response
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (srv AlertmanagerSrv) RouteDeleteAlertingConfig(c *contextmodel.ReqContext) response.Response {
|
func (srv AlertmanagerSrv) RouteDeleteAlertingConfig(c *contextmodel.ReqContext) response.Response {
|
||||||
am, errResp := srv.AlertmanagerFor(c.SignedInUser.GetOrgID())
|
err := srv.mam.SaveAndApplyDefaultConfig(c.Req.Context(), c.SignedInUser.GetOrgID())
|
||||||
if errResp != nil {
|
if err != nil {
|
||||||
return errResp
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := am.SaveAndApplyDefaultConfig(c.Req.Context()); err != nil {
|
|
||||||
srv.log.Error("Unable to save and apply default alertmanager configuration", "error", err)
|
srv.log.Error("Unable to save and apply default alertmanager configuration", "error", err)
|
||||||
return ErrResp(http.StatusInternalServerError, err, "failed to save and apply default Alertmanager configuration")
|
return response.ErrOrFallback(http.StatusInternalServerError, "failed to save and apply default Alertmanager configuration", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.JSON(http.StatusAccepted, util.DynMap{"message": "configuration deleted; the default is applied"})
|
return response.JSON(http.StatusAccepted, util.DynMap{"message": "configuration deleted; the default is applied"})
|
||||||
|
@ -49,6 +49,22 @@ type configurationStore interface {
|
|||||||
GetLatestAlertmanagerConfiguration(ctx context.Context, orgID int64) (*models.AlertConfiguration, error)
|
GetLatestAlertmanagerConfiguration(ctx context.Context, orgID int64) (*models.AlertConfiguration, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (moa *MultiOrgAlertmanager) SaveAndApplyDefaultConfig(ctx context.Context, orgId int64) error {
|
||||||
|
moa.alertmanagersMtx.RLock()
|
||||||
|
defer moa.alertmanagersMtx.RUnlock()
|
||||||
|
|
||||||
|
orgAM, err := moa.alertmanagerForOrg(orgId)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = orgAM.SaveAndApplyDefaultConfig(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ApplyConfig will apply the given alertmanager configuration for a given org.
|
// ApplyConfig will apply the given alertmanager configuration for a given org.
|
||||||
// Can be used to force regeneration of autogenerated routes.
|
// Can be used to force regeneration of autogenerated routes.
|
||||||
func (moa *MultiOrgAlertmanager) ApplyConfig(ctx context.Context, orgId int64, dbConfig *models.AlertConfiguration) error {
|
func (moa *MultiOrgAlertmanager) ApplyConfig(ctx context.Context, orgId int64, dbConfig *models.AlertConfiguration) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user