Apache Camel 2.14 is being released later this month. There is a slight
holdup due some Apache infrastructure issue which is being worked on.
This blog post is to talk about one of the new functions we have added to this release. Thanks to Lauri Kimmel who donated a camel-metrics component, we integrated with the excellent codehale metrics library.
So I took this component one step further and integrated it with the Camel routes so we have additional metrics about the route performances using codehale metrics. This allows end users to seamless feed Camel routing information together with existing data they are gathering using codehale metrics.
Also take note we have a lot of existing metrics from camel-core which of course is still around.
What codehale brings to the table is that they have additional statistical data which we do not have in camel-core.
To use the codehale metics all you need to do is:
- add camel-metrics component
- enable route metrics in XML or Java code
&;t;bean id="metricsRoutePolicyFactory" class="org.apache.camel.component.metrics. routepolicy.MetricsRoutePolicyFactory"/>And doing so in Java code is easy as well by calling this method on your CamelContext.
context.addRoutePolicyFactory(new MetricsRoutePolicyFactory());Now performance metrics is only useable if you have a way of displaying them, and for that you can use hawtio. Notice you can use any kind of monitoring tooling which can integrate with JMX, as the metrics is available over JMX. The actual data is 100% codehale json format, where a piece of the data is shown in the figure below.
|Sample of the route metrics JSON data|
|hawtio have detected that we have route metrics enabled, and shows a sub tab where we can see the data in real time|
The screenshot above is from the new camel-example-servlet-rest-tomcat which we ship out of the box. This example demonstrates another new functionality in Camel 2.14 which is the Rest DSL (I will do a blog about that later). This example enables the route metrics out of the box, so what I did was to deploy this example together with hawtio (the hawtio-default WAR) in Apache Tomcat 8.
With hawtio you can also build custom dashboards, so here at the end I have put together a dashboard with various screens from hawtio to have a custom view of a Camel application.
|hawtio dashboard with Camel route and metrics as well control panel to control the route(s), and the logs in the bottom.|