Alerting: Move alertmanager default config to UnifiedAlertingSettings (#39597)

This commit is contained in:
Yuriy Tseretyan
2021-09-23 13:52:20 -04:00
committed by GitHub
parent 01deae2105
commit 05eb30e323
3 changed files with 30 additions and 28 deletions
+25
View File
@@ -17,6 +17,28 @@ const (
AlertmanagerDefaultPushPullInterval = cluster.DefaultPushPullInterval
SchedulerDefaultAdminConfigPollInterval = 60 * time.Second
AlertmanagerDefaultConfigPollInterval = 60 * time.Second
// To start, the alertmanager needs at least one route defined.
// TODO: we should move this to Grafana settings and define this as the default.
AlertmanagerDefaultConfiguration = `{
"alertmanager_config": {
"route": {
"receiver": "grafana-default-email"
},
"receivers": [{
"name": "grafana-default-email",
"grafana_managed_receiver_configs": [{
"uid": "",
"name": "email receiver",
"type": "email",
"isDefault": true,
"settings": {
"addresses": "<example@email.com>"
}
}]
}]
}
}
`
)
type UnifiedAlertingSettings struct {
@@ -28,6 +50,7 @@ type UnifiedAlertingSettings struct {
HAPeerTimeout time.Duration
HAGossipInterval time.Duration
HAPushPullInterval time.Duration
DefaultConfiguration string
}
func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error {
@@ -64,6 +87,8 @@ func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error {
uaCfg.HAPeers = append(uaCfg.HAPeers, peer)
}
}
// TODO load from ini file
uaCfg.DefaultConfiguration = AlertmanagerDefaultConfiguration
cfg.UnifiedAlerting = uaCfg
return nil
}