From 123109e9679677e6497a98dd7a06e436e6abb729 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 30 Apr 2023 12:52:34 +0100 Subject: [PATCH] config: make work with SymbolTable labels Need a SymbolTable when we expand ExternalLabels. And we can't use labels.NewBuilder because we need to add blank values. Signed-off-by: Bryan Boreham --- config/config.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 7fa03a1445..e81ee8dd0b 100644 --- a/config/config.go +++ b/config/config.go @@ -82,7 +82,7 @@ func Load(s string, expandExternalLabels bool, logger log.Logger) (*Config, erro return cfg, nil } - b := labels.ScratchBuilder{} + b := labels.NewScratchBuilder(0) cfg.GlobalConfig.ExternalLabels.Range(func(v labels.Label) { newV := os.Expand(v.Value, func(s string) string { if s == "$" { @@ -97,6 +97,7 @@ func Load(s string, expandExternalLabels bool, logger log.Logger) (*Config, erro if newV != v.Value { level.Debug(logger).Log("msg", "External label replaced", "label", v.Name, "input", v.Value, "output", newV) } + // Note newV can be blank. https://github.com/prometheus/prometheus/issues/11024 b.Add(v.Name, newV) }) cfg.GlobalConfig.ExternalLabels = b.Labels()