From 9c1cde63be479798aaeb494450109bca4831eeac Mon Sep 17 00:00:00 2001 From: Brian Akins Date: Tue, 1 Aug 2017 07:07:44 -0400 Subject: [PATCH] simplify metric label key validation --- mapper.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mapper.go b/mapper.go index 6ea9e12..53ce4b2 100644 --- a/mapper.go +++ b/mapper.go @@ -145,9 +145,8 @@ func (m *metricMapper) initFromYAMLString(fileContents string) error { // Check that label is correct. for k, v := range currentMapping.Labels { - label := fmt.Sprintf("%s=%q", k, v) - if len(labelLineRE.FindStringSubmatch(label)) != 3 { - return fmt.Errorf("invalid label: %s: %s", k, v) + if !metricNameRE.MatchString(k) { + return fmt.Errorf("invalid label key: %s", k) } if k == "name" && !metricNameRE.MatchString(v) { return fmt.Errorf("metric name '%s' doesn't match regex '%s'", v, metricNameRE)