strategy

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelsKeyDatasourceID = "datasourceId"
	LabelsKeyRuleID       = "__alert_id__"
	LabelsKeyLevelID      = "__level_id__"
	LabelsKeyGroupID      = "groupID"
)

Variables

This section is empty.

Functions

func BuildDuration

func BuildDuration(duration string) time.Duration

BuildDuration 字符串转为api时间

Types

type EvalGroup

type EvalGroup struct {
	Name  string      `json:"name"`
	Rules []*EvalRule `json:"rules"`
}

func (*EvalGroup) GetName

func (g *EvalGroup) GetName() string

GetName get group name

func (*EvalGroup) GetRules

func (g *EvalGroup) GetRules() []*EvalRule

type EvalRule

type EvalRule struct {
	// ID 用作唯一标识
	ID          string            `json:"-"`
	Alert       string            `json:"alert"`
	Expr        string            `json:"expr"`
	For         string            `json:"for"`
	Labels      agent.Labels      `json:"labels"`
	Annotations agent.Annotations `json:"annotations"`
	// contains filtered or unexported fields
}

func (*EvalRule) Eval

func (e *EvalRule) Eval(ctx context.Context) ([]*agent.Alarm, error)

func (*EvalRule) ForEventsAt

func (e *EvalRule) ForEventsAt(startsAt time.Time) bool

ForEventsAt 断言eventsAt是否在for时间范围内

func (*EvalRule) GetAlert

func (e *EvalRule) GetAlert() string

GetAlert get alert name

func (*EvalRule) GetAnnotations

func (e *EvalRule) GetAnnotations() agent.Annotations

func (*EvalRule) GetDatasource

func (e *EvalRule) GetDatasource() agent.Datasource

func (*EvalRule) GetExpr

func (e *EvalRule) GetExpr() string

GetExpr get expr

func (*EvalRule) GetFor

func (e *EvalRule) GetFor() string

func (*EvalRule) GetID

func (e *EvalRule) GetID() string

GetID get rule id

func (*EvalRule) GetLabels

func (e *EvalRule) GetLabels() agent.Labels

func (*EvalRule) NewFiringAlarm

func (e *EvalRule) NewFiringAlarm(ctx context.Context, value *agent.QueryResponse) *agent.Alarm

NewFiringAlarm 创建告警

func (*EvalRule) NewFiringAlert

func (e *EvalRule) NewFiringAlert(_ context.Context, result *agent.Result) (*agent.Alert, bool)

NewFiringAlert 创建警报

func (*EvalRule) NewResolvedAlarm

func (e *EvalRule) NewResolvedAlarm(_ context.Context, firingAlarm *agent.Alarm) *agent.Alarm

NewResolvedAlarm 合并告警

func (*EvalRule) SetDatasource

func (e *EvalRule) SetDatasource(datasource agent.Datasource)

SetDatasource set datasource

func (*EvalRule) SetEventsAt

func (e *EvalRule) SetEventsAt(eventsAt time.Time)

SetEventsAt set events at

type Ruler

type Ruler interface {
	agent.Eval
	GetDatasource() agent.Datasource
}

Jump to

Keyboard shortcuts

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