mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-29 10:41:00 +00:00
allow metrics with dashes when mapping
This commit is contained in:
parent
4270a5ed7e
commit
411b071f1f
2 changed files with 27 additions and 3 deletions
|
@ -24,8 +24,10 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
identifierRE = `[a-zA-Z_][a-zA-Z0-9_]+`
|
||||
metricLineRE = regexp.MustCompile(`^(\*\.|` + identifierRE + `\.)+(\*|` + identifierRE + `)$`)
|
||||
identifierRE = `[a-zA-Z_][a-zA-Z0-9_]+`
|
||||
statsdMetricRE = `[a-zA-Z_](-?[a-zA-Z0-9_])+`
|
||||
|
||||
metricLineRE = regexp.MustCompile(`^(\*\.|` + statsdMetricRE + `\.)+(\*|` + statsdMetricRE + `)$`)
|
||||
labelLineRE = regexp.MustCompile(`^(` + identifierRE + `)\s*=\s*"(.*)"$`)
|
||||
metricNameRE = regexp.MustCompile(`^` + identifierRE + `$`)
|
||||
)
|
||||
|
|
|
@ -35,6 +35,13 @@ func TestMetricMapper(t *testing.T) {
|
|||
result="$3"
|
||||
job="test_dispatcher"
|
||||
|
||||
test.my-dispatch-host01.name.dispatcher.*.*.*
|
||||
name="host_dispatch_events"
|
||||
processor="$1"
|
||||
action="$2"
|
||||
result="$3"
|
||||
job="test_dispatcher"
|
||||
|
||||
*.*
|
||||
name="catchall"
|
||||
first="$1"
|
||||
|
@ -50,6 +57,13 @@ func TestMetricMapper(t *testing.T) {
|
|||
"result": "succeeded",
|
||||
"job": "test_dispatcher",
|
||||
},
|
||||
"test.my-dispatch-host01.name.dispatcher.FooProcessor.send.succeeded": map[string]string{
|
||||
"name": "host_dispatch_events",
|
||||
"processor": "FooProcessor",
|
||||
"action": "send",
|
||||
"result": "succeeded",
|
||||
"job": "test_dispatcher",
|
||||
},
|
||||
"foo.bar": map[string]string{
|
||||
"name": "catchall",
|
||||
"first": "foo",
|
||||
|
@ -91,7 +105,7 @@ func TestMetricMapper(t *testing.T) {
|
|||
// Config with bad metric line.
|
||||
{
|
||||
config: `
|
||||
bad-metric-line.*.*
|
||||
bad--metric-line.*.*
|
||||
name="foo"
|
||||
`,
|
||||
configBad: true,
|
||||
|
@ -104,6 +118,14 @@ func TestMetricMapper(t *testing.T) {
|
|||
`,
|
||||
configBad: true,
|
||||
},
|
||||
// Config with bad label line.
|
||||
{
|
||||
config: `
|
||||
test.*.*
|
||||
name="foo-name"
|
||||
`,
|
||||
configBad: true,
|
||||
},
|
||||
// Config with bad metric name.
|
||||
{
|
||||
config: `
|
||||
|
|
Loading…
Reference in a new issue