alert

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Builder *sdk.Alert
}

Alert represents an alert that can be triggered by a query.

func New

func New(name string, options ...Option) *Alert

New creates a new alert.

type Channel

type Channel struct {
	ID   uint   `json:"id"`
	UID  string `json:"uid"`
	Name string `json:"Name"`
	Type string `json:"type"`
}

Channel represents an alert notification channel. See https://grafana.com/docs/grafana/latest/alerting/notifications/#notification-channel-setup

type ConditionOption

type ConditionOption func(condition *condition)

ConditionOption represents an option that can be used to configure a condition.

func Avg

func Avg(refID string, from string, to string) ConditionOption

Avg defines the query to execute and computes the average of the results. See https://grafana.com/docs/grafana/latest/alerting/rules/#query-condition-example

func Count

func Count(refID string, from string, to string) ConditionOption

Count defines the query to execute and counts the results. See https://grafana.com/docs/grafana/latest/alerting/rules/#query-condition-example

func Diff

func Diff(refID string, from string, to string) ConditionOption

Diff defines the query to execute. See https://grafana.com/docs/grafana/latest/alerting/rules/#query-condition-example

func HasNoValue

func HasNoValue() ConditionOption

HasNoValue will match queries returning no value.

func IsAbove

func IsAbove(value float64) ConditionOption

IsAbove will match queries returning a value above the given threshold.

func IsBelow

func IsBelow(value float64) ConditionOption

IsBelow will match queries returning a value below the given threshold.

func IsOutsideRange

func IsOutsideRange(min float64, max float64) ConditionOption

IsOutsideRange will match queries returning a value outside the given range.

func IsWithinRange

func IsWithinRange(min float64, max float64) ConditionOption

IsWithinRange will match queries returning a value within the given range.

func Last

func Last(refID string, from string, to string) ConditionOption

Last defines the query to execute and takes the last result. See https://grafana.com/docs/grafana/latest/alerting/rules/#query-condition-example

func Max

func Max(refID string, from string, to string) ConditionOption

Max defines the query to execute and takes the largest result. See https://grafana.com/docs/grafana/latest/alerting/rules/#query-condition-example

func Median

func Median(refID string, from string, to string) ConditionOption

Median defines the query to execute and computes the mediam of the results. See https://grafana.com/docs/grafana/latest/alerting/rules/#query-condition-example

func Min

func Min(refID string, from string, to string) ConditionOption

Min defines the query to execute and takes the smallest result. See https://grafana.com/docs/grafana/latest/alerting/rules/#query-condition-example

func PercentDiff

func PercentDiff(refID string, from string, to string) ConditionOption

PercentDiff defines the query to execute. See https://grafana.com/docs/grafana/latest/alerting/rules/#query-condition-example

func Sum

func Sum(refID string, from string, to string) ConditionOption

Sum defines the query to execute and computes the sum of the results. See https://grafana.com/docs/grafana/latest/alerting/rules/#query-condition-example

type ErrorMode

type ErrorMode string

ErrorMode represents the behavior of an alert in case of execution error.

const Alerting ErrorMode = "alerting"

Alerting will set the alert state to "alerting".

const LastState ErrorMode = "keep_state"

LastState will set the alert state to its previous state.

type NoDataMode

type NoDataMode string

NoDataMode represents the behavior of an alert when no data is returned by the query.

const Error NoDataMode = "alerting"

Error will set the alert state to "alerting".

const KeepLastState NoDataMode = "keep_state"

KeepLastState will set the alert state to its previous state.

const NoData NoDataMode = "no_data"

NoData will set the alert state to "no data".

const OK NoDataMode = "ok"

OK will set the alert state to "ok".

type Operator

type Operator string

Operator represents a logical operator used to chain conditions.

const And Operator = "and"

And chains conditions with a logical AND

const Or Operator = "or"

Or chains conditions with a logical OR

type Option

type Option func(alert *Alert)

Option represents an option that can be used to configure an alert.

func EvaluateEvery

func EvaluateEvery(interval string) Option

EvaluateEvery defines the evaluation interval.

func For

func For(duration string) Option

For sets the time interval during which a query violating the threshold before the alert being actually triggered. See https://grafana.com/docs/grafana/latest/alerting/rules/#for

func If

func If(operator Operator, opts ...ConditionOption) Option

If adds a condition that could trigger the alert. See https://grafana.com/docs/grafana/latest/alerting/rules/#conditions

func Message

func Message(content string) Option

Message sets the message associated to the alert.

func Notify added in v0.4.0

func Notify(channel *Channel) Option

Notify adds a notification for this alert given a channel.

func NotifyChannel added in v0.5.4

func NotifyChannel(channelUID string) Option

NotifyChannel adds a notification for this alert given a channel UID.

func NotifyChannels added in v0.12.2

func NotifyChannels(channels ...*Channel) Option

NotifyChannels appends the given notification channels to the list of channels for this alert.

func OnExecutionError

func OnExecutionError(mode ErrorMode) Option

OnExecutionError defines the behavior on execution error. See https://grafana.com/docs/grafana/latest/alerting/rules/#execution-errors-or-timeouts

func OnNoData

func OnNoData(mode NoDataMode) Option

OnNoData defines the behavior when the query returns no data. See https://grafana.com/docs/grafana/latest/alerting/rules/#no-data-null-values

func Tags added in v0.12.6

func Tags(tags map[string]string) Option

Tags defines a set of tags that will be forwarded to the notifications channels when the alert will tbe triggered.

Jump to

Keyboard shortcuts

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