schedule

package
v0.0.85-test Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2023 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoDataAlertName = "DatasourceNoData"
	ErrorAlertName  = "DatasourceError"

	Rulename = "rulename"
)

Variables

This section is empty.

Functions

func FromAlertStateToPostableAlerts

func FromAlertStateToPostableAlerts(firingStates []*state.State, stateManager *state.Manager, appURL *url.URL) apimodels.PostableAlerts

func FromAlertsStateToStoppedAlert

func FromAlertsStateToStoppedAlert(firingStates []*state.State, appURL *url.URL, clock clock.Clock) apimodels.PostableAlerts

FromAlertsStateToStoppedAlert converts firingStates that have evaluation state either eval.Alerting or eval.NoData or eval.Error to models.PostableAlert that are accepted by notifiers. Returns a list of alert instances that have expiration time.Now

func NewScheduler

func NewScheduler(cfg SchedulerCfg, expressionService *expr.Service, appURL *url.URL, stateManager *state.Manager) *schedule

NewScheduler returns a new schedule.

Types

type FakeScheduleService

type FakeScheduleService struct {
	mock.Mock
}

FakeScheduleService is an autogenerated mock type for the ScheduleService type

func (*FakeScheduleService) AlertmanagersFor

func (_m *FakeScheduleService) AlertmanagersFor(orgID int64) []*url.URL

AlertmanagersFor provides a mock function with given fields: orgID

func (*FakeScheduleService) DeleteAlertRule

func (_m *FakeScheduleService) DeleteAlertRule(key models.AlertRuleKey)

DeleteAlertRule provides a mock function with given fields: key

func (*FakeScheduleService) DroppedAlertmanagersFor

func (_m *FakeScheduleService) DroppedAlertmanagersFor(orgID int64) []*url.URL

DroppedAlertmanagersFor provides a mock function with given fields: orgID

func (*FakeScheduleService) Pause

func (_m *FakeScheduleService) Pause() error

Pause provides a mock function with given fields:

func (*FakeScheduleService) Run

Run provides a mock function with given fields: _a0

func (*FakeScheduleService) Unpause

func (_m *FakeScheduleService) Unpause() error

Unpause provides a mock function with given fields:

func (*FakeScheduleService) UpdateAlertRule

func (_m *FakeScheduleService) UpdateAlertRule(key models.AlertRuleKey)

UpdateAlertRule provides a mock function with given fields: key

type ScheduleService

type ScheduleService interface {
	// Run the scheduler until the context is canceled or the scheduler returns
	// an error. The scheduler is terminated when this function returns.
	Run(context.Context) error
	Pause() error
	Unpause() error

	// AlertmanagersFor returns all the discovered Alertmanager URLs for the
	// organization.
	AlertmanagersFor(orgID int64) []*url.URL

	// DroppedAlertmanagersFor returns all the dropped Alertmanager URLs for the
	// organization.
	DroppedAlertmanagersFor(orgID int64) []*url.URL
	// UpdateAlertRule notifies scheduler that a rule has been changed
	UpdateAlertRule(key models.AlertRuleKey)
	// DeleteAlertRule notifies scheduler that a rule has been changed
	DeleteAlertRule(key models.AlertRuleKey)
	// contains filtered or unexported methods
}

ScheduleService is an interface for a service that schedules the evaluation of alert rules.

type SchedulerCfg

type SchedulerCfg struct {
	C                       clock.Clock
	BaseInterval            time.Duration
	Logger                  log.Logger
	EvalAppliedFunc         func(models.AlertRuleKey, time.Time)
	MaxAttempts             int64
	StopAppliedFunc         func(models.AlertRuleKey)
	Evaluator               eval.Evaluator
	RuleStore               store.RuleStore
	OrgStore                store.OrgStore
	InstanceStore           store.InstanceStore
	AdminConfigStore        store.AdminConfigurationStore
	MultiOrgNotifier        *notifier.MultiOrgAlertmanager
	Metrics                 *metrics.Scheduler
	AdminConfigPollInterval time.Duration
	DisabledOrgs            map[int64]struct{}
	MinRuleInterval         time.Duration
}

SchedulerCfg is the scheduler configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL