diff --git a/conf/defaults.ini b/conf/defaults.ini index 005f7ec510c..7e6418f889c 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -1195,6 +1195,25 @@ loki_basic_auth_password = # ex. # mylabelkey = mylabelvalue +# NOTE: this configuration options are not used yet. +[remote.alertmanager] + +# Enable the use of the configured remote Alertmanager and disable the internal one. +# The default value is `false`. +enabled = false + +# URL of the remote Alertmanager that will replace the internal one. +# Required if `enabled` is set to `true`. +url = + +# Tenant ID to use in requests to the Alertmanager. +# It will also be used for the basic auth username. +tenant = + +# Optional password for basic authentication. +# If not present, the tenant ID will be set in the X-Scope-OrgID header. +password = + #################################### Alerting ############################ [alerting] # Enable the legacy alerting sub-system and interface. If Unified Alerting is already enabled and you try to go back to legacy alerting, all data that is part of Unified Alerting will be deleted. When this configuration section and flag are not defined, the state is defined at runtime. See the documentation for more details. diff --git a/pkg/setting/setting_unified_alerting.go b/pkg/setting/setting_unified_alerting.go index e6194f5d9d4..f8f7477640d 100644 --- a/pkg/setting/setting_unified_alerting.go +++ b/pkg/setting/setting_unified_alerting.go @@ -95,10 +95,20 @@ type UnifiedAlertingSettings struct { Screenshots UnifiedAlertingScreenshotSettings ReservedLabels UnifiedAlertingReservedLabelSettings StateHistory UnifiedAlertingStateHistorySettings + RemoteAlertmanager RemoteAlertmanagerSettings // MaxStateSaveConcurrency controls the number of goroutines (per rule) that can save alert state in parallel. MaxStateSaveConcurrency int } +// RemoteAlertmanagerSettings contains the configuration needed +// to disable the internal Alertmanager and use an external one instead. +type RemoteAlertmanagerSettings struct { + Enable bool + URL string + TenantID string + Password string +} + type UnifiedAlertingScreenshotSettings struct { Capture bool CaptureTimeout time.Duration @@ -337,6 +347,15 @@ func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error { uaCfg.DefaultRuleEvaluationInterval = uaMinInterval } + remoteAlertmanager := iniFile.Section("remote.alertmanager") + uaCfgRemoteAM := RemoteAlertmanagerSettings{ + Enable: remoteAlertmanager.Key("enabled").MustBool(false), + URL: remoteAlertmanager.Key("url").MustString(""), + TenantID: remoteAlertmanager.Key("tenant").MustString(""), + Password: remoteAlertmanager.Key("password").MustString(""), + } + uaCfg.RemoteAlertmanager = uaCfgRemoteAM + screenshots := iniFile.Section("unified_alerting.screenshots") uaCfgScreenshots := uaCfg.Screenshots