JAMon (Java Application Monitor)

A Java Monitoring API

JAMon Introduction

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.

Monitoring your application

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!

Maven

JAMon is on Maven. The Maven pom dependency follows (substitute the appropriate version):
 <dependencies>
 <dependency>
 <groupId>com.jamonapi</groupId>
 <artifactId>jamon</artifactId>
 <version>2.81</version>
 </dependency>
 </dependencies>
 

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:

Videos - Short YouTube tutorials showing how to use JAMon

API - start/stop methods

MonitorFactory.start("myLabel"); - The start/stop methods time any code that they surround.

import com.jamonapi.*;
...
Monitor mon=MonitorFactory.start("myFirstMonitorLabel"); // using Strings is flexible as they can represent anything.
...Code Being Timed...
mon.stop();
"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.

API - add method

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.

import com.jamonapi.*;
...
double myValue=...
MonitorFactory.add("myBytesSentLabel", "MB", myValue); // units can be any string, and myValue can be any numeric

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.

Link to another simple example.

API - Capturing details/context

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.

import com.jamonapi.*;
...
double myValue=...
String stackTrace=...
MonKey key=new MonKeyImp("com.jamonapi.pageHits", stackTrace, "ms.");
Monitor mon=MonitorFactory.add(key, myValue);

JAMon License Agreement

JAMon has a very liberal license. The spirit of the license is that there are no restrictions on its use. Should something not be clear in the license please to contact admin@jamonapi.com. In general JAMon binaries can be used free of charge in any software (commercial software too), and JAMon source code may be modified. The JAMon License was adapted from the BSD license.

SourceForge.net Logo

AltStyle によって変換されたページ (->オリジナル) /