This guide describes how to monitor WSO2 ESB using Mediation Statistics component and Java Management Extensions (JMX). WSO2 ESB provides convenient, yet powerful mechanisms for monitoring an ESB deployment. Results provided by ESB Monitoring can be used to tune up message flows, detect mediation faults and track usage patterns.
WSO2 ESB provides variety of options to monitor and manage the server runtime. While it provides number of monitoring tools through the Web-based Management Console, WSO2 ESB also supports Java Management Extensions (JMX) way of monitoring.
Out of monitoring capabilities of WSO2 ESB, the Mediation Statistics feature stands out as one of the most useful and widely used features. From functional components of the ESB, sequences, proxy services and endpoints directly get involved in processing messages. The Mediation Statistics feature enables a server administrator to collect runtime statistical information on these three types of functional components and view them through the Management Console. This feature provides a simple but effective way of determining the runtime performance of the ESB. The collected statistical data can be used to analyze network traffic patterns and draw rough estimates on how the service bus will be used in the future. Perhaps the most enticing attribute of the mediation statistics feature is that it can be configured in a fine grained manner. In other words, it allows a user to collect data on only a specified set of sequences, proxy services and endpoints.
Mediation Statistics component of WSO2 ESB uses an in-memory data store to keep the collected data. The memory usage of the data store is restricted by the total number of statistics collecting proxy services, sequences and endpoints. If the number of proxy services, sequences and endpoints is constant, the memory usage of the mediation statistics component stays constant. Mediation Statistics component also supports persistence as an optional feature. That is, one may configure the ESB to save statistics to the WSO2 Governance Registry instance that comes embedded with the ESB. Mediation Statistics API allows easy sharing of collected data, among Carbon components. Currently WSO2 Business Activity Monitor (BAM) makes use of this API to access data collected by the service bus. Users can also develop custom data consumers to retrieve mediation statistics from the in-memory data store and process them further, using this API.
Mediation Statistics feature is available with WSO2 ESB out of the box. You do not have to configure anything to use this feature. Simply sign-in to the Management Console and enable statistics on the sequences, proxy services and endpoints you want to monitor, and the service bus will start collecting data on them. For an example, in order to enable statistics for a sequence, click on Service Bus > Sequences in the left menu and simply click on the Enable Statistics icon corresponding to that sequence.
Figure 1: Enabling mediation statistics for a sequence
To enable statistics for a mediation component using the Synapse configuration language, set the value of the "statistics" attribute to "enabled" on the sequence, proxy or endpoint configuration.
To view the gathered statistics, click Monitor > Mediation Statistics. You will be shown a graphical summary of all collected statistics.
Figure 2: Viewing mediation statistics
Starting from this view, you can drill down to see more fine grained data such as statistics pertaining to a single sequence or a proxy service. You can even get statistics for different operations on the same endpoint. Click Proxy Service Statistics link in the upper right corner box of the UI shown in Figure 2 to view a summary of Proxy Service Statistics (Figure 3)
Figure 3: Mediation statistics of all proxy services
Select a proxy service from the "Proxy Services" list shown above to view statistics of that proxy service.
Figure 4: Mediation statistics of a proxy service
WSO2 ESB exposes number of management resources as JMX MBeans that can be used for managing and monitoring the running server. These MBeans can be accessed remotely using a JMX client such as JConsole. When WSO2 ESB is starting up, it will display the JMX Service URL in the console as follows.
INFO - JMXServerManager JMX Service URL : service:jmx:rmi://localhost:11111/jndi/rmi://localhost:9999/jmxrmi
This URL can be used to remotely access the JMX Service exposed by WSO2 ESB. In this guide, we will use JConsole as the JMX client to access this service.
Start JConsole and enter the above URL as the JMX Service URL. Type "admin" in both username and password fields and click "Connect".
Figure 5: Connecting to the JMX service using JConsole
After successfully connecting to the JMX service, click on "MBeans" tab of JConsole to view MBeans exposed by the ESB. As shown in Figure 6, these are listed under org.apache.axis2 and org.apache.synapse nodes. The following section summarizes the attributes and operations available in MBeans exposed by the WSO2 ESB.
Figure 6: Viewing MBeans exposed by WSO2 ESB
|ActiveThreadCount||Threads active in this transport listener/sender.|
|AvgSizeReceived||Average size of received messages.|
|AvgSizeSent||Average size of sent messages.|
|MaxSizeReceived||Maximum message size of received messages.|
|MaxSizeSent||Maximum message size of sent messages.|
|MinSizeReceived||Minimum message size of received messages.|
|MinSizeSent||Minimum message size of sent messages.|
|MessagesReceived||Total number of messages received through this transport.|
|MessagesSent||Total number of messages sent through this transport.|
|FaultsReceiving||Number of faults encountered while receiving.|
|FaultsSending||Number of faults encountered while sending.|
|BytesReceived||Number of bytes received through this transport.|
|BytesSent||Number of bytes sent through this transport.|
|QueueSize||Number of messages currently queued. Messages get queued if all the worker threads in this transport thread pool are busy.|
|ResponseCodeTable||Number of messages sent against their response codes.|
|TimeoutsReceiving||Message receiving timeout.|
|TimeoutsSending||Message sending timeout.|
|LastResetTime||Last time transport listener/sender statistic recording was reset.|
|MetricsWindow||Time difference between current time and last reset time in milliseconds.|
|resetStatistics()||Clear recorded transport listener/sender statistics and restart recording.|
|start()||Start this transport listener/sender.|
|stop()||Stop this transport listener/sender.|
|pause()||Pause this transport listener/sender which has been started.|
|resume()||Resume this transport listener/sender which is currently paused.|
|maintenenceShutdown(long gracePeriod)||Stop processing new messages, and wait the specified maximum time for in-flight requests to complete before a controlled shutdown for maintenence.|
|AllTimeAvgLatency||Average latency since latency recording was last reset.|
|LastXxxAvgLatency||Average latency for last Xxx time period. For example, LastHourAvgLatency return the average latency for last hour.|
|LastResetTime||Last time latency statistic recording was reset.|
|reset()||Clear recorded latency statistics and restart recording.|
|ActiveConnections||Number of currently active connections.|
|ActiveConnectionsPerHosts||A map of number of connections against hosts.|
|LastXxxConnections||Number of connections created during last Xxx time period.|
|RequestSizesMap||A map of number of requests against their sizes.|
|ResponseSizesMap||A map of number of responses against their sizes.|
|LastResetTime||Last time connection statistic recordings was reset.|
|reset()||Clear recorded connection statistics and restart recording.|
|TotalWorkerCount||Total worker threads related to this server/client.|
|AvgUnblockedWorkerPercentage||Time-averaged unblocked worker thread percentage.|
|AvgBlockedWorkerPercentage||Time-averaged blocked worker thread percentage.|
|LastXxxBlockedWorkerPercentage||Blocked worker thread percentage averaged for last Xxx time period.|
|DeadLockedWorkers||Number of deadlocked worker threads since last statistics reset.|
|LastResetTime||Last time thread statistic recordings was reset.|
|reset()||Clear recorded thread statistic and restart recording.|