JBoss Connection Pool Monitoring Extension

jboss-connection-pool-monitoring-extension

An AppDynamics extension to be used with a stand alone Java machine agent to provide JBoss DataSource connection pool statistics.

Use Case

Red Hat JBoss Application Server and/or Enterprise Application Platform (EAP) are platforms to develop and deploy Java EE applications.

As of JBoss EAP 6 (and JBoss Application Server 7) the MBEAN jboss.jca.ManagedConnectionPool is no longer available and this prevents access to DataSource connection statistics via JMX.

This monitoring extension makes use of commands via jboss-cli.sh instead.

Metrics Provided

The following table contains a list of the JBoss EAP 6 core datasource statistics:

NameDescription
ActiveCountThe number of active connections. Each of the connections is either in use by an application or available in the pool
AvailableCountThe number of available connections in the pool.
AverageBlockingTimeThe average time spent blocking on obtaining an exclusive lock on the pool. The value is in milliseconds.
AverageCreationTimeThe average time spent creating a connection. The value is in milliseconds.
CreatedCountThe number of connections created.
DestroyedCountThe number of connections destroyed.
InUseCountThe number of connections currently in use.
MaxCreationTimeThe maximum time it took to create a connection. The value is in milliseconds.
MaxUsedCountThe maximum number of connections used.
MaxWaitCountThe maximum number of requests waiting for a connection at the same time.
MaxWaitTimeThe maximum time spent waiting for an exclusive lock on the pool.
TimedOutThe number of timed out connections.
TotalBlockingTimeThe total time spent waiting for an exclusive lock on the pool. The value is in milliseconds.
TotalCreationTimeThe total time spent creating connections. The value is in milliseconds.
WaitCountThe number of requests that had to wait for a connection.

Prerequisites

Starting from EAP 6.3, DataSource statistics need to be explicitly enabled before accessing as they are disabled by default to avoid any performance impact.

Execute in jboss-cli.sh command:

/subsystem=datasources/data-source=ExampleDS:write-attribute(name=statistics-enabled,value=true)

Alternatively set the statistics-enabled attribute to true in the standalone*.xml or domain.xml respectively.

<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="true">

To know more, please follow this link (Red Hat account required)

Installation

  1. After downloading and unzipping, use an editor to configure the user defined variables in JBossDatasourceMonitor/data-sources.sh according to the provided comments.
  2. Verify your settings by running data-sources.sh from the command prompt and with the user permissions of the Machine Agent. The output should look like:

    name=Custom Metrics|JBoss|data-source|ExampleDS|ActiveCount,aggregator=OBSERVATION,value=10
    name=Custom Metrics|JBoss|data-source|ExampleDS|AvailableCount,aggregator=OBSERVATION,value=20
    ...
    
  3. Copy directory JBossDatasourceMonitor into directory MACHINE_AGENT_HOME/monitors
  4. Restart the machine agent, check its logs and any non empty jboss_data-sources_$$.err file in the JBossDatasourceMonitor directory.
  5. Finally lookup the provided metrics via the AppDynamics metrics browser under:

    Application Infrastructure Performance> Root> Custom Metrics> JBoss> data-sources> DataSourceName
    

Troubleshooting steps

Use the following suggestions to troubleshoot any issues.

  • Check the machine agent log files for any issues
  • Check any non empty jboss_data-sources_$$.err file in the JBossDatasourceMonitor directory.
  • Start jboss-cli.sh from the command line using the credentials of the machine agent and execute commands "connect" and "/subsystem=datasources:read-resource" similar to the following example:

    /opt/jboss-eap-6.3/bin/jboss-cli.sh
    You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
    [disconnected /] connect [JBOSS_HOST:JBOSS_PORT]
    [standalone@localhost:9999 /] /subsystem=datasources:read-resource
    {
       "outcome" => "success",
       "result" => {
           "data-source" => {"ExampleDS" => undefined},
           "jdbc-driver" => {"h2" => undefined},
           "xa-data-source" => undefined
       },
      "response-headers" => {"process-state" => "reload-required"}
    }
    [standalone@localhost:9999 /] exit
    
  • Adjust the script to print debug information

Notes:

  • In JBoss domain mode jboss-cli.sh commands require command pre-pending with /host=<hostName>/server=<serverName>/ For example:

    /host=slave/server=server-one/subsystem=datasources/datasource=ExampleDS:read-resource(include-runtime=true)
    
  • By default, a Machine agent or a AppServer agent can only send a fixed number of metrics to the controller. To change this limit, please follow the instructions mentioned here. For example:

    java -Dappdynamics.agent.maxMetrics=2500 -jar machineagent.jar
    

Contributing

Always feel free to fork and contribute any changes directly via GitHub.

Community

Find out more in the AppDynamics Exchange.

Support

For any questions or feature request, please contact AppDynamics Center of Excellence.

Version: 1.0.4 Controller Compatibility: 4.1+ JBoss EAP Versions Tested On: 6 and 7