Skip to content

Commit 19d9ad6

Browse files
Add incident.io alerting
1 parent b8d84ee commit 19d9ad6

File tree

7 files changed

+47
-12
lines changed

7 files changed

+47
-12
lines changed

hack/diff-satellite.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jsonnet -c -J vendor -m diff/jsonnet-tmp \
1818
clusterName: 'fake-cluster',
1919
alerting: {
2020
pagerdutyRoutingKey: 'pd-routing-key',
21+
incidentIoURL: 'https://example.com/',
22+
incidentIoAuthToken: 'incident-io-token'
2123
slackOAuthToken: 'fake-key',
2224
2325
ide: {},

installer/pkg/components/alertmanager/configsecret.go

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const queryString = `{{ reReplaceAll "%22" "%5C%22" (index .Alerts 0).GeneratorU
1717
func configSecret(ctx *common.RenderContext) ([]runtime.Object, error) {
1818
var receivers []*config.Receiver
1919

20-
receivers = append(receivers, criticalReceiver(ctx))
20+
receivers = append(receivers, criticalReceivers(ctx)...)
2121
receivers = append(receivers, defaultReceivers(ctx)...)
2222
receivers = append(receivers, teamSlackReceivers(ctx)...)
2323
resolveTimeout, _ := model.ParseDuration("5m")
@@ -59,6 +59,14 @@ func configSecret(ctx *common.RenderContext) ([]runtime.Object, error) {
5959
func routes(ctx *common.RenderContext) []*config.Route {
6060
var routes []*config.Route
6161

62+
routes = append(routes, &config.Route{
63+
Receiver: "criticalReceiverIncidentIO",
64+
Match: map[string]string{
65+
"severity": "critical",
66+
},
67+
Continue: true,
68+
})
69+
6270
routes = append(routes, &config.Route{
6371
Receiver: "criticalReceiver",
6472
Match: map[string]string{
@@ -114,9 +122,11 @@ func inhibitRules() []*config.InhibitRule {
114122
return inhibitRules
115123
}
116124

117-
func criticalReceiver(ctx *common.RenderContext) *config.Receiver {
125+
func criticalReceivers(ctx *common.RenderContext) []*config.Receiver {
126+
var receivers []*config.Receiver
127+
118128
if ctx.Config.Alerting.PagerDutyRoutingKey != "" {
119-
return &config.Receiver{
129+
receivers = append(receivers, &config.Receiver{
120130
Name: "criticalReceiver",
121131
PagerdutyConfigs: []*config.PagerdutyConfig{
122132
{
@@ -138,9 +148,28 @@ func criticalReceiver(ctx *common.RenderContext) *config.Receiver {
138148
},
139149
},
140150
},
141-
}
142-
} else {
143-
return &config.Receiver{
151+
})
152+
}
153+
154+
if ctx.Config.Alerting.IncidentIoURL != "" && ctx.Config.Alerting.IncidentIoAuthToken != "" {
155+
receivers = append(receivers, &config.Receiver{
156+
Name: "criticalReceiverIncidentIO",
157+
WebhookConfigs: []*config.WebhookConfig{
158+
{
159+
VSendResolved: common.ToPointer(true),
160+
URL: ctx.Config.Alerting.IncidentIoURL,
161+
HTTPConfig: &config.HTTPClientConfig{
162+
Authorization: &config.Authorization{
163+
Credentials: ctx.Config.Alerting.IncidentIoAuthToken,
164+
},
165+
},
166+
},
167+
},
168+
})
169+
}
170+
171+
if len(receivers) == 0 {
172+
receivers = append(receivers, &config.Receiver{
144173
Name: "criticalReceiver",
145174
SlackConfigs: []*config.SlackConfig{
146175
{
@@ -158,8 +187,10 @@ func criticalReceiver(ctx *common.RenderContext) *config.Receiver {
158187
Actions: slackButtons(),
159188
},
160189
},
161-
}
190+
})
162191
}
192+
193+
return receivers
163194
}
164195

165196
func defaultReceivers(ctx *common.RenderContext) []*config.Receiver {

installer/pkg/config/alertmanagerconfig_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ type Receiver struct {
106106
OpsgenieConfigs []*opsgenieConfig `yaml:"opsgenie_configs,omitempty" json:"opsgenie_configs,omitempty"`
107107
PagerdutyConfigs []*PagerdutyConfig `yaml:"pagerduty_configs,omitempty" json:"pagerduty_configs,omitempty"`
108108
SlackConfigs []*SlackConfig `yaml:"slack_configs,omitempty" json:"slack_configs,omitempty"`
109-
WebhookConfigs []*webhookConfig `yaml:"webhook_configs,omitempty" json:"webhook_configs,omitempty"`
109+
WebhookConfigs []*WebhookConfig `yaml:"webhook_configs,omitempty" json:"webhook_configs,omitempty"`
110110
WeChatConfigs []*weChatConfig `yaml:"wechat_configs,omitempty" json:"wechat_config,omitempty"`
111111
EmailConfigs []*emailConfig `yaml:"email_configs,omitempty" json:"email_configs,omitempty"`
112112
PushoverConfigs []*pushoverConfig `yaml:"pushover_configs,omitempty" json:"pushover_configs,omitempty"`
@@ -115,7 +115,7 @@ type Receiver struct {
115115
TelegramConfigs []*telegramConfig `yaml:"telegram_configs,omitempty" json:"telegram_configs,omitempty"`
116116
}
117117

118-
type webhookConfig struct {
118+
type WebhookConfig struct {
119119
VSendResolved *bool `yaml:"send_resolved,omitempty" json:"send_resolved,omitempty"`
120120
URL string `yaml:"url,omitempty" json:"url,omitempty"`
121121
HTTPConfig *HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"`

installer/pkg/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ type Tracing struct {
8383

8484
type Alerting struct {
8585
PagerDutyRoutingKey string `json:"pagerdutyRoutingKey,omitempty"`
86+
IncidentIoURL string `json:"incidentIoURL,omitempty"`
87+
IncidentIoAuthToken string `json:"incidentIoAuthToken,omitempty"`
8688
SlackOAuthToken string `json:"slackOAuthToken"`
8789
GenericSlackChannel string `json:"genericSlackChannel"`
8890
TeamRoutes []TeamAlertingRoute `json:"teamRoutes,omitempty"`

monitoring-central/monitoring-central.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ local kubePrometheus =
112112
_config+: {
113113
alertmanagerClusterLabels: 'cluster',
114114
alertmanagerNameLabels: 'namespace,pod',
115-
alertmanagerCriticalIntegrationsRegEx: 'slack|pagerduty',
115+
alertmanagerCriticalIntegrationsRegEx: 'slack|pagerduty|webhook',
116116
},
117117
},
118118
},

monitoring-satellite/manifests/grafana/dashboardDefinitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35765,7 +35765,7 @@ items:
3576535765
"hide": 2,
3576635766
"includeAll": true,
3576735767
"name": "integration",
35768-
"query": "label_values(alertmanager_notifications_total{integration=~\"slack|pagerduty\"}, integration)",
35768+
"query": "label_values(alertmanager_notifications_total{integration=~\"slack|pagerduty|webhook\"}, integration)",
3576935769
"refresh": 2,
3577035770
"sort": 1,
3577135771
"type": "query"

monitoring-satellite/monitoring-satellite.libsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ local gitpod = import '../components/gitpod/gitpod.libsonnet';
3030
_config+: {
3131
alertmanagerClusterLabels: 'cluster',
3232
alertmanagerNameLabels: 'namespace,pod',
33-
alertmanagerCriticalIntegrationsRegEx: 'slack|pagerduty',
33+
alertmanagerCriticalIntegrationsRegEx: 'slack|pagerduty|webhook',
3434
},
3535
},
3636
},

0 commit comments

Comments
 (0)