Documentation ¶
Index ¶
- type Alert
- type Channel
- type ConditionOption
- func Avg(refID string, from string, to string) ConditionOption
- func Count(refID string, from string, to string) ConditionOption
- func Diff(refID string, from string, to string) ConditionOption
- func HasNoValue() ConditionOption
- func IsAbove(value float64) ConditionOption
- func IsBelow(value float64) ConditionOption
- func IsOutsideRange(min float64, max float64) ConditionOption
- func IsWithinRange(min float64, max float64) ConditionOption
- func Last(refID string, from string, to string) ConditionOption
- func Max(refID string, from string, to string) ConditionOption
- func Median(refID string, from string, to string) ConditionOption
- func Min(refID string, from string, to string) ConditionOption
- func PercentDiff(refID string, from string, to string) ConditionOption
- func Sum(refID string, from string, to string) ConditionOption
- type ErrorMode
- type NoDataMode
- type Operator
- type Option
- func EvaluateEvery(interval string) Option
- func For(duration string) Option
- func If(operator Operator, opts ...ConditionOption) Option
- func Message(content string) Option
- func Notify(channel *Channel) Option
- func NotifyChannel(channel int64) Option
- func OnExecutionError(mode ErrorMode) Option
- func OnNoData(mode NoDataMode) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 ¶
EvaluateEvery defines the evaluation interval.
func For ¶
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 NotifyChannel ¶ added in v0.5.4
NotifyChannel adds a notification for this alert given a channel ID.
func OnExecutionError ¶
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