mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-22 23:41:00 +00:00
Merge pull request #24 from macb/allow_hyphen_hostname
allow metrics with dashes when mapping
This commit is contained in:
commit
28d4020341
2 changed files with 27 additions and 3 deletions
|
@ -25,7 +25,9 @@ import (
|
|||
|
||||
var (
|
||||
identifierRE = `[a-zA-Z_][a-zA-Z0-9_]+`
|
||||
metricLineRE = regexp.MustCompile(`^(\*\.|` + identifierRE + `\.)+(\*|` + identifierRE + `)$`)
|
||||
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