mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/promrelabel: add relabeling tests when the source label is missing
This commit is contained in:
parent
2b2c58ecf8
commit
b6e8c1403a
1 changed files with 16 additions and 0 deletions
|
@ -115,6 +115,12 @@ func TestApplyRelabelConfigs(t *testing.T) {
|
|||
source_labels: ["foo"]
|
||||
target_label: "bar"
|
||||
regex: ".+"
|
||||
`, `{xxx="yyy"}`, false, `{xxx="yyy"}`)
|
||||
f(`
|
||||
- action: replace
|
||||
source_labels: ["foo"]
|
||||
target_label: "xxx"
|
||||
regex: ".+"
|
||||
`, `{xxx="yyy"}`, false, `{xxx="yyy"}`)
|
||||
})
|
||||
t.Run("replace-if-miss", func(t *testing.T) {
|
||||
|
@ -133,6 +139,16 @@ func TestApplyRelabelConfigs(t *testing.T) {
|
|||
target_label: "bar"
|
||||
replacement: "a-$1-b"
|
||||
`, `{xxx="yyy"}`, false, `{bar="a-yyy;-b",xxx="yyy"}`)
|
||||
f(`
|
||||
- action: replace
|
||||
source_labels: ["xxx", "foo"]
|
||||
target_label: "xxx"
|
||||
`, `{xxx="yyy"}`, false, `{xxx="yyy;"}`)
|
||||
f(`
|
||||
- action: replace
|
||||
source_labels: ["foo"]
|
||||
target_label: "xxx"
|
||||
`, `{xxx="yyy"}`, false, `{}`)
|
||||
})
|
||||
t.Run("replace-if-hit", func(t *testing.T) {
|
||||
f(`
|
||||
|
|
Loading…
Reference in a new issue