Integrate API Manager Analytics

This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Integrate API Manager Analytics

The API Manager Analytics provides reports, statistics and graphs on the APIs that are deployed in WSO2 Open Banking API Manager. You can configure alerts to monitor these APIs and detect unusual activity, manage locations via geo-location statistics, and carry out a detailed analysis of the logs. 

The placement of WSO2 APIM Analytics in deployment is as follows:

This section explains how to integrate API Manager Analytics with the WSO2 Open Banking solution.

Before you begin,

Download API-M Analytics 2.6.0 and unzip the file, or add API-M Analytics 2.6.0 through WUM using the following commands:

  1. Add API-M Analytics 2.6.0 WUM pack.

    wum add wso2am-analytics-2.6.0
  2. Update API-M Analytics 2.6.0 product packs using WUM.

    wum update wso2am-analytics-2.6.0

This guide is instructed for a server that runs API Manager Analytics worker profile with a port offset of 1.

Configuring the API Manager Analytics 

Follow the instructions below to configure the WSO2 Open Banking API Manager to publish statistics.

  1. Open the <WSO2_OB_APIM_HOME>/repository/conf/api-manager.xml file. 

  2. Configure the properties under the <Analytics> sub element.

    <Analytics> <!-- Enable Analytics for API Manager --> <Enabled>true</Enabled> <!-- Server URL of the remote StreamProcessor 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/} --> <StreamProcessorServerURL>{tcp://<WSO2_OB_APIM_ANALYTICS_HOST>:7612}</StreamProcessorServerURL> <!--StreamProcessorAuthServerURL>{ssl://localhost:7712}</StreamProcessorAuthServerURL--> <!-- Administrator username to login to the remote StreamProcessor server. --> <StreamProcessorUsername>admin</StreamProcessorUsername> <!-- Administrator password to login to the remote StreamProcessor server. --> <StreamProcessorPassword>admin</StreamProcessorPassword> <!-- For APIM implemented Statistic client for RDBMS --> <StatsProviderImpl>org.wso2.carbon.apimgt.usage.client.impl.APIUsageStatisticsRestClientImpl</StatsProviderImpl> <!-- StreamProcessor REST API configuration --> <StreamProcessorRestApiURL>https://<WSO2_OB_APIM_ANALYTICS_HOST>:7444</StreamProcessorRestApiURL> <StreamProcessorRestApiUsername>admin</StreamProcessorRestApiUsername> <StreamProcessorRestApiPassword>admin</StreamProcessorRestApiPassword> </Analytics>
  3. Save the changes and restart the WSO2 Open Banking API Manager server.

Configuring databases

The following is a list of database versions that are compatible with the WSO2 API Manager Analytics.

  • MySQL 5.7 

  • MS SQL Server 2016

  • Oracle 12c

You can configure databases to persist, process and analyze API-related data. Follow the steps below to configure the databases.

  1. Create the  openbank_apimgt_statsdb  database in your database server.

  2. Configure the worker profile.   

    Open the  <WSO2_APIM_ANALYTICS_HOME>/conf/worker/deployment.yaml  file. Update the  APIM_ANALYTICS_DB  datasource pointing it to the  openbank_apimgt_statsdb database using your database configurations.

    - name: APIM_ANALYTICS_DB description: The Datasource used for APIM Analytics jndiConfig: name: jdbc/APIM_ANALYTICS_DB definition: type: RDBMS configuration: jdbcUrl: 'jdbc:mysql://localhost:3306/openbank_apimgt_statsdb?autoReconnect=true&useSSL=false' username: root password: root driverClassName: com.mysql.jdbc.Driver maxPoolSize: 50 idleTimeout: 60000 connectionTestQuery: SELECT 1 validationTimeout: 30000 isAutoCommit: false
  3. By default, the following datasource entries are configured to H2 databases. If required, you can create external databases and point these entries to them.

  4. Place the database driver in the <WSO2_APIM_ANALYTICS_HOME>/lib directory. 

Configuring the Keystores

In the SSL handshake between the Open Banking API Manager and API Manager Analytics servers, the client (i.e. Open Banking API Manager) needs to verify the certificate presented by the server (i.e. API Manager Analytics). For this purpose, the client stores the trusted certificate of the server in the client-truststore.jks keystore.

If you use a custom keystore in Open Banking API Manager and/or API Manager Analytics, import the public key certificate of API Manager Analytics into the client-truststore.jks file of the Open Banking API Manager. To export the public key from the server and import it into the client's trust store, follow the steps given in Adding CA-signed certificates to keystores in the Administration Guide.

Enabling performance tuning and starting the servers

  1. You can enable performance tuning by adding configurations, as described in Performance Tuning in the WSO2 Stream Processor documentation.

  2. Navigate to the <WSO2_APIM_ANALYTICS_HOME>/bin directory, and give execution permissions to the worker.sh file.

  3. Run the API-M Analytics worker.sh as follows:

    ./worker.sh
  4. Navigate to the <WSO2_APIM_ANALYTICS_HOME>/bin directory, and give execution permissions to the dashboard.sh file.

  5. Run the API-M Analytics dashboard.sh as follows:

    ./dashboard.sh
  6. You can view analytics data as described below:

    1. Log in to the API Store or API Publisher.

    2. Click the Analytics tab.

    3. You can view API Usage, Top Users and Faulty Invocations details through the subtopics.

  7. To observe data analysis based on geographical locations, see Configuring Geolocation Based Statistics.