jmxtrans / jmxtrans-agent

Java Agent based JMX metrics exporter.
MIT License
179 stars 110 forks source link

Namespacing conversion #108

Open Tenchi2xh opened 7 years ago

Tenchi2xh commented 7 years ago

I was wondering if converting all the dots in a bean name (using %name% in the configuration) being transformed to underscores is a specific design decision?

At this line adding the optional second parameter to false would keep the dots.

It made querying Graphite unpractical since names were really long instead of having easy namespaces, for example service.http-server.akka-http-server_200_count instead of service.http-server.akka-http-server.200.count

Edit: here are the type of beans I am currently exporting:

screen shot 2017-07-31 at 15 23 47
kerlandsson commented 7 years ago

I think the reasoning behind this is that when using %name% it is hard to know beforehand how many dots the name will contain. E.g. the bean can dynamically pull its name from a system that has no knowledge that dots are special characters for a monitoring system somewhere. Hence the dots are escaped to make it deterministic how many dots the name will contain, for example to ensure that the metric ends up in the same Graphite folder always.

gehel commented 7 years ago

@kerlandsson has a pretty good explanation. The idea is that we want the Graphite hierarchy to match the JMX hierarchy. A bean name is a single component in the JMX hierarchy, so we don't want to split it on . which might or might not be the intent of whoever wrote the JMX bean.

Note that internally, jmxtrans uses String to represent those hierarchies, instead of a more abstract structure. This causes all kind of complications. This should be refactored at some point, which should enable making smarter decisions about how we rewrite bean names (or not rewrite them).