Alerting: Fetch configuration from the database and run a notification service (#32175)

* Alerting: Fetch configuration from the database and run a notification
instance

Co-Authored-By: Ganesh Vernekar <15064823+codesome@users.noreply.github.com>
This commit is contained in:
gotjosh
2021-03-24 14:20:44 +00:00
committed by GitHub
parent 49c4211295
commit 9b52ffc6a9
16 changed files with 437 additions and 78 deletions

View File

@@ -4,25 +4,24 @@ import (
"fmt"
"time"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/datasourceproxy"
ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/ngalert/schedule"
"github.com/grafana/grafana/pkg/services/ngalert/store"
"github.com/go-macaron/binding"
apimodels "github.com/grafana/alerting-api/pkg/api"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/api/routing"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/expr/translate"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/plugins"
"github.com/grafana/grafana/pkg/services/datasourceproxy"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/ngalert/eval"
ngmodels "github.com/grafana/grafana/pkg/services/ngalert/models"
"github.com/grafana/grafana/pkg/services/ngalert/schedule"
"github.com/grafana/grafana/pkg/services/ngalert/store"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/tsdb"
"github.com/grafana/grafana/pkg/util"
@@ -31,6 +30,10 @@ import (
// timeNow makes it possible to test usage of time
var timeNow = time.Now
type Alertmanager interface {
ApplyConfig(config *apimodels.PostableUserConfig) error
}
// API handlers.
type API struct {
Cfg *setting.Cfg
@@ -40,6 +43,7 @@ type API struct {
Schedule schedule.ScheduleService
Store store.Store
DataProxy *datasourceproxy.DatasourceProxyService
Alertmanager Alertmanager
}
// RegisterAPIEndpoints registers API handlers