Search code examples
jmxmetricsgaugespring-jmxcodahale-metrics

Change the default behavior of JMXReporter


I'm trying to push custom gauge type metrics of my application to JMX using com.codahale.metrics.JmxReporter.
It seems like JMXReporter by default pushes the metrics to the endpoint /metrics which appends an attribute called .value to the metric name i.e. say if my custom metric name is app.test.count JMXReporter reports this metric name as app.test.count.value (under the endpoint metrics).

So, is there a way to make JMXReporter to not to append this .value attribute to the metric names? I found here that for InfluxDBReporter all the gauge type metrics will be appended with .value. So, is this the same with JMXReporter?

If that's the case then is there any other way how I can report metrics to JMX with the metric name I need.


Solution

  • You can change the ObjectName the metric is published through, but the MBean attribute name is hard-coded into the JmxReporter. JmxReporter$JmxGauge is also private, so, the only way to change it would be to implement your own JmxReporter.