This guide explains how to set up WSO2 Business Activity Monitor (BAM) to collect and analyze runtime statistics from WSO2 APP Manager. Thrift protocol is used to publish data from App Manager to BAM. Information processed in BAM is stored in a database, from where the App Manager publisher retrieves information before displaying. By default,
org.wso2.carbon.appmgt.usage.publisher.APIMgtUsageDataPublisher is configured to collect data events from WSO2 BAM.
<BAM_HOME>refers to the Business Activity Monitor installation directory.
<AppM_HOME>refers to the App Manager installation directory.
- You can change the example datasource and database names used in this guide according to your configurations.
Configuring WSO2 BAM
- Download WSO2 BAM 2.5.0.
Apply an offset of 3 to the default BAM port by editing the
This increments all ports used by the server by 3, which means the BAM server will run on port 9446. Port offset is used to increment the default port by a given value. It avoids possible port conflicts when multiple WSO2 products run on same host.
Specify the datasource definition under the
<datasource>element in the
<BAM_HOME>/repository/conf/datasources/master-datasources.xmlfile. The tables are created automatically when the Hive script runs. You just need to create the schema. The example below connects to a MySQL instance:
Save the database driver JAR inside both
Copy the file
If this folder is not in the BAM installation directory by default, create it. The toolbox describes the information collected, how to analyze the data, as well as the location of the database where the analyzed data is stored.
Restart BAM server by running the following command:
Configuring WSO2 App Manager
Set the following configurations in
<AppM_HOME>/repository/conf/app-manager.xmlfile as follows. Change the default values of the <BAMServerURL>, <BAMUsername>, and <BAMPassword> properties accordingly.
<BAMServerURL>element in the above configuration, with the IP address of your BAM server, and also change the values of the
<BAMPassword>accordingly if you have changed them
Specify the datasource definition in
<APPM_HOME>/repository/conf/datasources/master-datasources.xmlfile as follows.
Replace the <BAM_HOME> in the above configuration with the absolute path of BAM installation directory.
- The JNDI name should be matched with the one give in the BAM configuration.
Start the WSO2 AppM server.
Tracking Web app usage
You can track the usage of the web application as follows.
The tracking ID is a string (for example: AM-000000-01), which is generated when you create the Web app in WSO2 AppM. Follow the steps below to view the tracking ID.
- Log in to the App Publisher using the following URL:
- Click Web Applications, and then click All Web Applications.
- Click on the Web app of which you need to publish runtime statistics. The tracking ID is available in the Overview page of the Web app, once it is created as shown below.
Add the following configuration in the Web page, which you want to track the usage. It activates tracking by inserting
invokeStatistics.js into the page.
Include the following code snippet in the
invokeStatistics.js file. Replace
AM-XXXXXX-X with the web app tracking ID and define t he URL with an endpoint.
When replacing the Web App tracking IDs, you can enter multiple Web proxy Apps as comma-separated values. Also, when defining the URL, if you have applied a port offset value for WSO2 App Manger, you need to change the URL accordingly.
When pages including the above code snippet are invoked, App Manager will publish statistics to the enabled analytics engines (BAM / Google Analytics or both).
You need to enable the Publish Statistics option under Global Policies in the Step 2 - Policies when creating a Web app, to view published runtime app statistics after completing the above configurations.
Viewing runtime statistics
Follow the steps below to view the runtime statistics.
Log in to the App Publisher using the following URL:
- Click Statistics as shown below.
You can view the following runtime statistics on apps.
Usage by app
This displays the number of subscribers per each Web application as shown below.
This displays response time statistics per each Web application as shown below.
Usage by page
This displays the request count per each Web app as shown below.
Click on the bar of the corresponding Web app in the graph to view the breakdown of the number of hits per page of that Web app as shown below.
Change the statistics database
To use a different database than the default H2 for publishing statistics, you must change the properties of the datasource element, and additionally delete some metadata tables created by previous executions of the Hive script, if there are any. Follow the steps below to delete the metadata tables.
- Log in to the BAM management console, and click Add in the Analytics menu.
- Go to the Script Editor in the window that opens.
Execute the following script.
If there are previous executions of the Hive scripts, click Main, then click List in the Analytics menu in the management console of BAM. Alternatively, you can wait until the periodical execution time occurs. After configuring WSO2 BAM to render and produce statistics of apps hosted and managed in the App Manager, you can view them through various statistical dashboards in the App Publisher, depending on your permission levels. For information, see .