Friday, February 8, 2013

Monitoring JBoss AS 7 web connector with RHQ

An RHQ user recently asked on our forums how to monitor "active connections" in a JBoss AS 7 web connector. Here is an how-to guide.

Let's assume that you already started a JBoss AS 7 instance, created a user in the Management Realm for RHQ agent (with add-user script) and imported this instance in RHQ server.

Don't forget to configure the user credentials under the Connection Settings tab.

RHQ AS7 Inventory Connection Settings
AS 7 Connection Settings

By default, the JBoss Web subsystem uses an internal thread pool and does not expose many properties through the management interface. What we need to do is creating a dedicated thread pool in the Threads subsystem and configure it to be the web connector executor.

Create a thread factory

Wouldn't it be nice to give connector threads an eloquent name? A dedicated thread factory will help. Under the Inventory > Child Resources tab of the Threads subsystem page, create a new child of ThreadFactory type:

RHQ AS7 Create Child Thread Factory
Create child of ThreadFactory type

Give this thread factory a name and adjust the Thread Name Pattern as you wish:

RHQ AS7 Thread Factory Wizard
ThreadFactory creation wizard
WARNING: don't leave priority unset. The default value '-1' is not valid and things will break at thread creation time.

Create and configure a thread pool

This is the core part. Under the Inventory > Child Resources tab of the Threads subsystem page, create a new child of ThreadPool type. Choose the unbounded-queue-thread-pool template and don't forget to link with your thread factory:

RHQ AS7 Thread Pool Wizard
ThreadPool creation wizard

Once the thread pool has been created and the new resource discovered by RHQ, enable measurements (only availability check is enabled by default). I chose to keep the default value for total counts and check active threads count every 30 seconds:

RHQ AS7 Thread Pool Schedules
ThreadPool Monitoring Schedules

Configure the web connector

Almost done! Configure the web connector to use the new thread pool as executor:

RHQ AS7 Connector Configuration
Web Connector configuration

This change requires to reload the JBoss AS 7 configuration. You can do this under the Operations tab of the JBoss AS 7 resource page.

Thread pool metrics

That's it! Now you can see your metrics collected:

RHQ AS7 Thread Pool Metrics
Web Connector Executor metrics