Alerting: Add configuration options to migrate to an external Alertmanager (#71318)

* add configuration options to .ini file and parse them

* updates on config options, add external AM config to the main config struct

* separate external AM configs from general alerting configs, naming

* comments about usage of tenantID in basic auth & not using config options yet
This commit is contained in:
Santiago
2023-09-05 11:24:35 -03:00
committed by GitHub
parent 2e67a9463d
commit 7a34cdb3a2
2 changed files with 38 additions and 0 deletions

View File

@@ -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.

View File

@@ -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