Alerting: Return cached alerts for prometheus/api/v1/alerts (#32654)

* Return cached alerts for prometheus/api/v1/alerts

* Return not implemented for /prometheus/grafana/api/v1/rules

* Set StartsAt for already alerting states

* Fix tests
This commit is contained in:
David Parrott
2021-04-05 15:05:39 -07:00
committed by GitHub
parent ec624aa1ef
commit c0d83fc01e
6 changed files with 54 additions and 136 deletions
+4 -1
View File
@@ -4,6 +4,8 @@ import (
"fmt"
"time"
"github.com/grafana/grafana/pkg/services/ngalert/state"
"github.com/go-macaron/binding"
apimodels "github.com/grafana/alerting-api/pkg/api"
@@ -47,6 +49,7 @@ type API struct {
AlertingStore store.AlertingStore
DataProxy *datasourceproxy.DatasourceProxyService
Alertmanager Alertmanager
StateTracker *state.StateTracker
}
// RegisterAPIEndpoints registers API handlers
@@ -63,7 +66,7 @@ func (api *API) RegisterAPIEndpoints() {
api.RegisterPrometheusApiEndpoints(NewForkedProm(
api.DatasourceCache,
NewLotexProm(proxy, logger),
PrometheusApiMock{log: logger},
PrometheusSrv{log: logger, stateTracker: api.StateTracker},
))
api.RegisterRulerApiEndpoints(NewForkedRuler(
api.DatasourceCache,