mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-22 15:30:59 +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
|
@ -24,8 +24,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
identifierRE = `[a-zA-Z_][a-zA-Z0-9_]+`
|
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*"(.*)"$`)
|
labelLineRE = regexp.MustCompile(`^(` + identifierRE + `)\s*=\s*"(.*)"$`)
|
||||||
metricNameRE = regexp.MustCompile(`^` + identifierRE + `$`)
|
metricNameRE = regexp.MustCompile(`^` + identifierRE + `$`)
|
||||||
)
|
)
|
||||||
|
|
|
@ -35,6 +35,13 @@ func TestMetricMapper(t *testing.T) {
|
||||||
result="$3"
|
result="$3"
|
||||||
job="test_dispatcher"
|
job="test_dispatcher"
|
||||||
|
|
||||||
|
test.my-dispatch-host01.name.dispatcher.*.*.*
|
||||||
|
name="host_dispatch_events"
|
||||||
|
processor="$1"
|
||||||
|
action="$2"
|
||||||
|
result="$3"
|
||||||
|
job="test_dispatcher"
|
||||||
|
|
||||||
*.*
|
*.*
|
||||||
name="catchall"
|
name="catchall"
|
||||||
first="$1"
|
first="$1"
|
||||||
|
@ -50,6 +57,13 @@ func TestMetricMapper(t *testing.T) {
|
||||||
"result": "succeeded",
|
"result": "succeeded",
|
||||||
"job": "test_dispatcher",
|
"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{
|
"foo.bar": map[string]string{
|
||||||
"name": "catchall",
|
"name": "catchall",
|
||||||
"first": "foo",
|
"first": "foo",
|
||||||
|
@ -91,7 +105,7 @@ func TestMetricMapper(t *testing.T) {
|
||||||
// Config with bad metric line.
|
// Config with bad metric line.
|
||||||
{
|
{
|
||||||
config: `
|
config: `
|
||||||
bad-metric-line.*.*
|
bad--metric-line.*.*
|
||||||
name="foo"
|
name="foo"
|
||||||
`,
|
`,
|
||||||
configBad: true,
|
configBad: true,
|
||||||
|
@ -104,6 +118,14 @@ func TestMetricMapper(t *testing.T) {
|
||||||
`,
|
`,
|
||||||
configBad: true,
|
configBad: true,
|
||||||
},
|
},
|
||||||
|
// Config with bad label line.
|
||||||
|
{
|
||||||
|
config: `
|
||||||
|
test.*.*
|
||||||
|
name="foo-name"
|
||||||
|
`,
|
||||||
|
configBad: true,
|
||||||
|
},
|
||||||
// Config with bad metric name.
|
// Config with bad metric name.
|
||||||
{
|
{
|
||||||
config: `
|
config: `
|
||||||
|
|
Loading…
Reference in a new issue