[v9.4.x] Alerting: Configurable externalLabels for Loki state history (#62517)

Alerting: Configurable externalLabels for Loki state history (#62404)

* Add config option for external labels

* Remove redundant nilcheck

(cherry picked from commit b4682fe3cb)

Co-authored-by: Alexander Weaver <weaver.alex.d@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2023-01-30 15:34:40 -06:00
committed by GitHub
co-authored by Alexander Weaver
parent 48bd8ebe92
commit f39c46a1b5
3 changed files with 18 additions and 5 deletions
+3
View File
@@ -108,6 +108,7 @@ type UnifiedAlertingStateHistorySettings struct {
// if one of them is set.
LokiBasicAuthPassword string
LokiBasicAuthUsername string
ExternalLabels map[string]string
}
// IsEnabled returns true if UnifiedAlertingSettings.Enabled is either nil or true.
@@ -317,6 +318,7 @@ func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error {
uaCfg.ReservedLabels = uaCfgReservedLabels
stateHistory := iniFile.Section("unified_alerting.state_history")
stateHistoryLabels := iniFile.Section("unified_alerting.state_history.external_labels")
uaCfgStateHistory := UnifiedAlertingStateHistorySettings{
Enabled: stateHistory.Key("enabled").MustBool(stateHistoryDefaultEnabled),
Backend: stateHistory.Key("backend").MustString("annotations"),
@@ -324,6 +326,7 @@ func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error {
LokiTenantID: stateHistory.Key("loki_tenant_id").MustString(""),
LokiBasicAuthUsername: stateHistory.Key("loki_basic_auth_username").MustString(""),
LokiBasicAuthPassword: stateHistory.Key("loki_basic_auth_password").MustString(""),
ExternalLabels: stateHistoryLabels.KeysHash(),
}
uaCfg.StateHistory = uaCfgStateHistory