While writing one of my search web application, I asked one of my friend for a free, lightweight, open-source tool for monitoring my application. What all I needed was average response times or page load times, error trends, and testing my optimization efforts.
As per his suggestion I tried JavaMelody, which perfectly fits into all my above requirements.
Goal of JavaMelody is to monitor Java or Java EE application servers. It provides a variety of charts and statistics like
- number of HTTP requests
- mean execution times
- percentage of errors of HTTP requets
- java memory details
- CPU load
- number of user sessions
and much more.
Take a look at the project page for more details.
However, in this post I will mention the steps required to set it up for web application.
Steps to setup JavaMelody on Apache Tomcat:
1. Download JavaMelody from Downloads page. Version available on their website while writing this post is 1.44, and the file to download is “javamelody-1.44.0.jar”.
2. Download “jrobin-1.5.9.jar”
3. Place these two files in your web application’s WEB-INF\lib folder.
4. Add following tags into WEB-INF\web.xml file:
<filter> <filter-name>monitoring</filter-name> <filter-class>net.bull.javamelody.MonitoringFilter</filter-class> </filter> <filter-mapping> <filter-name>monitoring</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>net.bull.javamelody.SessionListener</listener-class> </listener>
5. Restart tomcat service.
6. Open web browser and type in following URL: http://serverip:port/webappcontext/monitoring
[Update ‘serverip’, ‘port’ and ‘webappcontext’ with your server and application specific detail]
And here you go ! JavaMelody shows server snapshot in awesome graphs and other useful statistics.
Here are some of the screenshots: