Allow single-letter components in metric names

They are valid. Fixes #256.

Signed-off-by: Matthias Rampke <matthias@prometheus.io>
This commit is contained in:
Matthias Rampke 2020-05-29 07:45:22 +00:00
parent bd5e04d6e3
commit 44ae8f557c
No known key found for this signature in database
GPG key ID: F9AFF7F67ACE10BA
2 changed files with 24 additions and 1 deletions

View file

@ -27,7 +27,7 @@ import (
) )
var ( var (
statsdMetricRE = `[a-zA-Z_](-?[a-zA-Z0-9_])+` statsdMetricRE = `[a-zA-Z_](-?[a-zA-Z0-9_])*`
templateReplaceRE = `(\$\{?\d+\}?)` templateReplaceRE = `(\$\{?\d+\}?)`
metricLineRE = regexp.MustCompile(`^(\*\.|` + statsdMetricRE + `\.)+(\*|` + statsdMetricRE + `)$`) metricLineRE = regexp.MustCompile(`^(\*\.|` + statsdMetricRE + `\.)+(\*|` + statsdMetricRE + `)$`)

View file

@ -662,6 +662,29 @@ mappings:
`, `,
configBad: true, configBad: true,
}, },
{
config: `---
mappings:
- match: p.*.*.c.*
match_type: glob
name: issue_256
labels:
one: $1
two: $2
three: $3
`,
mappings: mappings{
{
statsdMetric: "p.one.two.c.three",
name: "issue_256",
labels: map[string]string{
"one": "one",
"two": "two",
"three": "three",
},
},
},
},
// Example from the README. // Example from the README.
{ {
config: ` config: `