Page History
...
Do the following changes in
<APIM_HOME>/repository/conf/api-manager.xml
file:- Enable API usage tracking by setting the
<APIUsageTracking>
element totrue
. - Because you will apply an offset to the default BAM port later in this guide, you need to apply the same offset to the default Thrift port. To do that, change the port value to 7614 in the <ThriftPort> element of this file. The API Manager will then push the data to BAM through port 7614, using the Thrift protocol.
- Uncomments Uncomment 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.
Info <BAMServerURL>
refers to the endpoint to which events will be published from the API Gateway. This endpoint is also known as the event receiver. You can define multiple event receiver groups, each with one or more receivers. A receiver group is defined within curly braces and receiver URLs are delimited by commas.For example,
<BAMServerURL>{tcp://localhost:7612/,tcp://localhost:7613/},{tcp://localhost:7712/,tcp://localhost:7713/}</BAMServerURL>
. This example has two receiver groups defined with two receivers in each group. When a request passes through the API Gateway, an event will be published to one selected receiver in each group.
Code Block language html/xml <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>
Tip Tip: You can give a comma-separated list of URLs as the
<BAMServerURL>
to manage failover. If the BAM server in the first URL fails, the request will be routed to the second one.Tip Tip: Are you working with an API Manager cluster? If so,
- Configure the
<APIUsageTracking>
element as given above in all API Gateway nodes Configure the following sub elements under the
<APIUsageTracking>
element in the API Publisher and Store nodes:Code Block language xml <DataSourceName>jdbc/WSO2AM_STATS_DB</DataSourceName>
If you use destination-based usage tracking, enable the
<APIUsageTracking>
element in the Publisher node and connect to a running BAM instance. This is because the API Manager uses a separate BAM mediator to do destination based usage tracking.
- Enable API usage tracking by setting the
Specify the datasource definition under the
<datasource>
element in the<APIM_HOME>/repository/conf/datasources/master-datasources.xml
file. The tables are created automatically when the Hive script runs. You just need to create the schemadatabase. The example below connects to a MySQL instance:Code Block language 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:mysql://localhost:3306/stats_db?autoReconnect=true&</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>
Save the database driver JAR inside both
<AM_HOME>/repository/components/lib
and<BAM_HOME>/repository/components/lib
folders.
...