Alerting: Add endpoint to revert to a previous alertmanager configuration (#65751)
* Alerting: Add endpoint to revert to a previous alertmanager configuration This endpoint is meant to be used in conjunction with /api/alertmanager/grafana/config/history to revert to a previously applied alertmanager configuration. This is done by ID instead of raw config string in order to avoid secure field complications.
This commit is contained in:
@@ -42,6 +42,7 @@ type AlertmanagerApi interface {
|
||||
RoutePostAMAlerts(*contextmodel.ReqContext) response.Response
|
||||
RoutePostAlertingConfig(*contextmodel.ReqContext) response.Response
|
||||
RoutePostGrafanaAlertingConfig(*contextmodel.ReqContext) response.Response
|
||||
RoutePostGrafanaAlertingConfigHistoryActivate(*contextmodel.ReqContext) response.Response
|
||||
RoutePostTestGrafanaReceivers(*contextmodel.ReqContext) response.Response
|
||||
}
|
||||
|
||||
@@ -167,6 +168,11 @@ func (f *AlertmanagerApiHandler) RoutePostGrafanaAlertingConfig(ctx *contextmode
|
||||
}
|
||||
return f.handleRoutePostGrafanaAlertingConfig(ctx, conf)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RoutePostGrafanaAlertingConfigHistoryActivate(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Path Parameters
|
||||
idParam := web.Params(ctx.Req)[":id"]
|
||||
return f.handleRoutePostGrafanaAlertingConfigHistoryActivate(ctx, idParam)
|
||||
}
|
||||
func (f *AlertmanagerApiHandler) RoutePostTestGrafanaReceivers(ctx *contextmodel.ReqContext) response.Response {
|
||||
// Parse Request Body
|
||||
conf := apimodels.TestReceiversConfigBodyParams{}
|
||||
@@ -408,6 +414,16 @@ func (api *API) RegisterAlertmanagerApiEndpoints(srv AlertmanagerApi, m *metrics
|
||||
m,
|
||||
),
|
||||
)
|
||||
group.Post(
|
||||
toMacaronPath("/api/alertmanager/grafana/config/history/{id}/_activate"),
|
||||
api.authorize(http.MethodPost, "/api/alertmanager/grafana/config/history/{id}/_activate"),
|
||||
metrics.Instrument(
|
||||
http.MethodPost,
|
||||
"/api/alertmanager/grafana/config/history/{id}/_activate",
|
||||
srv.RoutePostGrafanaAlertingConfigHistoryActivate,
|
||||
m,
|
||||
),
|
||||
)
|
||||
group.Post(
|
||||
toMacaronPath("/api/alertmanager/grafana/config/api/v1/receivers/test"),
|
||||
api.authorize(http.MethodPost, "/api/alertmanager/grafana/config/api/v1/receivers/test"),
|
||||
|
||||
Reference in New Issue
Block a user