From a72bf87e046eb1241b2969af3ece165db2ba9bd2 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 29 Oct 2022 04:33:34 +0300 Subject: [PATCH] lib/promrelabel: add a test from https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3251 Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3251 --- lib/promrelabel/relabel_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/promrelabel/relabel_test.go b/lib/promrelabel/relabel_test.go index 8c1d34064f..67caaad610 100644 --- a/lib/promrelabel/relabel_test.go +++ b/lib/promrelabel/relabel_test.go @@ -708,6 +708,18 @@ func TestApplyRelabelConfigs(t *testing.T) { source_labels: [xyz] `, `metric{xyz="foo$",a="b"}`, true, `metric{a="b",xyz="bar"}`) }) + t.Run("issue-3251", func(t *testing.T) { + f(` +- source_labels: [instance, container_label_com_docker_swarm_task_name] + separator: ';' + # regex: '(.*?)\..*;(.*?)\..*' + regex: '([^.]+).[^;]+;([^.]+).+' + replacement: '$2:$1' + target_label: container_label_com_docker_swarm_task_name + action: replace +`, `{instance="subdomain.domain.com",container_label_com_docker_swarm_task_name="myservice.h408nlaxmv8oqkn1pjjtd71to.nv987lz99rb27lkjjnfiay0g4"}`, true, +`{container_label_com_docker_swarm_task_name="myservice:subdomain",instance="subdomain.domain.com"}`) + }) } func TestFinalizeLabels(t *testing.T) {