2020-08-20 01:41:01 +02:00
|
|
|
package core
|
|
|
|
|
2020-08-22 20:15:44 +02:00
|
|
|
// Alert is the service's alert configuration
|
2020-08-20 01:41:01 +02:00
|
|
|
type Alert struct {
|
2020-08-22 20:15:44 +02:00
|
|
|
// Type of alert
|
|
|
|
Type AlertType `yaml:"type"`
|
|
|
|
|
|
|
|
// Enabled defines whether or not the alert is enabled
|
|
|
|
Enabled bool `yaml:"enabled"`
|
|
|
|
|
2020-09-17 02:22:33 +02:00
|
|
|
// FailureThreshold is the number of failures in a row needed before triggering the alert
|
|
|
|
FailureThreshold int `yaml:"failure-threshold"`
|
2020-08-22 20:15:44 +02:00
|
|
|
|
|
|
|
// Description of the alert. Will be included in the alert sent.
|
|
|
|
Description string `yaml:"description"`
|
2020-09-05 00:23:56 +02:00
|
|
|
|
|
|
|
// SendOnResolved defines whether to send a second notification when the issue has been resolved
|
|
|
|
SendOnResolved bool `yaml:"send-on-resolved"`
|
2020-09-17 01:26:19 +02:00
|
|
|
|
2020-09-17 02:22:33 +02:00
|
|
|
// SuccessThreshold defines how many successful executions must happen in a row before an ongoing incident is marked as resolved
|
|
|
|
SuccessThreshold int `yaml:"success-threshold"`
|
2020-09-17 01:26:19 +02:00
|
|
|
|
|
|
|
// ResolveKey is an optional field that is used by some providers (i.e. PagerDuty's dedup_key) to resolve
|
|
|
|
// ongoing/triggered incidents
|
|
|
|
ResolveKey string
|
|
|
|
|
|
|
|
// 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.
|
2021-01-21 22:14:32 +01:00
|
|
|
//
|
|
|
|
// 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).
|
2020-09-17 01:26:19 +02:00
|
|
|
Triggered bool
|
2020-08-20 01:41:01 +02:00
|
|
|
}
|
|
|
|
|
2020-10-23 21:58:59 +02:00
|
|
|
// AlertType is the type of the alert.
|
|
|
|
// The value will generally be the name of the alert provider
|
2020-08-20 01:41:01 +02:00
|
|
|
type AlertType string
|
|
|
|
|
|
|
|
const (
|
2021-03-05 03:26:17 +01:00
|
|
|
// CustomAlert is the AlertType for the custom alerting provider
|
|
|
|
CustomAlert AlertType = "custom"
|
|
|
|
|
|
|
|
// DiscordAlert is the AlertType for the discord alerting provider
|
|
|
|
DiscordAlert AlertType = "discord"
|
2020-10-23 21:58:59 +02:00
|
|
|
|
2020-11-14 15:55:37 +01:00
|
|
|
// MattermostAlert is the AlertType for the mattermost alerting provider
|
|
|
|
MattermostAlert AlertType = "mattermost"
|
|
|
|
|
2020-11-23 22:20:06 +01:00
|
|
|
// MessagebirdAlert is the AlertType for the messagebird alerting provider
|
|
|
|
MessagebirdAlert AlertType = "messagebird"
|
|
|
|
|
2020-10-23 21:58:59 +02:00
|
|
|
// PagerDutyAlert is the AlertType for the pagerduty alerting provider
|
2020-09-17 01:26:19 +02:00
|
|
|
PagerDutyAlert AlertType = "pagerduty"
|
2020-10-23 21:58:59 +02:00
|
|
|
|
2021-03-05 03:26:17 +01:00
|
|
|
// SlackAlert is the AlertType for the slack alerting provider
|
|
|
|
SlackAlert AlertType = "slack"
|
|
|
|
|
2020-10-23 21:58:59 +02:00
|
|
|
// TwilioAlert is the AlertType for the twilio alerting provider
|
|
|
|
TwilioAlert AlertType = "twilio"
|
2020-08-20 01:41:01 +02:00
|
|
|
)
|