mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Allow hooking into request handler functions. (#67000)
* Alerting: Allow hooking into request handler functions. Adds a facility to AlertNG for hooking into API handlers, allowing the replacement of request handlers for specific paths. One of goals of this approach was to allow hooking as late as possible in the request, e.g. after all middleware has been applied, to simplfiy usage. * Update pkg/services/ngalert/api/hooks.go Co-authored-by: gotjosh <josue.abreu@gmail.com> * Update pkg/services/ngalert/api/hooks.go Co-authored-by: gotjosh <josue.abreu@gmail.com> * Update pkg/services/ngalert/ngalert.go Co-authored-by: gotjosh <josue.abreu@gmail.com> * Fixes to review comments * Fix passing logger in --------- Co-authored-by: gotjosh <josue.abreu@gmail.com>
This commit is contained in:
@@ -68,7 +68,7 @@ func (api *API) RegisterTestingApiEndpoints(srv TestingApi, m *metrics.API) {
|
||||
metrics.Instrument(
|
||||
http.MethodPost,
|
||||
"/api/v1/rule/backtest",
|
||||
srv.BacktestConfig,
|
||||
api.Hooks.Wrap(srv.BacktestConfig),
|
||||
m,
|
||||
),
|
||||
)
|
||||
@@ -78,7 +78,7 @@ func (api *API) RegisterTestingApiEndpoints(srv TestingApi, m *metrics.API) {
|
||||
metrics.Instrument(
|
||||
http.MethodPost,
|
||||
"/api/v1/eval",
|
||||
srv.RouteEvalQueries,
|
||||
api.Hooks.Wrap(srv.RouteEvalQueries),
|
||||
m,
|
||||
),
|
||||
)
|
||||
@@ -88,7 +88,7 @@ func (api *API) RegisterTestingApiEndpoints(srv TestingApi, m *metrics.API) {
|
||||
metrics.Instrument(
|
||||
http.MethodPost,
|
||||
"/api/v1/rule/test/{DatasourceUID}",
|
||||
srv.RouteTestRuleConfig,
|
||||
api.Hooks.Wrap(srv.RouteTestRuleConfig),
|
||||
m,
|
||||
),
|
||||
)
|
||||
@@ -98,7 +98,7 @@ func (api *API) RegisterTestingApiEndpoints(srv TestingApi, m *metrics.API) {
|
||||
metrics.Instrument(
|
||||
http.MethodPost,
|
||||
"/api/v1/rule/test/grafana",
|
||||
srv.RouteTestRuleGrafanaConfig,
|
||||
api.Hooks.Wrap(srv.RouteTestRuleGrafanaConfig),
|
||||
m,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user