Monitoring

Hawtio quickstart tutorial

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 

This tutorial is an introduction to hawtio console showing how you can use it to manage every kind of container or even any JVM middleware.

Most of you would argue why we need to learn another management console, when we are just fine with the application server web console. Well, the advantage of using hawtio is evident if you have multiple middleware (maybe not homogeneous middleware) in your company: as a matter of fact hawtio is a pluggable management console for Java stuff which supports any kind of JVM, any kind of container (Tomcat, Karaf, JBoss, Fuse Fabric, etc), and any kind of Java technology and middleware. So, in a nutshell, you can have multiple middleware managed from a single point.

To make things easier hawtio also use Jolokia that exposes JMX with JSON over HTTP. This makes it pretty easy to hook frameworks even if they don't already provide a rest interface, but expose things over JMX.

In this guide we will show how to install the hawtio library to monitor both JBoss EAP 6 and WildFly. As first step download the the hawtio-web.war distro which contains all the necessary plugins. You can find it in the plugins page at. http://hawt.io/plugins/

Once downloaded, you can rename it for your convenience to hawtio.war and deploy into your application server. Now simply open the browser at the Web context of hawtio, for example http://localhost:8080/hawtio

As you can see, the screen is divided into several tabs, depending on the plugins detected. For example, let's dig into the JMX Section which contains all the available MBeans:

hawtio tutorial

One really nice thing is that you can click on the single JMX attributes and you will get the Jolokia REST URL to query for that attribute. So for example if we were to query the "Worker queue size" from the above picture, the following REST URL will be shown:

http://localhost:8080/hawtio-web/jolokia/read/org.xnio:type=Xnio,provider=%22nio%22,worker=%22default%22/WorkerQueueSize

By entering it on a Browser URL, you would get the value of that attribute as JSON expression:

{"timestamp":1422347678,"status":200,"request":{"mbean":"org.xnio:provider=\"nio\",type=Xnio,worker=\"default\"","attribute":"WorkerQueueSize","type":"read"},"value":0}

Securing hawtio on JBoss EAP 6 / WildFly

So far we have accessed the hawtio console without any kind of security. In order to introduce a login/password authentication we will provide the following properties to the startup script of the application server:

On Linux/Unix:

JAVA_OPTS="$JAVA_OPTS -Dhawtio.authenticationEnabled=true -Dhawtio.realm=other -Dhawtio.role=hawtioadmin"

And the corresponding on Windows

set "JAVA_OPTS=%JAVA_OPTS% -Dhawtio.authenticationEnabled=true -Dhawtio.realm=other -Dhawtio.role=hawtioadmin"

Since the security will be now bound with the default "other" security domain, we will add an user by means of the add-user script available in the bin folder of the application server:

D:\wildfly-8.2.0.Final\bin>add-user.bat

What type of user do you wish to add?

 a) Management User (mgmt-users.properties)

 b) Application User (application-users.properties)

(a): b

Enter the details of the new user to add.

Using realm 'ApplicationRealm' as discovered from the existing property files.

Username : francesco

Password :

Re-enter Password :

What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none):

hawtioadmin

Now start the application server and check that the login screen will kick in for first time access:

hawtio tutorial

Enter the credentials for the username you have just created and you will be able to access the hawtio console.

Adding plugins

hawtio is highly modular with lots of plugins, so that hawtio can discover exactly what services are inside a JVM and dynamically update the console to provide an interface to them as things come and go. So after you have deployed hawtio into a container, as you add and remove new services to your JVM the hawtio console updates in real time.

Since the plugin has been deployed on JBoss EAP, hawtio has detected the JBoss plugin which contains a set of three tabs: 

  • Server: Info about the server release
  • Applications: Can be used to manage the applications deployed
  • Connectors: shows the Socket bindings available on the server

hawtio tutorial

Let's see another example: we have set the Infinispan hibernate cache to EAGER and deploying an application which uses the 2LC of Infinispan. By logging into hawtio we can have evidence of our caches, by selecting the Infinispan tab, which shows the statistics for the cache:

hawtio tutorial

Follow us on Twitter