mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-10 15:14:09 +00:00
lib/promrelabel: add tests for removing the specified {label="value"} pair
This commit is contained in:
parent
0d6cac112a
commit
60ffbcbb99
1 changed files with 50 additions and 0 deletions
|
@ -121,6 +121,56 @@ func TestApplyRelabelConfigs(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
t.Run("replace-remove-label-value-hit", func(t *testing.T) {
|
||||||
|
f(`
|
||||||
|
- action: replace
|
||||||
|
source_labels: ["foo"]
|
||||||
|
target_label: "foo"
|
||||||
|
regex: "xxx"
|
||||||
|
replacement: ""
|
||||||
|
`, []prompbmarshal.Label{
|
||||||
|
{
|
||||||
|
Name: "foo",
|
||||||
|
Value: "xxx",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "bar",
|
||||||
|
Value: "baz",
|
||||||
|
},
|
||||||
|
}, false, []prompbmarshal.Label{
|
||||||
|
{
|
||||||
|
Name: "bar",
|
||||||
|
Value: "baz",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
t.Run("replace-remove-label-value-miss", func(t *testing.T) {
|
||||||
|
f(`
|
||||||
|
- action: replace
|
||||||
|
source_labels: ["foo"]
|
||||||
|
target_label: "foo"
|
||||||
|
regex: "xxx"
|
||||||
|
replacement: ""
|
||||||
|
`, []prompbmarshal.Label{
|
||||||
|
{
|
||||||
|
Name: "foo",
|
||||||
|
Value: "yyy",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "bar",
|
||||||
|
Value: "baz",
|
||||||
|
},
|
||||||
|
}, false, []prompbmarshal.Label{
|
||||||
|
{
|
||||||
|
Name: "bar",
|
||||||
|
Value: "baz",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "foo",
|
||||||
|
Value: "yyy",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
t.Run("replace-hit-target-label-with-capture-group", func(t *testing.T) {
|
t.Run("replace-hit-target-label-with-capture-group", func(t *testing.T) {
|
||||||
f(`
|
f(`
|
||||||
- action: replace
|
- action: replace
|
||||||
|
|
Loading…
Reference in a new issue