alert

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlertWithInvalidDescription is the error with which Gatus will panic if an alert has an invalid character
	ErrAlertWithInvalidDescription = errors.New("alert description must not have \" or \\")
)

Functions

This section is empty.

Types

type Alert

type Alert struct {
	// Type of alert (required)
	Type Type `yaml:"type"`

	// Enabled defines whether the alert is enabled
	//
	// Use Alert.IsEnabled() to retrieve the value of this field.
	//
	// This is a pointer, because it is populated by YAML and we need to know whether it was explicitly set to a value
	// or not for provider.ParseWithDefaultAlert to work.
	Enabled *bool `yaml:"enabled,omitempty"`

	// FailureThreshold is the number of failures in a row needed before triggering the alert
	FailureThreshold int `yaml:"failure-threshold"`

	// Description of the alert. Will be included in the alert sent.
	//
	// This is a pointer, because it is populated by YAML and we need to know whether it was explicitly set to a value
	// or not for provider.ParseWithDefaultAlert to work.
	Description *string `yaml:"description"`

	// SendOnResolved defines whether to send a second notification when the issue has been resolved
	//
	// This is a pointer, because it is populated by YAML and we need to know whether it was explicitly set to a value
	// or not for provider.ParseWithDefaultAlert to work. Use Alert.IsSendingOnResolved() for a non-pointer
	SendOnResolved *bool `yaml:"send-on-resolved"`

	// SuccessThreshold defines how many successful executions must happen in a row before an ongoing incident is marked as resolved
	SuccessThreshold int `yaml:"success-threshold"`

	// ResolveKey is an optional field that is used by some providers (i.e. PagerDuty's dedup_key) to resolve
	// ongoing/triggered incidents
	ResolveKey string `yaml:"-"`

	// Triggered is used to determine whether an alert has been triggered. When an alert is resolved, this value
	// should be set back to false. It is used to prevent the same alert from going out twice.
	//
	// This value should only be modified if the provider.AlertProvider's Send function does not return an error for an
	// alert that hasn't been triggered yet. This doubles as a lazy retry. The reason why this behavior isn't also
	// applied for alerts that are already triggered and has become "healthy" again is to prevent a case where, for
	// some reason, the alert provider always returns errors when trying to send the resolved notification
	// (SendOnResolved).
	Triggered bool `yaml:"-"`
}

Alert is a core.Endpoint's alert configuration

func (Alert) GetDescription

func (alert Alert) GetDescription() string

GetDescription retrieves the description of the alert

func (Alert) IsEnabled

func (alert Alert) IsEnabled() bool

IsEnabled returns whether an alert is enabled or not Returns true if not set

func (Alert) IsSendingOnResolved

func (alert Alert) IsSendingOnResolved() bool

IsSendingOnResolved returns whether an alert is sending on resolve or not

func (*Alert) ValidateAndSetDefaults

func (alert *Alert) ValidateAndSetDefaults() error

ValidateAndSetDefaults validates the alert's configuration and sets the default value of fields that have one

type Type

type Type string

Type is the type of the alert. The value will generally be the name of the alert provider

const (
	// TypeCustom is the Type for the custom alerting provider
	TypeCustom Type = "custom"

	// TypeDiscord is the Type for the discord alerting provider
	TypeDiscord Type = "discord"

	// TypeEmail is the Type for the email alerting provider
	TypeEmail Type = "email"

	// TypeGitHub is the Type for the github alerting provider
	TypeGitHub Type = "github"

	// TypeGoogleChat is the Type for the googlechat alerting provider
	TypeGoogleChat Type = "googlechat"

	// TypeMatrix is the Type for the matrix alerting provider
	TypeMatrix Type = "matrix"

	// TypeMattermost is the Type for the mattermost alerting provider
	TypeMattermost Type = "mattermost"

	// TypeMessagebird is the Type for the messagebird alerting provider
	TypeMessagebird Type = "messagebird"

	// TypeNtfy is the Type for the ntfy alerting provider
	TypeNtfy Type = "ntfy"

	// TypeOpsgenie is the Type for the opsgenie alerting provider
	TypeOpsgenie Type = "opsgenie"

	// TypePagerDuty is the Type for the pagerduty alerting provider
	TypePagerDuty Type = "pagerduty"

	// TypePushover is the Type for the pushover alerting provider
	TypePushover Type = "pushover"

	// TypeSlack is the Type for the slack alerting provider
	TypeSlack Type = "slack"

	// TypeTeams is the Type for the teams alerting provider
	TypeTeams Type = "teams"

	// TypeTelegram is the Type for the telegram alerting provider
	TypeTelegram Type = "telegram"

	// TypeTwilio is the Type for the twilio alerting provider
	TypeTwilio Type = "twilio"
)

Jump to

Keyboard shortcuts

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