mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promrelabel: make a copy of label with new name for action: labelmap
in the same way as Prometheus does
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/812
This commit is contained in:
parent
9a7c863bd8
commit
7505e4f390
3 changed files with 10 additions and 1 deletions
|
@ -206,8 +206,9 @@ func applyRelabelConfig(labels []prompbmarshal.Label, labelsOffset int, prc *Par
|
|||
}
|
||||
value := relabelBufPool.Get()
|
||||
value.B = prc.Regex.ExpandString(value.B[:0], prc.Replacement, label.Name, match)
|
||||
label.Name = string(value.B)
|
||||
labelName := string(value.B)
|
||||
relabelBufPool.Put(value)
|
||||
labels = setLabelValue(labels, labelsOffset, labelName, label.Value)
|
||||
}
|
||||
return labels
|
||||
case "labelmap_all":
|
||||
|
|
|
@ -575,6 +575,10 @@ func TestApplyRelabelConfigs(t *testing.T) {
|
|||
Name: "foo",
|
||||
Value: "yyy",
|
||||
},
|
||||
{
|
||||
Name: "foobar",
|
||||
Value: "aaa",
|
||||
},
|
||||
})
|
||||
})
|
||||
t.Run("labelmap_all", func(t *testing.T) {
|
||||
|
|
|
@ -920,6 +920,10 @@ scrape_configs:
|
|||
Name: "prefix:url",
|
||||
Value: "http://foo.bar:1234/metrics",
|
||||
},
|
||||
{
|
||||
Name: "url",
|
||||
Value: "http://foo.bar:1234/metrics",
|
||||
},
|
||||
},
|
||||
AuthConfig: &promauth.Config{},
|
||||
jobNameOriginal: "foo",
|
||||
|
|
Loading…
Reference in a new issue