metricalert

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopePerInstance = "per_instance"
	ScopeAggregate   = "aggregate"
	MatchAll         = "all"
	MatchAny         = "any"
	ReminderOnce     = "once"
	ReminderInterval = "repeat_interval"
)

Variables

View Source
var (
	ErrInvalidInput = errors.New("invalid metric alert input")
	ErrNotFound     = errors.New("metric alert rule not found")
)
View Source
var ErrDataUnavailable = errors.New("metric alert data unavailable")

Functions

func Audit

func Audit(actorID int, action string, resourceID int64, outcome string, details any)

func DeleteRule

func DeleteRule(id int64) error

func DueRules

func DueRules(now int64, limit int) ([]*model.MetricAlertRule, error)

func ErrorMessage

func ErrorMessage(err error) string

func TouchNextRun

func TouchNextRun(ruleID int64, now int64, interval int64) error

Types

type ConditionInput

type ConditionInput struct {
	Metric            string `json:"metric"`
	Operator          string `json:"operator"`
	Threshold         string `json:"threshold"`
	RecoveryThreshold string `json:"recovery_threshold"`
}

type EvaluationResult

type EvaluationResult struct {
	RuleID    int64              `json:"rule_id"`
	Scopes    int                `json:"scopes"`
	Triggered int                `json:"triggered"`
	Recovered int                `json:"recovered"`
	Values    map[string]float64 `json:"values,omitempty"`
}

func EvaluateRule

func EvaluateRule(ctx context.Context, ruleID int64) (*EvaluationResult, error)

type MetricDefinition

type MetricDefinition struct {
	Key          string   `json:"key"`
	Label        string   `json:"label"`
	Unit         string   `json:"unit"`
	Kinds        []string `json:"kinds"`
	Aggregatable bool     `json:"aggregatable"`
}

func Capabilities

func Capabilities(instanceIDs []int64, scopeMode string, access ...*authz.DataAccess) ([]MetricDefinition, error)

func MetricDefinitions

func MetricDefinitions() []MetricDefinition

type RuleInput

type RuleInput struct {
	Name                      string           `json:"name"`
	Description               string           `json:"description"`
	Enabled                   bool             `json:"enabled"`
	ScopeMode                 string           `json:"scope_mode"`
	MatchMode                 string           `json:"match_mode"`
	EvaluationIntervalSeconds int64            `json:"evaluation_interval_seconds"`
	TriggerCount              int              `json:"trigger_count"`
	RecoveryCount             int              `json:"recovery_count"`
	FailureThreshold          int              `json:"failure_threshold"`
	ReminderMode              string           `json:"reminder_mode"`
	RepeatIntervalSeconds     int64            `json:"repeat_interval_seconds"`
	Recipients                []string         `json:"recipients"`
	InstanceIDs               []int64          `json:"instance_ids"`
	Conditions                []ConditionInput `json:"conditions"`
}

type RuleView

type RuleView struct {
	model.MetricAlertRule
	Recipients  []string                      `json:"recipients"`
	InstanceIDs []int64                       `json:"instance_ids"`
	Conditions  []*model.MetricAlertCondition `json:"conditions"`
	States      []*model.MetricAlertState     `json:"states"`
}

func CreateRule

func CreateRule(input RuleInput, actorID int) (*RuleView, error)

func GetRule

func GetRule(id int64, access ...*authz.DataAccess) (*RuleView, error)

func ListRules

func ListRules(access ...*authz.DataAccess) ([]*RuleView, error)

func UpdateRule

func UpdateRule(id int64, input RuleInput, actorID int) (*RuleView, error)

Jump to

Keyboard shortcuts

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