From a054446e2f45855df0ac39937084b7e810aba408 Mon Sep 17 00:00:00 2001 From: Brian Brazil Date: Thu, 16 Apr 2015 20:50:52 +0100 Subject: [PATCH] Correct example, need to specify variables like in bash. See http://golang.org/pkg/regexp/#Regexp.Expand --- README.md | 2 +- mapper_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 33ea0f3..c8db563 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ An example mapping configuration: name="signup_events" provider="$2" outcome="$3" - job="$1_server" + job="${1}_server" This would transform these example StatsD metrics into Prometheus metrics as follows: diff --git a/mapper_test.go b/mapper_test.go index 68d02c6..8c7a0e2 100644 --- a/mapper_test.go +++ b/mapper_test.go @@ -60,6 +60,34 @@ func TestMetricMapper(t *testing.T) { "foo.bar.baz": map[string]string{}, }, }, + // Config with bad regex reference. + { + config: ` + test.* + name="name" + label="$1_foo" + `, + mappings: map[string]map[string]string{ + "test.a": map[string]string{ + "name": "name", + "label": "", + }, + }, + }, + // Config with good regex reference. + { + config: ` + test.* + name="name" + label="${1}_foo" + `, + mappings: map[string]map[string]string{ + "test.a": map[string]string{ + "name": "name", + "label": "a_foo", + }, + }, + }, // Config with bad metric line. { config: `