In WSO2 API Manager 1.10.0 Analytics can be configured using both (WSO2 APIM), you can configure Analytics either via the UI or XML.
Note |
---|
If you wish to configure Analytics in WSO2 API Manager via the UI, see Publishing API Runtime Statistics. |
Follow the instructions below to configure Analytics in APIM WSO2 API Manager using XML:
- Open the
<APIM_HOME>/repository/conf/api-manager.xml
file. - Carryout Carry out the following configuration changes under the
<APIUsageTracking>
element in the XML file.Enable Analytics in APIM by uncommenting and setting the <Enabled>
element to true.
Code Block |
---|
<Enabled>true</Enabled> |
Define the <DASServerURL>
value based on the WSO2 Data Analytics Server (WSO2 DAS) receivers.
: |
<DASServerURL> {tcp://localhost:7612/,tcp://localhost:7613/} </DASServerURL> |
Define the <DASUsername>
and <DASPassword>
based on the DAS receivers.
Define the <DASRestApiURL>
element according to the DAS master node as , because this URL is used to fetch data from DAS REST API.
Set the <DASRestApiUsername>
and <DASRestApiPassword>
element according to the DAS REST API.
Use the default configurations for the other configurations in this section.
Configure the statistics client.
By default APIM is configured for the DAS REST client.
Select the RDBMS Client.
Do this by setting the <StatisticClientProvider>
element as follows in the <APIM_HOME>/repository/conf/api-manager.xml
filethe <APIUsageTracking>
section.
ForAPIMimplementedStatisticclientforDASREST-->
<StatisticClientProvider>org.wso2.carbon.apimgt..client.impl.APIUsageStatisticsRestClientImpl</StatisticClientProvider>Define a datasource for the RDBMS client.
Do this by adding the following configuration in both the <APIM_HOME>/repository/conf/datasources/master-datasources.xml
and <DAS_HOME>/repository/conf/datasources/master-datasources.xml
files.
Code Block |
<datasource>
<name>WSO2AM_STATS_DB</name>
<description>The datasource used for registry and user manager</description> tracker configuration used by the DAS data publisher and
|
<jndiConfig> Google Analytics publisher in |
<name>jdbc/WSO2AM_STATS_DB</name></jndiConfig>
<definition type="RDBMS" <configuration> <url>jdbc:mysql://localhost:3306/APIM_STAT?autoReconnect=true&</url><username>root</username>Below property is used to enable API Manager analytics configuration |
<password>pass</password>
<driverClassName>com.mysql.jdbc.Driver</driverClassName><maxActive>50</maxActive>Enabling analytics via a configuration file can be useful in scenarios such as |
<maxWait>60000</maxWait>automated deployments where
|
<testOnBorrow>true</testOnBorrow> UI integration is inconvenient.
|
<validationQuery>SELECT1</validationQuery> If you uncomment this property, analytics configurations added |
<validationInterval>30000</validationInterval>
via admin-dashboard UI will
|
<defaultAutoCommit>false</defaultAutoCommit> get overwritten by tha configuration details |
</configuration>provided below when you restart |
</definition>
</datasource> - Copy the appropriate RDBMS driver into both the DAS and APIM
/repository/components/lib
directories. Deploy CApp.
As the summarization logic is defined in the DAS CApp, you need to depoy it in all the DAS nodes. When configuring Analytics using XML, you need to deploy the CApps manually; however, when configuring Analytics via the UI the CApp deployment process takes place automatically. The APIM Analytics related CApps are found in the <APIM_HOME>/statistics/
directory. Use the API_Manager_Analytics_RDBMS.car
for RDBMS configurations and the API_Manager_Analytics_REST.car
for the REST client. Use one of the following methods to deploy the CApp into DAS.- Copy the
<APIM_HOME>/statistics/API_Manager_Analytics_RDBMS.car
file into the <DAS_HOME>/repository/deployment/server/carbonapps
directory. If the /carbonapps
directory does not exist create the directory. Thereafter restart WSO2 DAS. Start WSO2 DAS and sign in to the DAS Management Console. Navigate to the main menu and click Carbon Applications. Click Add and deploy the CApp from the <APIM_HOME>/statistics/
directory.
Code Block |
<!--
APIusage tracker configuration used by the DAS data publisher and
Google Analytics publisher in API gateway.
<Analytics><!--EnableAnalyticsforAPIManager ><Enabled>false</Enabled>
<!-- Server URL of the remote DAS/CEP server used to collect statistics. Must |
be specified in protocol://hostname:port/ format. |
An event can also be published to multiple Receiver Groups each having 1 or more receivers. Receiver |
Groups are delimited by curly braces whereas receivers are delimited by commas.
|
Ex - Multiple Receivers within a single group |
tcp://localhost:7612/,tcp://localhost:7613/,tcp://localhost:7614/
|
Ex - Multiple Receiver Groups with two receivers each
{tcp://localhost:7612/,tcp://localhost:7613},{tcp://localhost:7712/,tcp://localhost:7713/}
-->
<DASServerURL>{tcp://localhost:7612/}</DASServerURL>
<!-- |
AdministratorusernametologintotheremoteDASserver.--> <DASUsername>admin</DASUsername>
<!-- passwordusername to login to the remote DAS server.
-->
|
<DASPassword>admin<DASPassword>ForAPIMimplementedStatisticclientforDASRESTAPI--> Administrator password to login to the remote DAS |
<StatsProviderImpl>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl</StatsProviderImpl><!ForAPIMimplementedStatisticclientforRDBMS --><DASPassword>admin</DASPassword>
<!-- |
StatsProviderImpl>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRdbmsClientImpl</StatsProviderImpl--><!-- DAS REST API configuration
Set the values if .'org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl'
is used as Statistic Client
-->
<DASRestApiURL>https://localhost:9444</DASRestApiURL>
<DASRestApiUsername>admin</DASRestApiUsername>
<DASRestApiPassword>admin</DASRestApiPassword>
<!--
Below property is used to skip trying to connect to event receiver nodes when publishing events even if
the stats enabled flag is set to true.
-->
<SkipEventReceiverConnection>false</SkipEventReceiverConnection>
<!--
API Usage Data Publisher.
-->
<PublisherClass>org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher</PublisherClass>
<!--
If below property set to true,then the response message size will be calculated and publish
with each successful API invocation event.
-->
<PublishResponseMessageSize>false</PublishResponseMessageSize>
<!--
Data publishing stream names and versions of API requests, responses and faults. If the default values
are changed, the toolbox also needs to be changed accordingly.
-->
<Streams>
<Request>
<Name>org.wso2.apimgt.statistics.request</Name>
<Version>1. |
10.0</Version>
</Request>
<Response>
<Name>org.wso2.apimgt.statistics.response</Name>
<Version>1. |
10.0</Version>
</Response>
<Fault>
<Name>org.wso2.apimgt.statistics.fault</Name>
<Version>1.0.0</Version>
</Fault>
<Destination>
<Name>org_wso2_apimgt_statistics_destination</Name>
<Version>1.0.0</Version>
<BAMProfileName>bam-profile</BAMProfileName>
</Destination>
<Throttle>
<Name>org.wso2.apimgt.statistics.throttle</Name>
<Version>1.0.0</Version>
</Throttle>
<Workflow>
<Name>org.wso2.apimgt.statistics.workflow</Name>
<Version>1.0.0</Version>
</Workflow>
</Streams>
</APIUsageTracking> |
Configure the statistics client.
Localtabgroup |
---|
Localtab |
---|
active | true |
---|
id | RDBMS-stat-client |
---|
title | RDBMS client |
---|
| Set the RDBMS client using the <StatisticClientProvider> element in the <APIM_HOME>/repository/conf/api-manager.xml file as follows: By default APIM is configured for the DAS REST client. Therefore, disable the REST client by commenting out the following: Code Block |
---|
<!-- For APIM implemented Statistic client for DAS REST |
|
|
<ExecutionTime>API -->
<!-- StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl</StatisticClientProvider --> |
Set the RDBMS client by uncommenting the following: Code Block |
---|
<!-- For APIM implemented Statistic client for RDBMS -->
|
|
|
<Name>org<StatisticClientProvider>org.wso2.carbon.apimgt |
|
|
.statistics.execution.time</Name>
.usage.client.impl.APIUsageStatisticsRdbmsClientImpl</StatisticClientProvider> |
Define a datasource for the RDBMS client. Do this by adding the following configuration in both the <APIM_HOME>/repository/conf/datasources/master-datasources.xml and <DAS_HOME>/repository/conf/datasources/master-datasources.xml files. Code Block |
---|
<datasource>
<name>WSO2AM_STATS_DB</name>
<description>The datasource used for registry and user manager</description>
<jndiConfig>
<name>jdbc/WSO2AM_STATS_DB</name>
|
|
|
<Version>1.0.0</Version></jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:mysql://localhost:3306/APIM_STAT?autoReconnect=true&< |
|
|
/ExecutionTime>
/url>
<username>root</username>
|
|
|
<AlertTypes> <password>pass</password>
|
|
|
<Name>orgwso2analytics.apim.alertStakeholderInfo</Name>jdbc.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
|
|
|
<Version>1.0.0</Version><defaultAutoCommit>false</defaultAutoCommit>
</configuration>
< |
|
|
/AlertTypes>
</Streams>
</Analytics>/definition>
</datasource> |
- If you are using MySQL as the database, run
<APIM_HOME>/dbscript/stat/sql/mysql.sql to create scemas in the database. Use the appropriate script according to your database. - Copy the appropriate RDBMS driver into both the WSO2 DAS and WSO2 APIM
/repository/components/lib directories.
|
Localtab |
---|
id | REST-stat-client |
---|
title | REST client |
---|
| Set the REST client using the <StatisticClientProvider> element in the <APIM_HOME>/repository/conf/api-manager.xml file as follows: By default APIM is configured for the DAS REST client. However, if it has been disabled, enable it by uncommenting the following: Code Block |
---|
<!-- For APIM implemented Statistic client for DAS REST API -->
<StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl</StatisticClientProvider> |
Disable the RDBMS client if it has been already enabled by commenting the following: Code Block |
---|
<!-- For APIM implemented Statistic client for RDBMS -->
<!-- StatisticClientProvider>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRdbmsClientImpl</StatisticClientProvider--> |
|
|
Deploy CApp.
As the summarization logic is defined in the DAS CApp, you need to depoy it in all the DAS nodes. When configuring Analytics using XML, you need to deploy the CApp manually.
Info |
---|
If you were to configure Analytics via the UI the CApp deployment process takes place automatically. |
Use one of the following methods to deploy the CApp into DAS.
- Deploy the CApp via the file system.
Copy the respective CAR file into the <DAS_HOME>/repository/deployment/server/carbonapps
directory.
Stats Client | CAR file |
---|
RDBMS client | <APIM_HOME>/statistics/API_Manager_Analytics_RDBMS.car |
REST client | <APIM_HOME>/statistics/API_Manager_Analytics_REST.car
|
Tip |
---|
If the /carbonapps directory does not exist create the directory. |
- Restart WSO2 DAS.
Deploy the CApp via the UI
Start WSO2 DAS and sign in to the DAS Management Console.
Navigate to the main menu and click Carbon Applications.
Click Add and deploy the CApp which is in the <APIM_HOME>/statistics
directory.