This documentation is for WSO2 API Manager 1.8.0 View documentation for the latest release.
Page Comparison - Quick Start Guide (v.43 vs v.44) - API Manager 1.8.0 - WSO2 Documentation

Versions Compared

Key

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

...

  1. Do the following changes in <APIM_HOME>/repository/conf/api-manager.xml file:

    • Enable API usage tracking by setting the <APIUsageTracking> element to true
    • Set the Thrift port to 7614
    • Uncomments and set the data source used for getting BAM statistics in <DataSourceName> element.
    • Set <BAMServerURL> to tcp://<BAM host IP>:7614/ where <BAM host IP> is the machine IP address. Do not use localhost unless you're in a disconnected mode.
    Code Block
    languagexml
    <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>
  2. Specify the datasource definition in <APIM_HOME>/repository/conf/datasources/master-datasources.xml file as follows. 

    Code Block
    languagexml
    <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>
                     <!-- 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>
  3. Save the database driver JAR inside both <AM_HOME>/repository/components/lib and <BAM_HOME>/repository/components/lib folders.

    Next, prepare BAM to collect and analyze statistics from API manager.

  4. Download WSO2 BAM 2.5.0 or later from location: http://wso2.com/products/business-activity-monitor.
  5. Change port offset of BAM to 3 by editing the file <BAM_HOME>/repository/conf/carbon.xml file (search for the offset node).

    Code Block
    languagehtml/xml
    <Offset>3</Offset>

    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 in same host.

  6. In <BAM_HOME>/repository/conf/datasources/bam_datasources.xml file, copy/paste WSO2_AMSTATS_DB definition from API Manager's master-datasources.xml file. You edited it in step 2.

  7. Give the hostname as localhost in in the <BAM_HOME>/repository/conf/data-bridge/data-bridge-config.xml file. 

    Code Block
    languagexml
    <thriftDataReceiver>
        <hostName>localhost</hostName>
        <port>7611</port>
        <securePort>7711</securePort>
    </
    thriftDataReceiver>
    thriftDataReceiver> 
  8. Restart the BAM server by running <BAM_HOME>/bin/wso2server.[sh/bat].
    Let's see the statistics now.

  9. Generate some traffic via the API Gateway (invoke the Cdyne API we use in this guide) and wait a few seconds. 

  10. Connect to the API Publisher as a creator or publisher.
    In the publisher role, you are able to see all stats and as creator, you see stats specific to the APIs you create.

  11. Click the Statistics menu. We show the sample statistics here, but you will see graphs specific to your instance.
  12. Similarly, API subscribers can also see statistics though the API Store. Click the Statistics menu as follows:

...