Oct 16 2017

Server & application monitor #java, #performance #tuning, #monitor, #bottleneck, #scale, #scalability, #monitoring #tools, #page #hits, #page #counter, #currenttimemillis, #benchmark, #jamonapi, #free, #freeware, #shareware, #open #source, #measure, #fdsapi, #formatteddataset, #servlet #filter


The Java Application Monitor (JAMon) is a free, simple, high performance, thread safe, Java API that allows developers to easily monitor production applications. Here is a link to a short video that gives an overview of JAMon.

  • JAMon allows developers to track their applications performance and behavior using predefined modules. There are modules that automatically monitor. SQL, HTTP page requests, Spring beans, method invocations, Log4j, and Exceptions. Other modules are often easy to build.
  • JAMon keeps track of the following metrics for any of the items it tracks in the modules: hits, total, average, min, max and concurrency (average, max, current/active) to name a few.
  • JAMon is fast and doesn’t consume much memory and so it is suitable for production environments.
  • JAMon statistics, stack traces and more are viewable from the JAMon war. JMX and are also accessible via the JAMon API.

In addition to using modules developers can monitor anything the modules don’t cover by using JAMon’s simple API methods ‘start/stop’ and ‘add’.

Of course nobody wants to litter their code with calls to add and stop, so when possible JAMon monitoring modules should be used as they allow the easiest monitoring. JAMon was developed primarily for monitoring web applications, however JAMon can be used in any JDK 1.6 or higher environment.

Feel free to continue reading the user’s guide or download JAMon and read the Java Docs. The following is a screen snapshot of jamonadmin.jsp from the JAMon WAR. It gives an idea of the type of information JAMon collects such as metrics on: SQL, JDBC, http page requests, http status codes, garbage collections, and exceptions.

JAMon comes with several ways to monitor your application that require no application code changes. Usually all that is required is to.

  • add a line to an xml file,
  • put the jamon jar file in your classpath,
  • and install the JAMon war to view JAMon metrics/monitors (or you can view the metrics in a JMX console like jconsole).

See HTTP Monitoring for directions on how to monitor page requests in your web server. See JAMon Modules for other easy ways to monitor different aspects of your application. You could be monitoring your code in a few minutes. Happy monitoring!

JAMon is on Maven. The Maven pom dependency follows (substitute the appropriate version):

Quick Links

JAMon Modules – The following links show how to enable monitoring with JAMon’s preconfigured modules:

  • HTTP Monitoring – Monitor requests/responses to Tomcat, Jetty, JBoss or any other JAVA web container. Track page execution times, status codes, bytes sent, exceptions thrown and more. Alternatively if you would like to monitor only your Web app and not the whole server you can use the JAMonFilter servlet filter or easily create your own.
  • Spring Monitoring – Monitor any Spring bean. Track method invocations, arguments passed to methods, and exceptions thrown.
  • JDBC/SQL monitoring – via the JAMon JDBC proxy driver (works with any other JDBC driver). Track SQL called, JDBC method calls, exceptions thrown and more.
  • Log4j Monitoring – Monitor via the JAMon log4j Appender. Track counts for ERROR, INFO, WARNING etc. ‘Tail’ the Log4j log from the JAMon web application
  • EJB3 Monitoring – Monitor EJBs using the JAMon EJB interceptor.
  • Interface Monitoring – Monitor any class implementing a Java interface. As this capability requires code changes it is best to use other forms of method monitoring such as AOP, or EJB monitoring if they are available. Like these approaches interface monitoring tracks method performance and thrown exceptions.

Features – The following contain links to useful JAMon features:

  • JAMon WAR – View & manage JAMon data with the JAMon web application
  • JAMon JMX – View JAMon data in a JMX tool like jconsole and visualvm. (2.80+)
  • GC metrics – View metrics associated with JVM garbage collections
  • JAMonListeners – Capture context about each monitor.
  • Distributed Application Monitoring – View all the data from your organizations applications from a central monitoring web application (the JAMon web application).

Videos – Short YouTube tutorials showing how to use JAMon

  • JAMon 101 – An intro video to JAMon. Shows how to use start/stop/add and also other highlights of using JAMon.
  • JAMon GUI – Shows how to access the information in JAMon via the JAMon WAR. Also shows data captured by the JAMon servlet filter and JDBC Proxy driver.
  • Monitoring Distributed Applications with JAMon
  • JAMon Operating System monitoring – Monitor your unix/linux/mac scripts with JAMon. Introduced in JAMon 2.72.

MonitorFactory.start(“myLabel”); – The start/stop methods time any code that they surround.

“myFirstMonitorLabel” can be replaced by strings that represent.

  • Page names – “/mydirectory/myfantasticpage.jsp”
  • SQL statements – “select * from myawesometable”
  • or anything else you would like to time.

JAMon keeps the label and units as a key in a Map and every time start or add are called with the same key JAMon updates statistics for: hits, total, average, min, max and concurrency (average, max, current/active) to name a few.

MonitorFactory.add(“myLabel”, “myUnits”, myValue); – Sometimes developers are interested in counting the frequency of items (such as exceptions, or page requests with a certain status code). In addition they are interested in measuring other concepts such as how many bytes are sent/received, or how much free memory there is. JAMon provides the ‘add’ method to handle these situations.

JAMon keeps the label and units as a key in a Map and every time start or add are called with the same key JAMon updates statistics for: hits, total, average, min, max and concurrency (average, max, current/active) to name a few.

MonitorFactory.add(new MonKeyImp(label, details, units), myValue); – An alternative way of calling JAMon start/stop or add methods is to pass in an explicit key. The advantage of passing in the key (MonKey) is that you can also pass in ‘details’. ‘details’ can can be any context information that is useful information fo the developer. For example a stacktrace, method arguments, or http parameters could be passed in.

JAMon typically deals with aggregate data, however the power of JAMonListeners. all data passed in as a ‘detail’ can later be viewed via the JAMon web application. To get more information about this capability see JAMonListener example.

Written by admin

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: