Every App has its own sound we cant hear. Even the tool we would like to talk about doesnt make it audible, but gives a good impression of runtime internals – at runtime :-).
Its Java Melody. What we’ve got here is a small library package that simply gets deployed with the application where you wanna know whats going on inside. Then, simply enter the URL of you Application Context into the browser, followed by „monitoring“ (like http://localhost:8080/MyGrateApp/monitoring) and you will land on an overview page. Be aware, that using a Servlet Container below v3 needs further configuration.
Here we go – Java internals at a glance. You will find yourself on a page that looks similar to our title image. View Memory consumption (Heap/Total), running Thread, number of HTTP Requests and even SQL Requests and JDBC Connection. Well, the latter ones doesn’t work out of the box, there is some more configuration needed. Same for monitoring EJB behaviour and other stuff like .
This shows memory consumption – nice view since garbage collection phases are visible. And a potential memory leak, because after each cleanup a little bit remains that stacks onto each other.
Another nice feature is, that Melody lets you create a memory histogram – but only when running a JDK instead of a JRE.
Of course, you can see environment information, like cpu, os info, java version, startup arguments and so on.
There is even a log viewer, that aggregates bad logs for you – or lets you browse through the entrys. Java Melody can notice you by mail, if something bad happens. This is really comfortable for application management without need for an extra log monitor (no question, there are better solutions, but we are talking about light weight here).
The comfortable this Tool is, the dangerous it is – Threads can be viewed AND killed online. So, be aware and always know where and what you do (i’m sure you are, but just in case 🙂
It is possible to setup a main Java Melody server to monitor and aggregate multiple Melody instances. I havent tested this yet, but sounds promissing.
Melody requires a JRE at least at v1.6. If you want the full features, you must run your server on a JDK. Be aware, that some features like EJB monitoring slows the overall performance.
Okay, so far a light overview. There is enough documentation out there, i recommend starting here.
Hint: if you want to monitor an App where you dont want to infiltrate the Archive (there might be several reasons), simply put Java Melody in a own WAR an deploy it besides. It does not show that much internal secrets, but still enough, since runtime info is global, like memory management.
PS: dont forget to protect your monitoring endpoint when using in production.