Alerting: New API endpoint GET /api/v1/ngalert (#55134)

* declare new endpoint /api/v1/ngalert
* add authorization for new path
* add request handler for the new path
This commit is contained in:
Yuriy Tseretyan
2022-09-14 14:03:10 -04:00
committed by GitHub
parent ca2139e9ce
commit 8a62020211
9 changed files with 142 additions and 1 deletions
@@ -22,6 +22,7 @@ type ConfigurationApi interface {
RouteDeleteNGalertConfig(*models.ReqContext) response.Response
RouteGetAlertmanagers(*models.ReqContext) response.Response
RouteGetNGalertConfig(*models.ReqContext) response.Response
RouteGetStatus(*models.ReqContext) response.Response
RoutePostNGalertConfig(*models.ReqContext) response.Response
}
@@ -34,6 +35,9 @@ func (f *ConfigurationApiHandler) RouteGetAlertmanagers(ctx *models.ReqContext)
func (f *ConfigurationApiHandler) RouteGetNGalertConfig(ctx *models.ReqContext) response.Response {
return f.handleRouteGetNGalertConfig(ctx)
}
func (f *ConfigurationApiHandler) RouteGetStatus(ctx *models.ReqContext) response.Response {
return f.handleRouteGetStatus(ctx)
}
func (f *ConfigurationApiHandler) RoutePostNGalertConfig(ctx *models.ReqContext) response.Response {
// Parse Request Body
conf := apimodels.PostableNGalertConfig{}
@@ -75,6 +79,16 @@ func (api *API) RegisterConfigurationApiEndpoints(srv ConfigurationApi, m *metri
m,
),
)
group.Get(
toMacaronPath("/api/v1/ngalert"),
api.authorize(http.MethodGet, "/api/v1/ngalert"),
metrics.Instrument(
http.MethodGet,
"/api/v1/ngalert",
srv.RouteGetStatus,
m,
),
)
group.Post(
toMacaronPath("/api/v1/ngalert/admin_config"),
api.authorize(http.MethodPost, "/api/v1/ngalert/admin_config"),