One of the reasons Dropwizard is so cool is how services can expose metrics simply by calling /metrics. What’s even better is that out of the box, you can pipe all of these metrics to a real-time graphing system like Graphite. I’ve mucked around with this and here are some of my thoughts.

First, Graphite is really cool but it is a major PITA to setup on a closed environment. I tried to go with a more lightweight approach, so I played around with a single page, jQuery and Highcharts combination. This proved to be a viable approach with several limitations. Due to the fact that you’re making the calls from the browser, cross domain issues will haunt your world. This means that you either have to ensure that the service can return the metrics in JSONP or be able to modify the access header. In addition, displaying metrics from multiple services quickly becomes untenable. Faced with these challenges, I basically decided to roll my own, using Dropwizard as well.

Basically, I used Dropwizard to serve up my monitoring view, accessible from 8080/metricsview. In the view itself, the jQuery $ajax call makes a call to another resource in my app, which basically acts as a wrapper around a HTTP call to any number of specified endpoints. It then collects all of these metrics and returns them to the browser, where it’s rendered according to whichever way the client wants. The prototype can be found here.

Right now, in its current proof-of-concept format, the service basically just monitors the JVM memory usage. There’s a lot more cool things to be done with this, such as monitoring multiple services, comparing similar metrics on the same graph, and organising the HTML views to make it more conducive for monitoring multiple metrics from multiple services, as rendering too many real-time graphs on the same page will inevitably degrade your browsing experience.

This is really fun!