Skip to content

Commit

Permalink
Merge pull request #309 from prometheus/mr/issue-256
Browse files Browse the repository at this point in the history
Allow single-letter components in metric names
  • Loading branch information
Matthias Rampke authored Jun 19, 2020
2 parents 7ba3550 + 44ae8f5 commit ed37775
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/mapper/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

var (
statsdMetricRE = `[a-zA-Z_](-?[a-zA-Z0-9_])+`
statsdMetricRE = `[a-zA-Z_](-?[a-zA-Z0-9_])*`
templateReplaceRE = `(\$\{?\d+\}?)`

metricLineRE = regexp.MustCompile(`^(\*\.|` + statsdMetricRE + `\.)+(\*|` + statsdMetricRE + `)$`)
Expand Down
23 changes: 23 additions & 0 deletions pkg/mapper/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,29 @@ mappings:
`,
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.
{
config: `
Expand Down

0 comments on commit ed37775

Please sign in to comment.