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 <bjboreham@gmail.com>
pull/12304/head
Bryan Boreham 2 years ago
parent 3716326f3f
commit 123109e967

@ -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()

Loading…
Cancel
Save