Tuesday, December 14, 2010

jmxtrans : queries jmx and writes out the data in whatever format you want

For a long time now, many large Java projects have diligently added support for JMX to their systems. Even the big players like Cloudera's Hadoop have great blog posts about how they have all sorts of great metrics available through JMX. In addition, Tomcat, JBoss and ActiveMQ all have metrics exposed through JMX.

Sadly, there is not a single project out there that makes it easy to take the data out of JMX and convert it into something that can be graphed. Some suggest using jconsole to look at things. jconsole is great if you want to look at a server at a time. Others suggest graphing or monitoring with one of the many tools available. JMX4Perl, Hyperic, Cacti, OpenNMS, Nagios, etc. These tools all have their advantages and disadvantages. However, what they all have in common is that they are ridiculously difficult to configure and use in a production environment.

Enter my new project: jmxtrans. Yes, stupid name, but it really serves a purpose. jmxtrans allows a sysadmin to define a simple json configuration file and then execute that config to produce a list of results that can be transformed into whatever format you want. Out of the box it supports cacti/rrd databases and graphite. I'll add more as time goes on. It can also scale to support massive clusters of servers with a fully multithreaded engine. It also has an api which makes it easy to add to your existing application and it can be used from any one of the Java'ish languages (Scala, Groovy, JRuby, PHPJavaBridge, JPython).

This image...



Was generated with this simple json configuration...

{
  "servers" : [ {
    "port" : "1099",
    "host" : "w2",
    "queries" : [ {
      "outputWriters" : [ {
        "@class" : "com.googlecode.jmxtrans.model.output.GraphiteWriter",
        "port" : 2003,
        "host" : "192.168.192.133"
      } ],
      "obj" : "java.lang:type=Memory",
      "attr" : [ "HeapMemoryUsage", "NonHeapMemoryUsage" ]
    } ]
  } ]
}

This project has been about 3 solid days of work and I'm really proud of it. Graphical monitoring of your JVM is very important in order to understand what is going on in your application. I'm looking forward to seeing how this project grows.