state

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: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ResendDelay = 30 * time.Second

Functions

func NewEvaluationValues

func NewEvaluationValues(m map[string]eval.NumberValueCapture) map[string]*float64

NewEvaluationValues returns the labels and values for each RefID in the capture.

Types

type AlertInstanceManager

type AlertInstanceManager interface {
	GetAll(orgID int64) []*State
	GetStatesForRuleUID(orgID int64, alertRuleUID string) []*State
}

AlertInstanceManager defines the interface for querying the current alert instances.

type Evaluation

type Evaluation struct {
	EvaluationTime  time.Time
	EvaluationState eval.State
	// Values contains the RefID and value of reduce and math expressions.
	// Classic conditions can have different values for the same RefID as they can include multiple conditions.
	// For these, we use the index of the condition in addition RefID as the key e.g. "A0, A1, A2, etc.".
	Values map[string]*float64
	// Condition is the refID specified as the condition in the alerting rule at the time of the evaluation.
	Condition string
}

type Manager

type Manager struct {
	ResendDelay time.Duration
	// contains filtered or unexported fields
}

func NewManager

func NewManager(logger log.Logger, metrics *metrics.State, externalURL *url.URL, ruleStore store.RuleStore,
	instanceStore store.InstanceStore, sqlStore sqlstore.Store) *Manager

func (*Manager) Close

func (st *Manager) Close()

func (*Manager) Get

func (st *Manager) Get(orgID int64, alertRuleUID, stateId string) (*State, error)

func (*Manager) GetAll

func (st *Manager) GetAll(orgID int64) []*State

func (*Manager) GetStatesForRuleUID

func (st *Manager) GetStatesForRuleUID(orgID int64, alertRuleUID string) []*State

func (*Manager) ProcessEvalResults

func (st *Manager) ProcessEvalResults(ctx context.Context, alertRule *ngModels.AlertRule, results eval.Results) []*State

func (*Manager) Put

func (st *Manager) Put(states []*State)

func (*Manager) RemoveByRuleUID

func (st *Manager) RemoveByRuleUID(orgID int64, ruleUID string)

RemoveByRuleUID deletes all entries in the state manager that match the given rule UID.

func (*Manager) ResetCache

func (st *Manager) ResetCache()

ResetCache is used to ensure a clean cache on startup.

func (*Manager) Warm

func (st *Manager) Warm(ctx context.Context)

type State

type State struct {
	AlertRuleUID         string
	OrgID                int64
	CacheId              string
	State                eval.State
	Resolved             bool
	Results              []Evaluation
	LastEvaluationString string
	StartsAt             time.Time
	EndsAt               time.Time
	LastEvaluationTime   time.Time
	EvaluationDuration   time.Duration
	LastSentAt           time.Time
	Annotations          map[string]string
	Labels               data.Labels
	Error                error
}

func (*State) Equals

func (a *State) Equals(b *State) bool

func (*State) GetLabels

func (a *State) GetLabels(opts ...ngModels.LabelOption) map[string]string

func (*State) GetLastEvaluationValuesForCondition

func (a *State) GetLastEvaluationValuesForCondition() map[string]float64

func (*State) NeedsSending

func (a *State) NeedsSending(resendDelay time.Duration) bool

func (*State) TrimResults

func (a *State) TrimResults(alertRule *ngModels.AlertRule)

Jump to

Keyboard shortcuts

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