2021-03-12 03:28:00 +08:00
|
|
|
/*Package api contains base API implementation of unified alerting
|
|
|
|
|
*
|
2021-04-09 17:55:41 +08:00
|
|
|
*Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
2021-03-12 03:28:00 +08:00
|
|
|
*
|
2021-04-09 17:55:41 +08:00
|
|
|
*Do not manually edit these files, please find ngalert/api/swagger-codegen/ for commands on how to generate them.
|
2021-03-12 03:28:00 +08:00
|
|
|
*/
|
|
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
2021-04-29 04:59:15 +08:00
|
|
|
"net/http"
|
|
|
|
|
|
2021-03-12 03:28:00 +08:00
|
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
|
|
|
"github.com/grafana/grafana/pkg/api/routing"
|
2021-04-06 22:22:05 +08:00
|
|
|
"github.com/grafana/grafana/pkg/middleware"
|
2021-03-12 03:28:00 +08:00
|
|
|
"github.com/grafana/grafana/pkg/models"
|
2021-05-01 00:28:06 +08:00
|
|
|
"github.com/grafana/grafana/pkg/services/ngalert/metrics"
|
2021-03-12 03:28:00 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type PrometheusApiService interface {
|
|
|
|
|
RouteGetAlertStatuses(*models.ReqContext) response.Response
|
|
|
|
|
RouteGetRuleStatuses(*models.ReqContext) response.Response
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 19:55:01 +08:00
|
|
|
func (api *API) RegisterPrometheusApiEndpoints(srv PrometheusApiService, m *metrics.API) {
|
2021-03-12 03:28:00 +08:00
|
|
|
api.RouteRegister.Group("", func(group routing.RouteRegister) {
|
2021-04-29 04:59:15 +08:00
|
|
|
group.Get(
|
|
|
|
|
toMacaronPath("/api/prometheus/{Recipient}/api/v1/alerts"),
|
2021-05-01 00:28:06 +08:00
|
|
|
metrics.Instrument(
|
2021-04-29 04:59:15 +08:00
|
|
|
http.MethodGet,
|
|
|
|
|
"/api/prometheus/{Recipient}/api/v1/alerts",
|
|
|
|
|
srv.RouteGetAlertStatuses,
|
2021-05-01 00:28:06 +08:00
|
|
|
m,
|
2021-04-29 04:59:15 +08:00
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
group.Get(
|
|
|
|
|
toMacaronPath("/api/prometheus/{Recipient}/api/v1/rules"),
|
2021-05-01 00:28:06 +08:00
|
|
|
metrics.Instrument(
|
2021-04-29 04:59:15 +08:00
|
|
|
http.MethodGet,
|
|
|
|
|
"/api/prometheus/{Recipient}/api/v1/rules",
|
|
|
|
|
srv.RouteGetRuleStatuses,
|
2021-05-01 00:28:06 +08:00
|
|
|
m,
|
2021-04-29 04:59:15 +08:00
|
|
|
),
|
|
|
|
|
)
|
2021-04-06 22:22:05 +08:00
|
|
|
}, middleware.ReqSignedIn)
|
2021-03-12 03:28:00 +08:00
|
|
|
}
|