Documentation ¶
Index ¶
- Constants
- func FromAlertsStateToStoppedAlert(firingStates []state.StateTransition, appURL *url.URL, clock clock.Clock) apimodels.PostableAlerts
- func FromStateTransitionToPostableAlerts(firingStates []state.StateTransition, stateManager *state.Manager, ...) apimodels.PostableAlerts
- func NewScheduler(cfg SchedulerCfg, stateManager *state.Manager) *schedule
- func SchedulerUserFor(orgID int64) *user.SignedInUser
- type AlertsSender
- type AlertsSenderMock
- type AlertsSenderMock_Expecter
- type AlertsSenderMock_Send_Call
- type RulesStore
- type ScheduleService
- type SchedulerCfg
Constants ¶
const ( NoDataAlertName = "DatasourceNoData" ErrorAlertName = "DatasourceError" Rulename = "rulename" )
Variables ¶
This section is empty.
Functions ¶
func FromAlertsStateToStoppedAlert ¶
func FromAlertsStateToStoppedAlert(firingStates []state.StateTransition, appURL *url.URL, clock clock.Clock) apimodels.PostableAlerts
FromAlertsStateToStoppedAlert selects only transitions from firing states (states eval.Alerting, eval.NoData, eval.Error) and converts them to models.PostableAlert with EndsAt set to time.Now
func FromStateTransitionToPostableAlerts ¶
func FromStateTransitionToPostableAlerts(firingStates []state.StateTransition, stateManager *state.Manager, appURL *url.URL) apimodels.PostableAlerts
func NewScheduler ¶
func NewScheduler(cfg SchedulerCfg, stateManager *state.Manager) *schedule
NewScheduler returns a new schedule.
func SchedulerUserFor ¶
func SchedulerUserFor(orgID int64) *user.SignedInUser
Types ¶
type AlertsSender ¶
type AlertsSender interface {
Send(key ngmodels.AlertRuleKey, alerts definitions.PostableAlerts)
}
AlertsSender is an interface for a service that is responsible for sending notifications to the end-user.
type AlertsSenderMock ¶
AlertsSenderMock is an autogenerated mock type for the AlertsSender type
func (*AlertsSenderMock) EXPECT ¶
func (_m *AlertsSenderMock) EXPECT() *AlertsSenderMock_Expecter
func (*AlertsSenderMock) Send ¶
func (_m *AlertsSenderMock) Send(key models.AlertRuleKey, alerts definitions.PostableAlerts)
Send provides a mock function with given fields: key, alerts
type AlertsSenderMock_Expecter ¶
type AlertsSenderMock_Expecter struct {
// contains filtered or unexported fields
}
func (*AlertsSenderMock_Expecter) Send ¶
func (_e *AlertsSenderMock_Expecter) Send(key interface{}, alerts interface{}) *AlertsSenderMock_Send_Call
Send is a helper method to define mock.On call
- key models.AlertRuleKey
- alerts definitions.PostableAlerts
type AlertsSenderMock_Send_Call ¶
AlertsSenderMock_Send_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Send'
func (*AlertsSenderMock_Send_Call) Return ¶
func (_c *AlertsSenderMock_Send_Call) Return() *AlertsSenderMock_Send_Call
func (*AlertsSenderMock_Send_Call) Run ¶
func (_c *AlertsSenderMock_Send_Call) Run(run func(key models.AlertRuleKey, alerts definitions.PostableAlerts)) *AlertsSenderMock_Send_Call
type RulesStore ¶
type RulesStore interface { GetAlertRulesKeysForScheduling(ctx context.Context) ([]ngmodels.AlertRuleKeyWithVersion, error) GetAlertRulesForScheduling(ctx context.Context, query *ngmodels.GetAlertRulesForSchedulingQuery) error }
RulesStore is a store that provides alert rules for scheduling
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 }
ScheduleService is an interface for a service that schedules the evaluation of alert rules.
type SchedulerCfg ¶
type SchedulerCfg struct { MaxAttempts int64 BaseInterval time.Duration C clock.Clock MinRuleInterval time.Duration DisableGrafanaFolder bool AppURL *url.URL EvaluatorFactory eval.EvaluatorFactory RuleStore RulesStore Metrics *metrics.Scheduler AlertSender AlertsSender Tracer tracing.Tracer }
SchedulerCfg is the scheduler configuration.