Alerting: Add basic auth options to historian args (#114880)

This commit is contained in:
Steve Simpson
2025-12-04 22:56:07 +01:00
committed by GitHub
parent f07cc211bd
commit 4969df8a83
2 changed files with 16 additions and 5 deletions
@@ -67,6 +67,9 @@ func (v urlVar) Type() string {
func addLokiFlags(l *lokiclient.LokiConfig, prefix string, flags *pflag.FlagSet) {
flags.Var(urlVar{&l.ReadPathURL}, prefix+".read-url", "URL to Loki instance for performing queries")
flags.StringVar(&l.BasicAuthUser, prefix+".user", "", "Basic auth Username to authenticate to the Loki instance")
flags.StringVar(&l.BasicAuthPassword, prefix+".password", "", "Basic auth password to authenticate to the Loki instance")
flags.StringVar(&l.TenantID, prefix+".tenant-id", "", "Value to use for X-Scope-OrgID")
flags.DurationVar(&l.MaxQueryLength, prefix+".max-query-length", lokiDefaultMaxQueryLength, "Maximum allowed time range for queries")
flags.IntVar(&l.MaxQuerySize, prefix+".max-query-size", lokiDefaultMaxQuerySize, "Maximum allowed size of a query string passed to Loki")
}
@@ -47,15 +47,23 @@ func TestRuntimeConfig(t *testing.T) {
},
},
{
name: "with loki read url",
args: []string{"--alerting.historian.notification.loki.read-url=http://localhost:3100"},
name: "with loki options",
args: []string{
"--alerting.historian.notification.loki.read-url=http://localhost:3100",
"--alerting.historian.notification.loki.user=foo",
"--alerting.historian.notification.loki.password=bar",
"--alerting.historian.notification.loki.tenant-id=baz",
},
expected: RuntimeConfig{
Notification: NotificationConfig{
Enabled: false,
Loki: lokiclient.LokiConfig{
ReadPathURL: lokiURL,
MaxQueryLength: 721 * time.Hour,
MaxQuerySize: 65536,
ReadPathURL: lokiURL,
BasicAuthUser: "foo",
BasicAuthPassword: "bar",
TenantID: "baz",
MaxQueryLength: 721 * time.Hour,
MaxQuerySize: 65536,
},
},
},