mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-27 02:14:38 +01:00
fix!: Default Alert.Enabled to true (#380)
BREAKING CHANGE: It used to default to false, which meant that users had to explicitly set endpoints[].alerts[].enabled to true
This commit is contained in:
parent
7dccf5f08c
commit
d058d7a54b
@ -7,10 +7,9 @@ endpoints:
|
|||||||
- name: example
|
- name: example
|
||||||
url: https://example.org
|
url: https://example.org
|
||||||
interval: 1m
|
interval: 1m
|
||||||
alerts:
|
|
||||||
- type: mattermost
|
|
||||||
enabled: true
|
|
||||||
description: "health check failed 3 times in a row"
|
|
||||||
send-on-resolved: true
|
|
||||||
conditions:
|
conditions:
|
||||||
- "[STATUS] == 200"
|
- "[STATUS] == 200"
|
||||||
|
alerts:
|
||||||
|
- type: mattermost
|
||||||
|
description: "health check failed 3 times in a row"
|
||||||
|
send-on-resolved: true
|
||||||
|
22
README.md
22
README.md
@ -179,7 +179,7 @@ If you want to test it locally, see [Docker](#docker).
|
|||||||
| `endpoints[].dns.query-type` | Query type (e.g. MX) | `""` |
|
| `endpoints[].dns.query-type` | Query type (e.g. MX) | `""` |
|
||||||
| `endpoints[].dns.query-name` | Query name (e.g. example.com) | `""` |
|
| `endpoints[].dns.query-name` | Query name (e.g. example.com) | `""` |
|
||||||
| `endpoints[].alerts[].type` | Type of alert. <br />Valid types: `slack`, `discord`, `email`, `googlechat`, `pagerduty`, `twilio`, `mattermost`, `messagebird`, `teams` `custom`. | Required `""` |
|
| `endpoints[].alerts[].type` | Type of alert. <br />Valid types: `slack`, `discord`, `email`, `googlechat`, `pagerduty`, `twilio`, `mattermost`, `messagebird`, `teams` `custom`. | Required `""` |
|
||||||
| `endpoints[].alerts[].enabled` | Whether to enable the alert. | `false` |
|
| `endpoints[].alerts[].enabled` | Whether to enable the alert. | `true` |
|
||||||
| `endpoints[].alerts[].failure-threshold` | Number of failures in a row needed before triggering the alert. | `3` |
|
| `endpoints[].alerts[].failure-threshold` | Number of failures in a row needed before triggering the alert. | `3` |
|
||||||
| `endpoints[].alerts[].success-threshold` | Number of successes in a row before an ongoing incident is marked as resolved. | `2` |
|
| `endpoints[].alerts[].success-threshold` | Number of successes in a row before an ongoing incident is marked as resolved. | `2` |
|
||||||
| `endpoints[].alerts[].send-on-resolved` | Whether to send a notification once a triggered alert is marked as resolved. | `false` |
|
| `endpoints[].alerts[].send-on-resolved` | Whether to send a notification once a triggered alert is marked as resolved. | `false` |
|
||||||
@ -410,7 +410,6 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: discord
|
- type: discord
|
||||||
enabled: true
|
|
||||||
description: "healthcheck failed"
|
description: "healthcheck failed"
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
```
|
```
|
||||||
@ -457,7 +456,6 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: email
|
- type: email
|
||||||
enabled: true
|
|
||||||
description: "healthcheck failed"
|
description: "healthcheck failed"
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
|
|
||||||
@ -470,7 +468,6 @@ endpoints:
|
|||||||
- "[CERTIFICATE_EXPIRATION] > 48h"
|
- "[CERTIFICATE_EXPIRATION] > 48h"
|
||||||
alerts:
|
alerts:
|
||||||
- type: email
|
- type: email
|
||||||
enabled: true
|
|
||||||
description: "healthcheck failed"
|
description: "healthcheck failed"
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
```
|
```
|
||||||
@ -505,7 +502,6 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: googlechat
|
- type: googlechat
|
||||||
enabled: true
|
|
||||||
description: "healthcheck failed"
|
description: "healthcheck failed"
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
```
|
```
|
||||||
@ -537,7 +533,6 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: matrix
|
- type: matrix
|
||||||
enabled: true
|
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
description: "healthcheck failed"
|
description: "healthcheck failed"
|
||||||
```
|
```
|
||||||
@ -571,7 +566,6 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: mattermost
|
- type: mattermost
|
||||||
enabled: true
|
|
||||||
description: "healthcheck failed"
|
description: "healthcheck failed"
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
```
|
```
|
||||||
@ -608,7 +602,6 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: messagebird
|
- type: messagebird
|
||||||
enabled: true
|
|
||||||
failure-threshold: 3
|
failure-threshold: 3
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
description: "healthcheck failed"
|
description: "healthcheck failed"
|
||||||
@ -634,7 +627,6 @@ alerting:
|
|||||||
topic: "gatus-test-topic"
|
topic: "gatus-test-topic"
|
||||||
priority: 2
|
priority: 2
|
||||||
default-alert:
|
default-alert:
|
||||||
enabled: true
|
|
||||||
failure-threshold: 3
|
failure-threshold: 3
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
|
|
||||||
@ -711,7 +703,6 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: pagerduty
|
- type: pagerduty
|
||||||
enabled: true
|
|
||||||
failure-threshold: 3
|
failure-threshold: 3
|
||||||
success-threshold: 5
|
success-threshold: 5
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
@ -726,7 +717,6 @@ endpoints:
|
|||||||
- "[CERTIFICATE_EXPIRATION] > 48h"
|
- "[CERTIFICATE_EXPIRATION] > 48h"
|
||||||
alerts:
|
alerts:
|
||||||
- type: pagerduty
|
- type: pagerduty
|
||||||
enabled: true
|
|
||||||
failure-threshold: 3
|
failure-threshold: 3
|
||||||
success-threshold: 5
|
success-threshold: 5
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
@ -758,11 +748,9 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: slack
|
- type: slack
|
||||||
enabled: true
|
|
||||||
description: "healthcheck failed 3 times in a row"
|
description: "healthcheck failed 3 times in a row"
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
- type: slack
|
- type: slack
|
||||||
enabled: true
|
|
||||||
failure-threshold: 5
|
failure-threshold: 5
|
||||||
description: "healthcheck failed 5 times in a row"
|
description: "healthcheck failed 5 times in a row"
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
@ -804,7 +792,6 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: teams
|
- type: teams
|
||||||
enabled: true
|
|
||||||
description: "healthcheck failed"
|
description: "healthcheck failed"
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
|
|
||||||
@ -817,7 +804,6 @@ endpoints:
|
|||||||
- "[CERTIFICATE_EXPIRATION] > 48h"
|
- "[CERTIFICATE_EXPIRATION] > 48h"
|
||||||
alerts:
|
alerts:
|
||||||
- type: teams
|
- type: teams
|
||||||
enabled: true
|
|
||||||
description: "healthcheck failed"
|
description: "healthcheck failed"
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
```
|
```
|
||||||
@ -852,7 +838,6 @@ endpoints:
|
|||||||
- "[BODY].status == UP"
|
- "[BODY].status == UP"
|
||||||
alerts:
|
alerts:
|
||||||
- type: telegram
|
- type: telegram
|
||||||
enabled: true
|
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -889,7 +874,6 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: twilio
|
- type: twilio
|
||||||
enabled: true
|
|
||||||
failure-threshold: 5
|
failure-threshold: 5
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
description: "healthcheck failed"
|
description: "healthcheck failed"
|
||||||
@ -945,7 +929,6 @@ endpoints:
|
|||||||
- "[RESPONSE_TIME] < 300"
|
- "[RESPONSE_TIME] < 300"
|
||||||
alerts:
|
alerts:
|
||||||
- type: custom
|
- type: custom
|
||||||
enabled: true
|
|
||||||
failure-threshold: 10
|
failure-threshold: 10
|
||||||
success-threshold: 3
|
success-threshold: 3
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
@ -985,7 +968,6 @@ alerting:
|
|||||||
slack:
|
slack:
|
||||||
webhook-url: "https://hooks.slack.com/services/**********/**********/**********"
|
webhook-url: "https://hooks.slack.com/services/**********/**********/**********"
|
||||||
default-alert:
|
default-alert:
|
||||||
enabled: true
|
|
||||||
description: "health check failed"
|
description: "health check failed"
|
||||||
send-on-resolved: true
|
send-on-resolved: true
|
||||||
failure-threshold: 5
|
failure-threshold: 5
|
||||||
@ -1032,12 +1014,10 @@ alerting:
|
|||||||
slack:
|
slack:
|
||||||
webhook-url: "https://hooks.slack.com/services/**********/**********/**********"
|
webhook-url: "https://hooks.slack.com/services/**********/**********/**********"
|
||||||
default-alert:
|
default-alert:
|
||||||
enabled: true
|
|
||||||
failure-threshold: 3
|
failure-threshold: 3
|
||||||
pagerduty:
|
pagerduty:
|
||||||
integration-key: "********************************"
|
integration-key: "********************************"
|
||||||
default-alert:
|
default-alert:
|
||||||
enabled: true
|
|
||||||
failure-threshold: 5
|
failure-threshold: 5
|
||||||
|
|
||||||
endpoints:
|
endpoints:
|
||||||
|
@ -17,6 +17,8 @@ type Alert struct {
|
|||||||
|
|
||||||
// Enabled defines whether the alert is enabled
|
// 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
|
// 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.
|
// or not for provider.ParseWithDefaultAlert to work.
|
||||||
Enabled *bool `yaml:"enabled,omitempty"`
|
Enabled *bool `yaml:"enabled,omitempty"`
|
||||||
@ -77,10 +79,10 @@ func (alert Alert) GetDescription() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsEnabled returns whether an alert is enabled or not
|
// IsEnabled returns whether an alert is enabled or not
|
||||||
|
// Returns true if not set
|
||||||
func (alert Alert) IsEnabled() bool {
|
func (alert Alert) IsEnabled() bool {
|
||||||
if alert.Enabled == nil {
|
if alert.Enabled == nil {
|
||||||
// TODO: Default to true in v5.0.0 (unless default-alert.enabled is set to false)
|
return true
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
return *alert.Enabled
|
return *alert.Enabled
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,8 @@ func TestAlert_ValidateAndSetDefaults(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAlert_IsEnabled(t *testing.T) {
|
func TestAlert_IsEnabled(t *testing.T) {
|
||||||
if (Alert{Enabled: nil}).IsEnabled() {
|
if !(Alert{Enabled: nil}).IsEnabled() {
|
||||||
t.Error("alert.IsEnabled() should've returned false, because Enabled was set to nil")
|
t.Error("alert.IsEnabled() should've returned true, because Enabled was set to nil")
|
||||||
}
|
}
|
||||||
if value := false; (Alert{Enabled: &value}).IsEnabled() {
|
if value := false; (Alert{Enabled: &value}).IsEnabled() {
|
||||||
t.Error("alert.IsEnabled() should've returned false, because Enabled was set to false")
|
t.Error("alert.IsEnabled() should've returned false, because Enabled was set to false")
|
||||||
|
@ -448,26 +448,21 @@ endpoints:
|
|||||||
url: https://twin.sh/health
|
url: https://twin.sh/health
|
||||||
alerts:
|
alerts:
|
||||||
- type: slack
|
- type: slack
|
||||||
enabled: true
|
|
||||||
- type: pagerduty
|
- type: pagerduty
|
||||||
enabled: true
|
|
||||||
failure-threshold: 7
|
failure-threshold: 7
|
||||||
success-threshold: 5
|
success-threshold: 5
|
||||||
description: "Healthcheck failed 7 times in a row"
|
description: "Healthcheck failed 7 times in a row"
|
||||||
- type: mattermost
|
- type: mattermost
|
||||||
enabled: true
|
|
||||||
- type: messagebird
|
- type: messagebird
|
||||||
|
enabled: false
|
||||||
- type: discord
|
- type: discord
|
||||||
enabled: true
|
|
||||||
failure-threshold: 10
|
failure-threshold: 10
|
||||||
- type: telegram
|
- type: telegram
|
||||||
enabled: true
|
enabled: true
|
||||||
- type: twilio
|
- type: twilio
|
||||||
enabled: true
|
|
||||||
failure-threshold: 12
|
failure-threshold: 12
|
||||||
success-threshold: 15
|
success-threshold: 15
|
||||||
- type: teams
|
- type: teams
|
||||||
enabled: true
|
|
||||||
conditions:
|
conditions:
|
||||||
- "[STATUS] == 200"
|
- "[STATUS] == 200"
|
||||||
`))
|
`))
|
||||||
|
@ -372,8 +372,8 @@ func TestEndpoint_ValidateAndSetDefaults(t *testing.T) {
|
|||||||
if len(endpoint.Alerts) != 1 {
|
if len(endpoint.Alerts) != 1 {
|
||||||
t.Error("Endpoint should've had 1 alert")
|
t.Error("Endpoint should've had 1 alert")
|
||||||
}
|
}
|
||||||
if endpoint.Alerts[0].IsEnabled() {
|
if !endpoint.Alerts[0].IsEnabled() {
|
||||||
t.Error("Endpoint alert should've defaulted to disabled")
|
t.Error("Endpoint alert should've defaulted to true")
|
||||||
}
|
}
|
||||||
if endpoint.Alerts[0].SuccessThreshold != 2 {
|
if endpoint.Alerts[0].SuccessThreshold != 2 {
|
||||||
t.Error("Endpoint alert should've defaulted to a success threshold of 2")
|
t.Error("Endpoint alert should've defaulted to a success threshold of 2")
|
||||||
|
Loading…
Reference in New Issue
Block a user