mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
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>
This commit is contained in:
parent
3716326f3f
commit
123109e967
|
@ -82,7 +82,7 @@ func Load(s string, expandExternalLabels bool, logger log.Logger) (*Config, erro
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
b := labels.ScratchBuilder{}
|
b := labels.NewScratchBuilder(0)
|
||||||
cfg.GlobalConfig.ExternalLabels.Range(func(v labels.Label) {
|
cfg.GlobalConfig.ExternalLabels.Range(func(v labels.Label) {
|
||||||
newV := os.Expand(v.Value, func(s string) string {
|
newV := os.Expand(v.Value, func(s string) string {
|
||||||
if s == "$" {
|
if s == "$" {
|
||||||
|
@ -97,6 +97,7 @@ func Load(s string, expandExternalLabels bool, logger log.Logger) (*Config, erro
|
||||||
if newV != v.Value {
|
if newV != v.Value {
|
||||||
level.Debug(logger).Log("msg", "External label replaced", "label", v.Name, "input", v.Value, "output", newV)
|
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)
|
b.Add(v.Name, newV)
|
||||||
})
|
})
|
||||||
cfg.GlobalConfig.ExternalLabels = b.Labels()
|
cfg.GlobalConfig.ExternalLabels = b.Labels()
|
||||||
|
|
Loading…
Reference in a new issue