Tuesday, July 7, 2015

Publishing WSO2 APIM Statistics to WSO2 BAM

WSO2 API Manager (WSO2APIM) [1] is a fully open source, complete solution for creating, publishing and managing all aspects of an API and its lifecycle.

WSO2 Business Activity Monitor (WSO2BAM) [2] is a fully open source, complete solution for monitor/store a large amount of business related activities and understand business activities within SOA and Cloud deployments.

Users can use these two products together, which collectively gives total control over management and monitoring of APIs.

In this post I'm going to explain how APIM stat publishing and monitoring happens in WSO2APIM and WSO2BAM.

Configuring WSO2 APIM to publish statistics

You can find more information on setting up statistics publishing in [3]. Once you do your configurations, it should look like the below.

<APIM_HOME>/repository/conf/api-manager.xml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<APIUsageTracking>
    <!-- Enable/Disable the API usage tracker. -->
    <Enabled>true</Enabled>   
    <PublisherClass>org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher</PublisherClass>
    <ThriftPort>7614</ThriftPort> 
    <BAMServerURL>tcp://<BAM host IP>:7614/</BAMServerURL>
    <BAMUsername>admin</BAMUsername>
    <BAMPassword>admin</BAMPassword>
    <!-- JNDI name of the data source to be used for getting BAM statistics. This data source should
        be defined in the master-datasources.xml file in conf/datasources directory. -->
    <DataSourceName>jdbc/WSO2AM_STATS_DB</DataSourceName>
</APIUsageTracking>

<APIM_HOME>/repository/conf/datasources/master-datasources.xml


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<datasource>
    <name>WSO2AM_STATS_DB</name>
    <description>The datasource used for getting statistics to API Manager</description>
    <jndiConfig>
        <name>jdbc/WSO2AM_STATS_DB</name>
    </jndiConfig>
    <definition type="RDBMS">
        <configuration>
            <url>jdbc:mysql://localhost:3306/stats_db?autoReconnect=true&amp;</url>
            <username>db_username</username>
            <password>db_password</password>
            <driverClassName>com.mysql.jdbc.Driver</driverClassName>
            <maxActive>50</maxActive>
            <maxWait>60000</maxWait>
            <testOnBorrow>true</testOnBorrow>
            <validationQuery>SELECT 1</validationQuery>
            <validationInterval>30000</validationInterval>
         </configuration>
    </definition>
 </datasource>


Configuring WSO2 BAM


You can find more information on setting up statistics publishing in [3].

Note that you only need to copy API_Manager_Analytics.tbox into super tenant space. (No need to do any configuration in tenant space)




Above digram illustrate how the stat data is published and eventually view though the APIM Statistic view.

1. Statistics information about APIs from all the tenants are published to the WSO2 BAM via a single data publisher.

2.  API_Manager_Analytics.tbox has stream definitions and hive scripts needed to summarize statistics. These hive scripts get periodically executed and summarized data is pushed into a RDBMS.

3. When you visit statistics page in WSO2 APIM, it will retrieve summerized statistics form the RDBMS and shows it to you.

Note: If you need to view statistics of a API which is deployed in a particular tenant. Login in to WSO2 APIM in particular tenant and view statistics page.
(You don't need to do any additional configuration to support tenant specific statistics.)


[1] http://wso2.com/api-management/
[2] http://wso2.com/products/business-activity-monitor/
[3] https://docs.wso2.com/display/AM180/Publishing+API+Runtime+Statistics

No comments:

Post a Comment