Monitor JBoss AS with Jolokia

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Jolokia is a cool monitoring solution for accessing JMX MBeans remotely. It is different to JSR-160 connectors in so far as it is an agent based approach which uses JSON over HTTP for its communication in a REST-stylish way.

As any monitoring solution, an agent is required to interact with the application. Multiple agents are provided for different environments:

  • WAR Agent for deployment as web application in a JEE Server.
  • OSGi Agent for deployment in an OSGi container. This agent is packaged as a bundle and comes in two flavors (minimal, all-in-one).
  • Mule Agent for usage within a Mule ESB
  • JVM Agent which can be used with any Oracle/Sun JVM, Version 6

In this tutorial we will deploy the WAR agent on JBoss AS 7 and access the JMX deployed on the server. So as first step, move to the download page and download the WAR Agent. Once downloaded renamed it for your convenience as jolokia.war and drop it into the deployments folder of your standalone server.

First test: let's see if Jolokia responds correctly: issue the following GET request:


You should see the following JSON response:


Now let's try something more complex, but we need to know how the application server MBeans tree looks like. For this purpose you can issue the following GET request:

This will produce a quite verbose list of the MBeans running on the server. However, it would be easier to grasp it with the JConsole tools which shows in the Mbeans tab all the Mbeans in a tree-like structure.
jolokia tutorial jboss
In order to read an MBean property you can use the REST's read path as in the following example, where we are investigating on the ExampleDS Datasource (Use the ignoreErrors=true argument in order to avoid failures if some attributes are unreadable).


     . . . . .

Another example, which digs into the AS Thread pool:


. . . . .

In the following example we are using the exec command to execute an MBean command: in this case we will issue a redeploy command on the web application named myapp.war: http://localhost:8080/jolokia/exec/

Follow us on Twitter