Versions Compared

Key

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

...

  1. Enable API tracking option by setting the <APIUsageTracking> element to true in <APIM_HOME>/repository/conf/api-manager.xml. Also specify the data source used for getting BAM statistics in <DataSourceName> element. For example,

    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>
    Note

    In the above configuration, the default Thrift port is increased by 1 because we apply an offset of 1 to default BAM port later in this guide.

  2. Specify the data source definition in <APIM_HOME>/repository/conf/datasources/master-datasources.xml file as follows.  WSO2AM_STATS_DB is 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>
                    <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>
    Note

    In the above configuration,

    • Replace <BAM_HOME> with the absolute path of BAM installation directory.
    • The JNDI config name must match with configurations of api-manager.xml file defined later in this guide.

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

...