Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot map StatsD metrics with consecutive dashes in name #380

Closed
evandam opened this issue Jun 16, 2021 · 5 comments
Closed

Cannot map StatsD metrics with consecutive dashes in name #380

evandam opened this issue Jun 16, 2021 · 5 comments

Comments

@evandam
Copy link
Contributor

evandam commented Jun 16, 2021

Trying to reference an incoming StatsD metric with two dashes -- in the name results in an error starting statsd-exporter. Replacing the dashes with an underscore results in the metric not being mapped, though.

If I had to guess, https://github.com/prometheus/statsd_exporter/blob/master/pkg/mapper/mapper.go#L33-L37 should be tweaked to allow * dashes.

Example metric default-ubuntu-1804_kitchen.fabio--requests.count:0|c

level=debug ts=2021-06-16T23:54:45.193Z caller=listener.go:73 msg="Incoming line" proto=udp line=default-ubuntu-1804_kitchen.fabio--requests.count:0|c

Mapping with underscores:

mappings:
- match: "*.fabio__requests.count"
  name: "fabio_requests_count"
  help: "Fabio request count"
  labels:
    hostname: "$1"

Results in autogenerated metric mapping, not what we specify.

$ curl -s localhost:9102/metrics | grep 'requests_count'
# HELP default_ubuntu_1804_kitchen_fabio___requests_count Metric autogenerated by statsd_exporter.
# TYPE default_ubuntu_1804_kitchen_fabio___requests_count counter
default_ubuntu_1804_kitchen_fabio___requests_count 0

Mapping with dashes as seen in incoming metric:

mappings:
- match: "*.fabio--requests.count"
  name: "fabio_requests_count"
  help: "Fabio request count"
  labels:
    hostname: "$1"

statsd-exporter logs:

$ statsd_exporter --statsd.mapping-config=mapping.yml --log.level=debug
level=info ts=2021-06-16T23:57:30.868Z caller=main.go:321 msg="Starting StatsD -> Prometheus Exporter" version="(version=0.21.0, branch=HEAD, revision=ef6627b9f05350d54cd3bfea5afe36617d7eb5a4)"
level=info ts=2021-06-16T23:57:30.869Z caller=main.go:322 msg="Build context" context="(go=go1.16.5, user=root@8ace135a0329, date=20210610-07:24:32)"
level=error ts=2021-06-16T23:57:30.870Z caller=main.go:340 msg="error loading config" error="invalid match: *.fabio--requests.count"
@evandam evandam changed the title Cannot map StatsD metrics with dashes in name Cannot map StatsD metrics with consecutive dashes in name Jun 17, 2021
@SuperQ
Copy link
Member

SuperQ commented Jun 17, 2021

Yea, I'm not sure why the dash is outside the character class matching.

@matthiasr
Copy link
Contributor

Yes, seems like we can allow this. Will you make a PR @evandam?

@SuperQ
Copy link
Member

SuperQ commented Jun 17, 2021

It looks like the multi-dash bad test was added in #24

Maybe @juliusv or @macb can help understand why multiple dashes is invalid.

@matthiasr
Copy link
Contributor

matthiasr commented Jun 17, 2021 via email

@matthiasr
Copy link
Contributor

This is now fixed for mapped metrics (#381).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants