Alerting: Add client configuration for remote Loki historian backend and test connection (#61114)

* Create loki client type and ping method

* Expose TestConnection on client

* Configure and ping Loki URL

* Close response body reader if present

* Add 30 second timeout

* Remove duplicate close
This commit is contained in:
Alexander Weaver
2023-01-17 13:58:52 -06:00
committed by GitHub
parent f6e3252c00
commit 1ac89ea040
4 changed files with 88 additions and 10 deletions

View File

@@ -101,8 +101,9 @@ type UnifiedAlertingReservedLabelSettings struct {
}
type UnifiedAlertingStateHistorySettings struct {
Enabled bool
Backend string
Enabled bool
Backend string
LokiRemoteURL string
}
// IsEnabled returns true if UnifiedAlertingSettings.Enabled is either nil or true.
@@ -313,8 +314,9 @@ func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error {
stateHistory := iniFile.Section("unified_alerting.state_history")
uaCfgStateHistory := UnifiedAlertingStateHistorySettings{
Enabled: stateHistory.Key("enabled").MustBool(stateHistoryDefaultEnabled),
Backend: stateHistory.Key("backend").MustString("annotations"),
Enabled: stateHistory.Key("enabled").MustBool(stateHistoryDefaultEnabled),
Backend: stateHistory.Key("backend").MustString("annotations"),
LokiRemoteURL: stateHistory.Key("loki_remote_url").MustString(""),
}
uaCfg.StateHistory = uaCfgStateHistory