diff --git a/config/config.go b/config/config.go index efd0b1f58..7b63c4061 100644 --- a/config/config.go +++ b/config/config.go @@ -31,7 +31,7 @@ var ( patFileSDName = regexp.MustCompile(`^[^*]*(\*[^/]*)?\.(json|yml|yaml|JSON|YML|YAML)$`) patRulePath = regexp.MustCompile(`^[^*]*(\*[^/]*)?$`) patAuthLine = regexp.MustCompile(`((?:password|bearer_token|secret_key|client_secret):\s+)(".+"|'.+'|[^\s]+)`) - relabelTarget = regexp.MustCompile(`^(?:(?:[a-zA-Z_]|\$\{?[\w]+}?)+\w*)+$`) + relabelTarget = regexp.MustCompile(`^(?:(?:[a-zA-Z_]|\$\{?[\w]+\}?)+\w*)+$`) ) // Load parses the YAML input s into a Config. diff --git a/config/config_test.go b/config/config_test.go index 38d885f33..a8cff5ddf 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -207,6 +207,17 @@ var expectedConf = &Config{ Scheme: DefaultConsulSDConfig.Scheme, }, }, + + RelabelConfigs: []*RelabelConfig{ + { + SourceLabels: model.LabelNames{"__meta_sd_consul_tags"}, + Regex: MustNewRegexp("label:([^=]+)=([^,]+)"), + Separator: ",", + TargetLabel: "${1}", + Replacement: "${2}", + Action: RelabelReplace, + }, + }, }, { JobName: "service-z", diff --git a/config/testdata/conf.good.yml b/config/testdata/conf.good.yml index a18deeddb..ab38a56fa 100644 --- a/config/testdata/conf.good.yml +++ b/config/testdata/conf.good.yml @@ -104,6 +104,13 @@ scrape_configs: - server: 'localhost:1234' services: ['nginx', 'cache', 'mysql'] + relabel_configs: + - source_labels: [__meta_sd_consul_tags] + separator: ',' + regex: label:([^=]+)=([^,]+) + target_label: ${1} + replacement: ${2} + - job_name: service-z tls_config: diff --git a/config/testdata/relabel_target_label.good.yml b/config/testdata/relabel_target_label.good.yml deleted file mode 100644 index e69de29bb..000000000