Alerting: modify prometheus endpoints for proxying using the datasource UID (#48052)

* Modify prometheus endpoints to expect the data source UID

* Update frontend
This commit is contained in:
Sofia Papagiannaki
2022-05-06 15:05:02 -04:00
committed by GitHub
parent 30d9cc81ec
commit bb66c03f9a
11 changed files with 73 additions and 92 deletions
@@ -43,11 +43,11 @@ func (f *ForkedPrometheusApi) RouteGetRuleStatuses(ctx *models.ReqContext) respo
func (api *API) RegisterPrometheusApiEndpoints(srv PrometheusApiForkingService, m *metrics.API) {
api.RouteRegister.Group("", func(group routing.RouteRegister) {
group.Get(
toMacaronPath("/api/prometheus/{DatasourceID}/api/v1/alerts"),
api.authorize(http.MethodGet, "/api/prometheus/{DatasourceID}/api/v1/alerts"),
toMacaronPath("/api/prometheus/{DatasourceUID}/api/v1/alerts"),
api.authorize(http.MethodGet, "/api/prometheus/{DatasourceUID}/api/v1/alerts"),
metrics.Instrument(
http.MethodGet,
"/api/prometheus/{DatasourceID}/api/v1/alerts",
"/api/prometheus/{DatasourceUID}/api/v1/alerts",
srv.RouteGetAlertStatuses,
m,
),
@@ -73,11 +73,11 @@ func (api *API) RegisterPrometheusApiEndpoints(srv PrometheusApiForkingService,
),
)
group.Get(
toMacaronPath("/api/prometheus/{DatasourceID}/api/v1/rules"),
api.authorize(http.MethodGet, "/api/prometheus/{DatasourceID}/api/v1/rules"),
toMacaronPath("/api/prometheus/{DatasourceUID}/api/v1/rules"),
api.authorize(http.MethodGet, "/api/prometheus/{DatasourceUID}/api/v1/rules"),
metrics.Instrument(
http.MethodGet,
"/api/prometheus/{DatasourceID}/api/v1/rules",
"/api/prometheus/{DatasourceUID}/api/v1/rules",
srv.RouteGetRuleStatuses,
m,
),