ngalert

package
v0.0.0-...-900be4e Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertDefinition

type AlertDefinition struct {
	ID              int64             `xorm:"pk autoincr 'id'" json:"id"`
	OrgID           int64             `xorm:"org_id" json:"orgId"`
	Title           string            `json:"title"`
	Condition       string            `json:"condition"`
	Data            []eval.AlertQuery `json:"data"`
	Updated         time.Time         `json:"updated"`
	IntervalSeconds int64             `json:"intervalSeconds"`
	Version         int64             `json:"version"`
	UID             string            `xorm:"uid" json:"uid"`
	Paused          bool              `json:"paused"`
}

AlertDefinition is the model for alert definitions in Alerting NG.

type AlertDefinitionVersion

type AlertDefinitionVersion struct {
	ID                 int64  `xorm:"pk autoincr 'id'"`
	AlertDefinitionID  int64  `xorm:"alert_definition_id"`
	AlertDefinitionUID string `xorm:"alert_definition_uid"`
	ParentVersion      int64
	RestoredFrom       int64
	Version            int64

	Created         time.Time
	Title           string
	Condition       string
	Data            []eval.AlertQuery
	IntervalSeconds int64
}

AlertDefinitionVersion is the model for alert definition versions in Alerting NG.

type AlertInstance

type AlertInstance struct {
	DefinitionOrgID   int64  `xorm:"def_org_id"`
	DefinitionUID     string `xorm:"def_uid"`
	Labels            InstanceLabels
	LabelsHash        string
	CurrentState      InstanceStateType
	CurrentStateSince time.Time
	LastEvalTime      time.Time
}

AlertInstance represents a single alert instance.

type AlertNG

type AlertNG struct {
	Cfg             *setting.Cfg             `inject:""`
	DatasourceCache datasources.CacheService `inject:""`
	RouteRegister   routing.RouteRegister    `inject:""`
	SQLStore        *sqlstore.SQLStore       `inject:""`
	// contains filtered or unexported fields
}

AlertNG is the service for evaluating the condition of an alert definition.

func (*AlertNG) AddMigration

func (ng *AlertNG) AddMigration(mg *migrator.Migrator)

AddMigration defines database migrations. If Alerting NG is not enabled does nothing.

func (*AlertNG) Init

func (ng *AlertNG) Init() error

Init initializes the AlertingService.

func (*AlertNG) IsDisabled

func (ng *AlertNG) IsDisabled() bool

IsDisabled returns true if the alerting service is disable for this instance.

func (*AlertNG) Run

func (ng *AlertNG) Run(ctx context.Context) error

Run starts the scheduler

type InstanceLabels

type InstanceLabels data.Labels

InstanceLabels is an extension to data.Labels with methods for database serialization.

func (*InstanceLabels) FromDB

func (il *InstanceLabels) FromDB(b []byte) error

FromDB loads labels stored in the database as json tuples into InstanceLabels. FromDB is part of the xorm Conversion interface.

func (*InstanceLabels) StringAndHash

func (il *InstanceLabels) StringAndHash() (string, string, error)

StringAndHash returns a the json representation of the labels as tuples sorted by key. It also returns the a hash of that representation.

func (*InstanceLabels) ToDB

func (il *InstanceLabels) ToDB() ([]byte, error)

ToDB is not implemented as serialization is handled with manual SQL queries). ToDB is part of the xorm Conversion interface.

type InstanceStateType

type InstanceStateType string

InstanceStateType is an enum for instance states.

const (
	// InstanceStateFiring is for a firing alert.
	InstanceStateFiring InstanceStateType = "Alerting"
	// InstanceStateNormal is for a normal alert.
	InstanceStateNormal InstanceStateType = "Normal"
)

func (InstanceStateType) IsValid

func (i InstanceStateType) IsValid() bool

IsValid checks that the value of InstanceStateType is a valid string.

Directories

Path Synopsis
Package eval executes the condition for an alert definition, evaluates the condition results, and returns the alert instance states.
Package eval executes the condition for an alert definition, evaluates the condition results, and returns the alert instance states.

Jump to

Keyboard shortcuts

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