model

package
v0.0.0-...-c092c37 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	// Executor of action: shell, jenkins, etc.
	Executor string `mapstructure:"executor"`

	// CommonParameters represents string for Config.CommonParameters map.
	CommonParameters string `mapstructure:"common_parameters"`

	// Parameters for TaskExecutor.
	Parameters map[string]interface{} `mapstructure:"parameters"`

	// Block time after action success execute.
	Block time.Duration `mapstructure:"block"`

	// TaskExecutor for this action.
	TaskExecutor executor.TaskExecutor `mapstructure:"-"`
}

Action describes direct action as an reaction of alert.

type Actions

type Actions []Action

Actions is a slice of Action.

type Alerts

type Alerts []alert

Alerts is a slice of Alert.

func (Alerts) ToTasksGroups

func (alerts Alerts) ToTasksGroups(rules Rules, eventID string) (tasksGroups TasksGroups)

ToTasksGroups converts alerts to tasks.

type Conditions

type Conditions struct {
	// AlertStatus is a status of alert. By default set by setDefaultAlertStatus() function.
	AlertStatus string `mapstructure:"alert_status"`

	// AlertLabels is a map label-value for match labels.
	AlertLabels map[string]string `mapstructure:"alert_labels"`

	// AlertLabelsRegexp is a compiled AlertLabels.
	AlertLabelsRegexp map[string]*regexp.Regexp `mapstructure:"-"`

	// AlertAnnotations is a map annotation-value for match annotations.
	AlertAnnotations map[string]string `mapstructure:"alert_annotations"`

	// AlertAnnotationsRegexp is a compiled AlertAnnotations.
	AlertAnnotationsRegexp map[string]*regexp.Regexp `mapstructure:"-"`
}

Conditions describes

type Payload

type Payload template.Data

Payload represents json structure of payload from Alertmanager.

func (Payload) ToAlerts

func (payload Payload) ToAlerts() (alerts Alerts)

ToAlerts converts payload to alerts.

type Rule

type Rule struct {
	// Name of the rule, used for metrics, logger.
	Name string `mapstructure:"name"`

	// Conditions for rule match.
	Conditions Conditions `mapstructure:"conditions"`

	// Actions is a slice of action.
	Actions Actions `mapstructure:"actions"`
}

Rule describes rule for alerts.

type Rules

type Rules []Rule

Rules is a slice of Rule.

func (Rules) Prepare

func (rules Rules) Prepare(commonParams map[string]map[string]interface{}, taskExecutors map[string]executor.TaskExecutor) error

Prepare prepares rules after config init.

type Tasks

type Tasks []executor.Task

Tasks is a slice of executor.Task.

func NewTasks

func NewTasks(rule Rule, alert alert, eventID string) Tasks

NewTasks creates for rule-alert pairs.

func (Tasks) Details

func (tasks Tasks) Details() []map[string]interface{}

Details gets details for all tasks.

type TasksGroups

type TasksGroups []Tasks

TasksGroups is a slice of Tasks.

func (TasksGroups) Details

func (tasksGroups TasksGroups) Details() [][]map[string]interface{}

Details gets details for all tasks groups.

Jump to

Keyboard shortcuts

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