mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-26 01:01:01 +00:00
Allow comments in mapping files
This commit is contained in:
parent
89e5e36b51
commit
5018c7415a
3 changed files with 10 additions and 1 deletions
|
@ -88,6 +88,7 @@ with `-statsd.add-suffix=false`.
|
||||||
|
|
||||||
An example mapping configuration with `-statsd.add-suffix=false`:
|
An example mapping configuration with `-statsd.add-suffix=false`:
|
||||||
|
|
||||||
|
# comments are allowed
|
||||||
test.dispatcher.*.*.*
|
test.dispatcher.*.*.*
|
||||||
name="dispatcher_events_total"
|
name="dispatcher_events_total"
|
||||||
processor="$1"
|
processor="$1"
|
||||||
|
|
|
@ -59,6 +59,11 @@ func (m *metricMapper) initFromString(fileContents string) error {
|
||||||
for i, line := range lines {
|
for i, line := range lines {
|
||||||
line := strings.TrimSpace(line)
|
line := strings.TrimSpace(line)
|
||||||
|
|
||||||
|
// skip comments
|
||||||
|
if strings.HasPrefix(line, "#") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
switch state {
|
switch state {
|
||||||
case SEARCHING:
|
case SEARCHING:
|
||||||
if line == "" {
|
if line == "" {
|
||||||
|
|
|
@ -28,11 +28,14 @@ func TestMetricMapper(t *testing.T) {
|
||||||
// Config with several mapping definitions.
|
// Config with several mapping definitions.
|
||||||
{
|
{
|
||||||
config: `
|
config: `
|
||||||
|
# this is a comment
|
||||||
|
# this is another
|
||||||
test.dispatcher.*.*.*
|
test.dispatcher.*.*.*
|
||||||
name="dispatch_events"
|
name="dispatch_events"
|
||||||
processor="$1"
|
processor="$1"
|
||||||
action="$2"
|
action="$2"
|
||||||
result="$3"
|
result="$3"
|
||||||
|
# here is a third
|
||||||
job="test_dispatcher"
|
job="test_dispatcher"
|
||||||
|
|
||||||
test.my-dispatch-host01.name.dispatcher.*.*.*
|
test.my-dispatch-host01.name.dispatcher.*.*.*
|
||||||
|
@ -148,7 +151,7 @@ func TestMetricMapper(t *testing.T) {
|
||||||
test.bar
|
test.bar
|
||||||
name="name_bar"
|
name="name_bar"
|
||||||
label="foo"
|
label="foo"
|
||||||
|
|
||||||
test.foo
|
test.foo
|
||||||
name="name_foo"
|
name="name_foo"
|
||||||
label="bar"`,
|
label="bar"`,
|
||||||
|
|
Loading…
Reference in a new issue