mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promrelabel: add tests for removing the specified {label="value"} pair
This commit is contained in:
parent
0969b446b3
commit
9a930720b3
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) {
|
||||
f(`
|
||||
- action: replace
|
||||
|
|
Loading…
Reference in a new issue