Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

2. Enable API tracking option by setting the "APIUsageTracking" element to true in <AM_HOME>\/repository\/conf\/api-manager.xml  file as follows.

Code Block
languagehtml/xml
<APIUsageTracking>

    <!-- Enable/Disable the API usage tracker. -->
    <Enabled>true</Enabled>   
    <PublisherClass>org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher</PublisherClass>
    <ThriftPort>7612</ThriftPort> 
    <BAMServerURL>tcp://localhost:7612/</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>

 

3. Configure . Restart the API Manager.

4. Next, configure a database to which BAM can write analyzed information to. This information is retrieved by the API Publisher before displaying on the corresponding statistical dashboards. Thrift protocol is used to publish data from the API Manager to BAM.

5. Specify the data source definition used in the above configuration in <AM_HOME>\repository\conf\datasourcesmaster-datasources.xml file as shown below. The <Name>WSO2AM_STATS_DB</Name> XML node defines the datasource used to fetch analytical data.

Code Block
languagehtml/xml
<datasource>
     <name>WSO2AM_STATS_DB</name>
     <description>The datasource used for getting statistics to API Manager</description>
     <jndiConfig>
          <!-- This jndi name should be same as the DataSourceName defined in api-manager.xml -->
          <name>jdbc/WSO2AM_STATS_DB</name>
     </jndiConfig>
     <definition type="RDBMS">
           <configuration>
                <!-- JDBC URL to query the database -->
                <url>jdbc:h2:<BAM_HOME>/repository/database/APIMGTSTATS_DB;AUTO_SERVER=TRUE</url>
                <username>wso2carbon</username>
                <password>wso2carbon</password>
                <driverClassName>org.h2.Driver</driverClassName>
                <maxActive>50</maxActive>
                <maxWait>60000</maxWait>
                <testOnBorrow>true</testOnBorrow>
                <validationQuery>SELECT 1</validationQuery>
                <validationInterval>30000</validationInterval>
           </configuration>
      </definition>
</datasource>
Info
titleNote

In the above configuration,

  • Replace <BAM_HOME> with the absolute path of BAM installation directory.
  • The JNDI config name should be the same as <APIUsageTracking> element in api-manager.xml defined in step 2.

 

 

 

 

 

 

 

 

 

 

 

4. Restart the API Manager.

5. Next, configure a database to which BAM can write analyzed information. This information is retrieved by the API Publisher before displaying on the corresponding statistical dashboards. Thrift protocol is used to publish data from the API Manager to BAM.

6. Open the file master-datasources.xml at location <AMNext, prepare BAM to collect and analyze statistics from API manager.

6. Copy the file <AM_HOME>/statistics/API_Manager_Analytics.tbox to directory, <BAM_HOME>/repository/deployment/server/bam-toolbox. If this folder is not in the BAM installation folder by default, create it before copying the file. The toolbox file describes the information collected and how to analyze the data.

A toolbox is an installable archive, with a .tbox extension. It contains necessary artifacts that models a complete usecase.

7. Change port offset for the BAM product to 1 by editing the file <BAM_HOME>/repository/conf/

...

carbon.xml file (search for the offset node).

Code Block
languagehtml/xml
<!-- Ports offset. This entry will set the value of the ports defined below 
to the define value + Offset. e.g. Offset=2 and HTTPS port=9443 will set
 the effective HTTPS port to 9445 -->
 
<Offset>1</Offset>

This increments all ports used by the server by 1, which means the BAM server will run on port 9444. Port offset is used to increment the default port by a given value. It avoids possible port conflicts when multiple WSO2 Carbon-based products are run in same host.

8. Add the following to <BAM_HOME>/conf/datasources/master-datasources.xml file.

Code Block
languagehtml/xml
<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:h2:   <!-- FullJDBC pathURL to query JDBCthe database -->
              <url>jdbc:h2:<BAM_HOME>/repository/database/APIMGTSTATS_DB;AUTO_SERVER=TRUE</url>
              <username>wso2carbon</username>
              <password>wso2carbon</password>
              <driverClassName>org.h2.Driver</driverClassName>
              <maxActive>50</maxActive>
              <maxWait>60000</maxWait>
              <testOnBorrow>true</testOnBorrow>
              <validationQuery>SELECT 1</validationQuery>
              <validationInterval>30000</validationInterval>
         </configuration>
      </definition>
</datasource>

Edit it to point to <BAM_HOME>/repository/database/APIMGTSTATS_DB database, which is where the default analytics scripts write by default.

Info
titleNote

<DataSourceName> of <APIUsageTracking> entry in <AM_HOME>/repository/conf/api-manager.xml should be same as the JNDI config name in <AM_HOME>/repository/conf/datasources/master-datasources.xml.

 Next, prepare BAM to create statistics from the API manager.

8. Copy the file <AM_HOME>/statistics/API_Manager_Analytics.tbox to directory, <BAM_HOME>/repository/deployment/server/bam-toolbox. If this folder is not in the BAM installation folder by default, create it before copying the file. The toolbox file describes the information collected, how to analyze the data,  as well as the location of the database where the analyzed data is stored.

9. Change port offset for the BAM product to 1 by editing the file <BAM_HOME>/repository/conf/carbon.xml file (search for the offset node). This increments all ports used by the servers by 1, which means the BAM server will now run on port 9444 - the port that the API manager uses by default.

...

 

 

 

 

 

 

 

 

 

 

 

 

Start WSO2 BAM server by running <BAM_HOME>/bin/wso2server.[sh/bat].

...