Monday, January 3, 2011

Apache Camel Monitoring

I've seen a lot of discussion about how to monitor Camel based applications.  Most people are looking for the following features: ability to view services (contexts, endpoints, routes), to view performance statistics (route throughput, etc) and to perform basic operations (start/stop routes, send messages, etc).

This post will breakdown the options (that I know of) that are available today (as of Camel 2.8).  If you have used other approaches or know of other ongoing development in this area, please let me know.

JMX APIs

Camel uses JMX to provide a standardized way to access metadata about contexts/routes/endpoints defined in a given application.  Also, you can use JMX to interact with these components (start/stop routes, etc) in some interesting ways.

I recently had some very specific Camel/ActiveMQ monitoring requests from a client.  After looking at the options, we ended up building a standalone Tomcat web app that used JSPs, jQuery, Ajax and JMX APIs to view route/endpoint statistics, manage Camel routes (stop, start, etc) and monitor/manipulate ActiveMQ queues.  It provided some much needed visibility and management features for our Camel/ActiveMQ based message processing application...

CamelContext

If you have a handle to the CamelContext, there are various APIs that can help describe and manage routes and endpoints.  These are used by the existing Camel Web Console and can be used to build custom interface to retrieve and use this information in various ways...

here are some of the notable APIs...

getRouteDefinitions()
getEndpoints()
getEndpointsMap()
getRouteStatus(routeId)
startRoute(routeId)
stopRoute(routeId)
removeRoute(routeId)
addRoutes(routeBuilder)
suspendRoute(routeId)
resumeRoute(routeId)

With a little creativity, you can use these APIs to manage/monitor and re-wire a Camel application dynamically.

Camel Web Console

This console provides web and REST interfaces to Camel contexts/routes/endpoints and allows you to view/manage endpoints/routes, send messages to endpoints, viewing route statistics, etc.

That being said, using this web console with an existing Camel application is tricky at the moment.  It's currently deployed as a war file that only has access to the CamelContext defined in its embedded spring XML file.  Though the entire camel-web project can be embedded and customized in your application if you desire (and know Scalate).  Given my recent client requirements, I opted to build my own basic app using JSPs/JMX as described above.

There has been some recent support for deploying this console in OSGI, where it should be able to view any CamelContexts deployed in the container, etc.  However, I'm yet to see this work...more on this later.

Using Camel APIs

There are also a number of Camel technologies/patterns that can be used to add monitoring to existing routes.

  • wire tap - can add message logging (to a file or JMS queue/topic, etc) or other inline processing
  • advicewith - can be used to modify existing routes to apply before/after operations or add/remove operations in a route
  • intercept - can be used to intercept Exchanges while they are in route, can apply to all endpoints, certain endpoints or just starting endpoints
  • BrowsableEndpoint - is an interface which Endpoints may implement to support the browsing of the exchanges which are pending or have been sent on it.
That being said, it takes some creativity to use these effectively and caution to not adversely affect the routes you are trying to monitor.

 Hyperic HQ

You can use this tool to monitor Servicemix (or any process), but it more geared towards system monitoring and JVM stats.  I didn't find it useful for any Camel specific monitoring. 

HAWTIO - http://hawt.io/
This is a newer tool that has plugins for ActiveMQ, Camel, etc to expose some great information and allow your to perform JMX operations.

jConsole/VisualVM

these are standard JMX based consoles.  They aren't web based and can't be customized (easily anyways) to provide anything more than a tree-like view of JMX MBeans.  If you know where to look though, you can do a lot with it.

summary

These are just some quick notes at this point.  As I learn about other ways of monitoring Camel, I'll update this list and give some more detailed comparison.  Any comments are welcome...


4 comments:

  1. Just seen this article on DZone. You should also check out https://github.com/sksamuel/camelwatch which is a camel feedback system we use at ecb.co.uk (heavily camel based for stats) that I've just open sourced.

    ReplyDelete
  2. thanks Sam, I'll take a look at camelwatch...it looks similar to what I built for a client a few years back

    ReplyDelete
  3. Here is my blog post about monitoring alternatives for Apache Camel:

    http://www.kai-waehner.de/blog/2013/07/15/apache-camel-and-talend-esb-management-and-monitoring-of-integration-routes-and-soap-rest-web-services-jmx-osgi-logstash-elasticsearch-kibana-hawtio

    My favorite is Kibana, a great open source project for creating dashboards based on log files.

    ReplyDelete
  4. Camel Web Console is not to be used anymore The web console module from Apache Camel distribution is deprecated and will be removed from Camel 3.0 onwards.
    Instead we encourage users to look at some of the alternative console projects, which some are listed in the bottom of this page.

    I have been using the HawtIO console and it is looking good. Lets see when it goes into production.

    ReplyDelete