I have a project based on RedHat's fuse-springboot-bom that will be depolyed on OpenShift:
<dependency>
<groupId>org.jboss.redhat-fuse</groupId>
<artifactId>fuse-springboot-bom</artifactId>
<version>7.5.0.fuse-sb2-750029-redhat-00003</version>
<type>pom</type>
<scope>import</scope>
</dependency>
I was following this article in order to set up Camel metrics monitoring and export it via JMX Exporter in order to be consumed by Prometheus monitoring tool.
I added camel-metrics dependency into my POM:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-metrics</artifactId>
</dependency>
Then I was forced to include also an older version of Dropwizards's metrics-core, in order to avoid java.lang.ClassNotFoundException: com.codahale.metrics.JmxReporter error:
<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.2.2</version>
</dependency>
I am not 100% sure about this, but without this hack my application was failing on startup, because the JmxReporter class was moved to other location in newer versions that are being referenced by current camel-metrics. The other option was to downgrade camel-metrics, but versions 2.17.7 and lower were giving me org.apache.camel.FailedToCreateRouteException: Failed to create route aggregatesRoute: Route(aggregatesRoute)[[From[cxf:bean:aggregatesInEndpoint?d... because of NullPointerException error instead...
Following the tutorial further, I defined my MetricsRoutePolicy to use JMX and with custom domain name:
<bean class="org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicy" id="policy">
<property name="useJmx" value="true"/>
<property name="jmxDomain" value="okte.metrics"/>
</bean>
And I made a reference to this in my route:
<route id="aggregatesRoute" routePolicyRef="policy">
Then I tried to define simple counter metrics inside the route:
<route id="aggregatesRoute" routePolicyRef="policy">
<from id="aggregatesInEndpoint" uri="cxf:bean:aggregatesInEndpoint?dataFormat=PAYLOAD"/>
<!-- DO STUFF HERE -->
<log message="TEST camel-metrics counter will be increased"/>
<to uri="metrics:counter:simple.counter"/>
<log message="TEST camel-metrics counter was increased"/>
</route>
When I start my application on localhost (not in OpenShift yet) and use SoapUI to invoke the route, I see both log messages in console and no error or something.
But when I open JConsole, connect to running process and check listed MBeans, then for group okte.metrics I only see default the metric for the route:
I don't see my custom simple.counter unlinke in the tutorial article, where the author has his own metrics visible...
I believe I am missing something. Maybe because I use different version of underlying software, so I have to configure something more? Or it has something to do with older version of metrics library? Any clues or hints?
