Documentation ¶
Index ¶
- type AlertsRouter
- func (d *AlertsRouter) AlertmanagersFor(orgID int64) []*url.URL
- func (d *AlertsRouter) DroppedAlertmanagersFor(orgID int64) []*url.URL
- func (d *AlertsRouter) Run(ctx context.Context) error
- func (d *AlertsRouter) Send(key models.AlertRuleKey, alerts definitions.PostableAlerts)
- func (d *AlertsRouter) SyncAndApplyConfigFromDatabase() error
- type ExternalAlertmanager
- func (s *ExternalAlertmanager) Alertmanagers() []*url.URL
- func (s *ExternalAlertmanager) ApplyConfig(cfg *ngmodels.AdminConfiguration) error
- func (s *ExternalAlertmanager) DroppedAlertmanagers() []*url.URL
- func (s *ExternalAlertmanager) Run()
- func (s *ExternalAlertmanager) SendAlerts(alerts apimodels.PostableAlerts)
- func (s *ExternalAlertmanager) Stop()
- type FakeExternalAlertmanager
- func (am *FakeExternalAlertmanager) AlertNamesCompare(expected []string) bool
- func (am *FakeExternalAlertmanager) Alerts() amv2.PostableAlerts
- func (am *FakeExternalAlertmanager) AlertsCount() int
- func (am *FakeExternalAlertmanager) Close()
- func (am *FakeExternalAlertmanager) Handler() func(w http.ResponseWriter, r *http.Request)
- func (am *FakeExternalAlertmanager) URL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertsRouter ¶
type AlertsRouter struct {
// contains filtered or unexported fields
}
AlertsRouter handles alerts generated during alert rule evaluation. Based on rule's orgID and the configuration for that organization, it determines whether an alert needs to be sent to an external Alertmanager and\or internal notifier.Alertmanager
After creating a AlertsRouter, you must call Run to keep the AlertsRouter's state synchronized with the alerting configuration.
func NewAlertsRouter ¶
func NewAlertsRouter(multiOrgNotifier *notifier.MultiOrgAlertmanager, store store.AdminConfigurationStore, clk clock.Clock, appURL *url.URL, disabledOrgs map[int64]struct{}, configPollInterval time.Duration, datasourceService datasources.DataSourceService, secretService secrets.Service) *AlertsRouter
func (*AlertsRouter) AlertmanagersFor ¶
func (d *AlertsRouter) AlertmanagersFor(orgID int64) []*url.URL
AlertmanagersFor returns all the discovered Alertmanager(s) for a particular organization.
func (*AlertsRouter) DroppedAlertmanagersFor ¶
func (d *AlertsRouter) DroppedAlertmanagersFor(orgID int64) []*url.URL
DroppedAlertmanagersFor returns all the dropped Alertmanager(s) for a particular organization.
func (*AlertsRouter) Run ¶
func (d *AlertsRouter) Run(ctx context.Context) error
Run starts regular updates of the configuration.
func (*AlertsRouter) Send ¶
func (d *AlertsRouter) Send(key models.AlertRuleKey, alerts definitions.PostableAlerts)
func (*AlertsRouter) SyncAndApplyConfigFromDatabase ¶
func (d *AlertsRouter) SyncAndApplyConfigFromDatabase() error
SyncAndApplyConfigFromDatabase looks for the admin configuration in the database and adjusts the sender(s) and alert handling mechanism accordingly.
type ExternalAlertmanager ¶
type ExternalAlertmanager struct {
// contains filtered or unexported fields
}
ExternalAlertmanager is responsible for dispatching alert notifications to an external Alertmanager service.
func NewExternalAlertmanagerSender ¶
func NewExternalAlertmanagerSender() (*ExternalAlertmanager, error)
func (*ExternalAlertmanager) Alertmanagers ¶
func (s *ExternalAlertmanager) Alertmanagers() []*url.URL
Alertmanagers returns a list of the discovered Alertmanager(s).
func (*ExternalAlertmanager) ApplyConfig ¶
func (s *ExternalAlertmanager) ApplyConfig(cfg *ngmodels.AdminConfiguration) error
ApplyConfig syncs a configuration with the sender.
func (*ExternalAlertmanager) DroppedAlertmanagers ¶
func (s *ExternalAlertmanager) DroppedAlertmanagers() []*url.URL
DroppedAlertmanagers returns a list of Alertmanager(s) we no longer send alerts to.
func (*ExternalAlertmanager) Run ¶
func (s *ExternalAlertmanager) Run()
func (*ExternalAlertmanager) SendAlerts ¶
func (s *ExternalAlertmanager) SendAlerts(alerts apimodels.PostableAlerts)
SendAlerts sends a set of alerts to the configured Alertmanager(s).
func (*ExternalAlertmanager) Stop ¶
func (s *ExternalAlertmanager) Stop()
Stop shuts down the sender.
type FakeExternalAlertmanager ¶
type FakeExternalAlertmanager struct { Server *httptest.Server // contains filtered or unexported fields }
func NewFakeExternalAlertmanager ¶
func NewFakeExternalAlertmanager(t *testing.T) *FakeExternalAlertmanager
func (*FakeExternalAlertmanager) AlertNamesCompare ¶
func (am *FakeExternalAlertmanager) AlertNamesCompare(expected []string) bool
func (*FakeExternalAlertmanager) Alerts ¶
func (am *FakeExternalAlertmanager) Alerts() amv2.PostableAlerts
func (*FakeExternalAlertmanager) AlertsCount ¶
func (am *FakeExternalAlertmanager) AlertsCount() int
func (*FakeExternalAlertmanager) Close ¶
func (am *FakeExternalAlertmanager) Close()
func (*FakeExternalAlertmanager) Handler ¶
func (am *FakeExternalAlertmanager) Handler() func(w http.ResponseWriter, r *http.Request)
func (*FakeExternalAlertmanager) URL ¶
func (am *FakeExternalAlertmanager) URL() string