1
votes

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:

JConsole view

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?

1
So it looks like the root cause of the problem is Spring Boot 2 itself, which is using another library for metrics. So the aproach described in the article doesn't work anymore. - Ellrohir
I'm looking to implement monitoring and metrics collection in camel springboot 2 (with prometheus) as well. Were you able to successfully implement yours? I'm confused on what to use camel-micrometer or camel-metrics as ive seen the tutorial that you linked above. - bencampbell_14
I am sorry, but we have abandoned this task in the end, so I can't provide any useful help atm. It turned out, that for our project needs it is enough to monitor native metrics provided by OpenShift after the Fuse application is deployed there. - Ellrohir
But if I understood correctly, Micrometer is the library that is currently being used in Spring Boot 2. Camel-metrics used to be bundled in Spring Boot 1. - Ellrohir
our group doesn't have cluster privileges in the openshift envt, so we were thinking of running our own prometheus instance in an openshift namespace that will read the prometheus endpoints of our springboot apps. i see that you abandoned it already, any chance that you looked at exposing the JMX metrics via prometheus endpoint? - bencampbell_14

1 Answers

0
votes

I had the same issue with my spring boot 2.x application. Per the the camel jmx documentation it says to add the camel-management dependency and metrics will appear ootb. After adding it I see the metrics in jconsole.