unify loki settings
This commit is contained in:
8 files changed
+162
-153
No files matched your search
@@ -183,29 +183,7 @@ type UnifiedAlertingPrometheusConversionSettings struct {
|
||||
RuleQueryOffset time.Duration
|
||||
}
|
||||
|
||||
type UnifiedAlertingStateHistorySettings struct {
|
||||
Enabled bool
|
||||
Backend string
|
||||
LokiRemoteURL string
|
||||
LokiReadURL string
|
||||
LokiWriteURL string
|
||||
LokiTenantID string
|
||||
// LokiBasicAuthUsername and LokiBasicAuthPassword are used for basic auth
|
||||
// if one of them is set.
|
||||
LokiBasicAuthPassword string
|
||||
LokiBasicAuthUsername string
|
||||
LokiMaxQueryLength time.Duration
|
||||
LokiMaxQuerySize int
|
||||
PrometheusMetricName string
|
||||
PrometheusTargetDatasourceUID string
|
||||
PrometheusWriteTimeout time.Duration
|
||||
MultiPrimary string
|
||||
MultiSecondaries []string
|
||||
ExternalLabels map[string]string
|
||||
}
|
||||
|
||||
type UnifiedAlertingNotificationHistorySettings struct {
|
||||
Enabled bool
|
||||
type UnifiedAlertingLokiSettings struct {
|
||||
LokiRemoteURL string
|
||||
LokiReadURL string
|
||||
LokiWriteURL string
|
||||
@@ -219,6 +197,23 @@ type UnifiedAlertingNotificationHistorySettings struct {
|
||||
ExternalLabels map[string]string
|
||||
}
|
||||
|
||||
type UnifiedAlertingStateHistorySettings struct {
|
||||
Enabled bool
|
||||
Backend string
|
||||
LokiSettings UnifiedAlertingLokiSettings
|
||||
PrometheusMetricName string
|
||||
PrometheusTargetDatasourceUID string
|
||||
PrometheusWriteTimeout time.Duration
|
||||
MultiPrimary string
|
||||
MultiSecondaries []string
|
||||
ExternalLabels map[string]string
|
||||
}
|
||||
|
||||
type UnifiedAlertingNotificationHistorySettings struct {
|
||||
Enabled bool
|
||||
LokiSettings UnifiedAlertingLokiSettings
|
||||
}
|
||||
|
||||
// IsEnabled returns true if UnifiedAlertingSettings.Enabled is either nil or true.
|
||||
// It hides the implementation details of the Enabled and simplifies its usage.
|
||||
func (u *UnifiedAlertingSettings) IsEnabled() bool {
|
||||
@@ -470,16 +465,18 @@ func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error {
|
||||
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"),
|
||||
LokiRemoteURL: stateHistory.Key("loki_remote_url").MustString(""),
|
||||
LokiReadURL: stateHistory.Key("loki_remote_read_url").MustString(""),
|
||||
LokiWriteURL: stateHistory.Key("loki_remote_write_url").MustString(""),
|
||||
LokiTenantID: stateHistory.Key("loki_tenant_id").MustString(""),
|
||||
LokiBasicAuthUsername: stateHistory.Key("loki_basic_auth_username").MustString(""),
|
||||
LokiBasicAuthPassword: stateHistory.Key("loki_basic_auth_password").MustString(""),
|
||||
LokiMaxQueryLength: stateHistory.Key("loki_max_query_length").MustDuration(lokiDefaultMaxQueryLength),
|
||||
LokiMaxQuerySize: stateHistory.Key("loki_max_query_size").MustInt(lokiDefaultMaxQuerySize),
|
||||
Enabled: stateHistory.Key("enabled").MustBool(stateHistoryDefaultEnabled),
|
||||
Backend: stateHistory.Key("backend").MustString("annotations"),
|
||||
LokiSettings: UnifiedAlertingLokiSettings{
|
||||
LokiRemoteURL: stateHistory.Key("loki_remote_url").MustString(""),
|
||||
LokiReadURL: stateHistory.Key("loki_remote_read_url").MustString(""),
|
||||
LokiWriteURL: stateHistory.Key("loki_remote_write_url").MustString(""),
|
||||
LokiTenantID: stateHistory.Key("loki_tenant_id").MustString(""),
|
||||
LokiBasicAuthUsername: stateHistory.Key("loki_basic_auth_username").MustString(""),
|
||||
LokiBasicAuthPassword: stateHistory.Key("loki_basic_auth_password").MustString(""),
|
||||
LokiMaxQueryLength: stateHistory.Key("loki_max_query_length").MustDuration(lokiDefaultMaxQueryLength),
|
||||
LokiMaxQuerySize: stateHistory.Key("loki_max_query_size").MustInt(lokiDefaultMaxQuerySize),
|
||||
},
|
||||
MultiPrimary: stateHistory.Key("primary").MustString(""),
|
||||
MultiSecondaries: splitTrim(stateHistory.Key("secondaries").MustString(""), ","),
|
||||
PrometheusMetricName: stateHistory.Key("prometheus_metric_name").MustString(defaultHistorianPrometheusMetricName),
|
||||
@@ -492,16 +489,18 @@ func (cfg *Cfg) ReadUnifiedAlertingSettings(iniFile *ini.File) error {
|
||||
notificationHistory := iniFile.Section("unified_alerting.notification_history")
|
||||
notificationHistoryLabels := iniFile.Section("unified_alerting.notification_history.external_labels")
|
||||
uaCfgNotificationHistory := UnifiedAlertingNotificationHistorySettings{
|
||||
Enabled: notificationHistory.Key("enabled").MustBool(notificationHistoryDefaultEnabled),
|
||||
LokiRemoteURL: notificationHistory.Key("loki_remote_url").MustString(""),
|
||||
LokiReadURL: notificationHistory.Key("loki_remote_read_url").MustString(""),
|
||||
LokiWriteURL: notificationHistory.Key("loki_remote_write_url").MustString(""),
|
||||
LokiTenantID: notificationHistory.Key("loki_tenant_id").MustString(""),
|
||||
LokiBasicAuthUsername: notificationHistory.Key("loki_basic_auth_username").MustString(""),
|
||||
LokiBasicAuthPassword: notificationHistory.Key("loki_basic_auth_password").MustString(""),
|
||||
LokiMaxQueryLength: notificationHistory.Key("loki_max_query_length").MustDuration(lokiDefaultMaxQueryLength),
|
||||
LokiMaxQuerySize: notificationHistory.Key("loki_max_query_size").MustInt(lokiDefaultMaxQuerySize),
|
||||
ExternalLabels: notificationHistoryLabels.KeysHash(),
|
||||
Enabled: notificationHistory.Key("enabled").MustBool(notificationHistoryDefaultEnabled),
|
||||
LokiSettings: UnifiedAlertingLokiSettings{
|
||||
LokiRemoteURL: notificationHistory.Key("loki_remote_url").MustString(""),
|
||||
LokiReadURL: notificationHistory.Key("loki_remote_read_url").MustString(""),
|
||||
LokiWriteURL: notificationHistory.Key("loki_remote_write_url").MustString(""),
|
||||
LokiTenantID: notificationHistory.Key("loki_tenant_id").MustString(""),
|
||||
LokiBasicAuthUsername: notificationHistory.Key("loki_basic_auth_username").MustString(""),
|
||||
LokiBasicAuthPassword: notificationHistory.Key("loki_basic_auth_password").MustString(""),
|
||||
LokiMaxQueryLength: notificationHistory.Key("loki_max_query_length").MustDuration(lokiDefaultMaxQueryLength),
|
||||
LokiMaxQuerySize: notificationHistory.Key("loki_max_query_size").MustInt(lokiDefaultMaxQuerySize),
|
||||
ExternalLabels: notificationHistoryLabels.KeysHash(),
|
||||
},
|
||||
}
|
||||
uaCfg.NotificationHistory = uaCfgNotificationHistory
|
||||
|
||||
|
||||
Reference in new issue
Block a user