Versions Compared

Key

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

This section explains how to configure analytics for WSO2 API Manager (WSO2 API-M). The API Manager integrates with the WSO2 Stream Processor 4.3.0 to provide reports, statistics and graphs on the APIs deployed in WSO2 API Manager. You can then configure alerts to monitor these APIs and detect unusual activity, manage locations via geo location statistics and carry out detailed analysis of the logs. WSO2 API Manager has an enhanced distribution of Analytics to cater to API Manager specific scenarios which is used here to configure APIM Analytics.

...

Localtabgroup
Localtab
titleQuick Setup

Anchor
quicksetup
quicksetup
Follow the instructions below if you wish to set up API-M Analytics for a quick demo in order to try-out the scenarios.

  1. Download and install WSO2 API-M.
    To download WSO2 API-M go to the WSO2 API Manager page and either click DOWNLOAD or OTHER INSTALLATION OPTIONS.

    For more information on installing WSO2 API-M, see the Installation Guide.
  2. Download and install WSO2 API-M Analytics.
    To download WSO2 API-M Analytics go to the WSO2 API Manager page, click OTHER INSTALLATION OPTIONS to navigate to the Installation Options page, and click Analytics.

    As the process of installing API-M Analytics is identical to installing WSO2 Stream Processor Server 4.3.0 (WSO2 SP), the following steps direct you to the WSO2 SP documentation for details.

    1. Ensure that you have met the Installation Prerequisites.
    2. Install WSO2 API-M Analytics based on the installation instructions that is relevant to your operating system:
  3. To enable Analytics, open the <API-M_HOME>/repository/conf/api-manager.xml file and set the Enabled property under Analytics to true as shown below. Save this change.

    Code Block
    languagexml
    <Analytics>
    	<Enabled>true</Enabled>
    	...
    <Analytics>
    Note

    If you are working on a distributed (clustered) setup of WSO2 API Manager, do the configurations instructed to be done in API Manager in the Publisher, Store, and Gateway nodes as well.

  4. Start the Analytics Server.
    Navigate to the <API-M_ANALYTICS_HOME>/bin directory in your console and execute one of the following scripts based on your OS.
    • On Windows:  worker.bat --run
    • On Linux/Mac OS:  sh worker.sh

  5. Start the API Manager server.
    Navigate to the <API-M_HOME>/bin directory in your console and execute one of the following scripts based on your OS.
    • On Windows:  wso2server.bat --run
    • On Linux/Mac OS:  sh wso2server.sh

      Info

      If API-M Analytics is properly configured in WSO2 API Manager, when you start up the API Manager server, which is after the WSO2 API-M Analytics server, you will see the following log message in the terminal that is running the API-M Analytics server.

      Code Block
      INFO {org.wso2.carbon.databridge.core.DataBridge} - user admin connected
  6. Optionally, if you wish to access the business rules via the Dashboard node, navigate to the <API-M_ANALYTICS_HOME>/bin directory in your console and execute one of the following scripts based on your OS.
    • On Windows:  dashboard.bat --run
    • On Linux/Mac OS:  sh dashboard.sh

You can now start using the WSO2 API Manager for its usual operations and the required Analytics functionality.

Localtab
idstandardsetup
titleStandard Setup

Anchor
standardsetup
standardsetup
Follow the instructions below if you wish to set up API-M Analytics for a production environment.

Table of Content Zone
locationtop
stylecircle

Step 1 - Download and install WSO2 API-M

To download WSO2 API-M go to the WSO2 API Manager page and either click DOWNLOAD or OTHER INSTALLATION OPTIONS. For more information on installing WSO2 API-M, see the Installation Guide.

Anchor
Step 1 - Download and install WSO2 API-M
Step 1 - Download and install WSO2 API-M


Step 2 - Download and install WSO2 API-M Analytics

To download WSO2 API-M Analytics go to the WSO2 API Manager page, click OTHER INSTALLATION OPTIONS to navigate to the Installation Options page, and click Analytics.


As the process of installing API-M Analytics is identical to installing WSO2 Stream Processor Server 4.3.0 (WSO2 SP), the following steps direct you to the WSO2 SP documentation for details.

Anchor
Step 2 - Download and install WSO2 API-M Analytics
Step 2 - Download and install WSO2 API-M Analytics

  1. Ensure that you have met the Installation Prerequisites.
  2. Install WSO2 API-M Analytics based on the installation instructions that is relevant to your operating system:

Step 3 - Configure WSO2 API Manager to publish statistics

Follow the instructions below to do the required configurations for WSO2 API-M to publish statistics in the WSO2 API-M Analytics server.

Anchor
Step 3 - Configure WSO2 API Manager to publish statistics
Step 3 - Configure WSO2 API Manager to publish statistics

Info

To download the WSO2 API Manager distribution, click DOWNLOAD and then click DOWNLOAD Server in the WSO2 API Manager page.

Note

If you are working on a distributed (clustered) setup of API Manager, carry out the instructed configurations in the Publisher, Store and Gateway nodes of the API Manager.

  1. Open the <API-M_HOME>/repository/conf/api-manager.xml file. 
  2. Under the <Analytics> sub element, set the Enabled parameter to true.
  3. Configure the following parameters if required.

    ParameterValueDescription
    <StreamProcessorServerURL><protocol>://<hostname>:<port>/
    The server URL of the remote WSO2 API-M Analytics server used to collect statistics from WSO2 API Manager. An event can also be published to multiple receiver groups, where each group has one or more receivers. Receiver groups are delimited by curly braces, whereas receivers are delimited by commas.

    e.g., Three receivers within a single group can be specified as follows.
    tcp://localhost:7612,tcp://localhost:7613,tcp://localhost:7614

    Two receiver groups with two receivers each can be specified as follows.
    {tcp://localhost:7612,tcp://localhost:7613},{tcp://localhost:7712,tcp://localhost:7713}

    Note

    Previously, when WSO2 API-M Analytics was powered by WSO2 Data Analytics Server 4.3.0Serverstr, you had to add a comma to separate the DAS URLs so that the analytics events were published to both nodes. However, when using WSO2 API-M Analytics 2.6.0, which is based on WSO2 Stream Processor 4.3.0, when publishing to an HA setup of APIM analytics, you need to separate the Stream Processor server URLs by the pipe symbol (|) because the analytics events are published in a failover manner where only one node handles the processing at any given time.

    Format:
    Receiver URL = tcp://<SP Receiver -1>:<port>|tcp://<SP Receiver -2>:<port>|tcp://<SP Receiver -3>:<port>
    Example:
    Receiver URL = tcp://localhost:7611|tcp://localhost:7612

    <StreamProcessorUsername>A valid administrator username

    The administrator username to log into the remote WSO2 API-M Analytics server that collects statistics from WSO2 API Manager.

    Info
    • If you enable email user, you need to configure @carbon.super to the username of the API-M Analytics admin user. e.g., If the username of the API-M Analytics admin use is demo@wso2.com, it must be demo@wso2.com @carbon.super once you have enabled email user.
    • It is required to change the values StreamProcessorUsername and StreamProcessorPassword parameters if the user of WSO2 API-M is different to the user of WSO2 API-M Analytics. The default value ${admin.username} retrieves the admin user of the current API-M node as the StreamProcessorUsername.
    <StreamProcessorPassword>The password of the username specified.

    The administrator password to log into the remote WSO2 API-M Analytics server that collects statistics from WSO2 API Manager.

    Info

    It is required to change the values StreamProcessorUsername and StreamProcessorPassword parameters if the user of WSO2 API-M is different to the user of WSO2 API-M Analytics. The default value ${admin.password} retrieves the admin user of the current API-M node as the StreamProcessorUsername.

    <StreamProcessorRestApiURL>https://<host>:<port>The WSO2 API-M Analytics REST API URL. The WSO2 API-M Analytics REST API connection information, which are included under the REST API-M connection information, are defined as global properties, as they are common to all the WSO2 API-M analytics.
    <StreamProcessorRestApiUsername>A valid administrator usernameThe administrator username to log into the remote WSO2 API-M Analytics server.
    <StreamProcessorRestApiPassword>The password of the username specified.The administrator password to log into the remote WSO2 API-M Analytics server.
  4. Save the changes.

Step 4 - Configure the databases

Configuring databases allow you to persist data relating to APIs, process them and analyze. Follow the procedure below to configure databases.

Anchor
Step 4 - Configure the databases
Step 4 - Configure the databases

Excerpt
Info

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

  • Postgres 9.5 and later
  • MySQL 5.6
  • MySQL 5.7 
  • Oracle 12c
  • MS SQL Server 2012
  • MS SQL Server 2014
  • MS SQL Server 2016
  • DB2
  1. Stop the WSO2 API-M Analytics server if it is running already.
  2. Configure the dashboard profile.

    1. Open the <API-M_ANALYTICS_HOME>/conf/dashboard/deployment.yaml file.

    2. Edit the APIM_ANALYTICS_DB section.
      A sample for MySQL is shown below.

      Code Block
       - name: APIM_ANALYTICS_DB
            description: "The datasource used for APIM statistics aggregated data."
            jndiConfig:
              name: jdbc/APIM_ANALYTICS_DB
            definition:
              type: RDBMS
              configuration:
                jdbcUrl: 'jdbc:mysql://localhost:3306/ANALYTICS_DB'
                username: 'root'
                password: '123'
                driverClassName: com.mysql.jdbc.Driver
                maxPoolSize: 50
                idleTimeout: 60000
                connectionTestQuery: SELECT 1
                validationTimeout: 30000
                isAutoCommit: false
  3. Configure the worker profile.

    Note

    If your deployment does not consist of any Mirogateways, you do not need to configure the WSO2AM_MGW_ANALYTICS_DB to an external database as you can use the default embedded H2 database.

    1. Open the <API-M_ANALYTICS_HOME>/conf/worker/deployment.yaml file.
    2. Edit the APIM_ANALYTICS_DB section.
      A sample for MySQL is shown below.

      Code Block
       - name: APIM_ANALYTICS_DB
            description: "The datasource used for APIM statistics aggregated data."
            jndiConfig:
              name: jdbc/APIM_ANALYTICS_DB
            definition:
              type: RDBMS
              configuration:
                jdbcUrl: 'jdbc:mysql://localhost:3306/ANALYTICS_DB'
                username: 'root'
                password: '123'
                driverClassName: com.mysql.jdbc.Driver
                maxPoolSize: 50
                idleTimeout: 60000
                connectionTestQuery: SELECT 1
                validationTimeout: 30000
                isAutoCommit: false
    3. Configure WSO2AM_MGW_ANALYTICS_DB to the same database as APIM_ANALYTICS_DB in the <API-M_ANALYTICS_HOME>/conf/worker/deployment.yaml file.

      Code Block
       - name: WSO2AM_MGW_ANALYTICS_DB
            description: "The datasource used for APIM MGW analytics data."
            jndiConfig:
              name: jdbc/WSO2AM_MGW_ANALYTICS_DB
            definition:
              type: RDBMS
              configuration:
                jdbcUrl: 'jdbc:mysql://localhost:3306/ANALYTICS_DB'
                username: 'root'
                password: '123'
                driverClassName: com.mysql.jdbc.Driver
                maxPoolSize: 50
                idleTimeout: 60000
                connectionTestQuery: SELECT 1
                validationTimeout: 30000
                isAutoCommit: false
    4. Create the AM_USAGE_UPLOADED_FILES table in the APIM_ANALYTICS_DB database.

      Localtabgroup
      Localtab
      activetrue
      idmysql-AM_USAGE_UPLOADED_FILES
      titleMySQL
      Code Block
      CREATE TABLE IF NOT EXISTS AM_USAGE_UPLOADED_FILES (
      FILE_NAME varchar(255) NOT NULL,
      FILE_TIMESTAMP TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      FILE_PROCESSED tinyint(1) DEFAULT 0,
      FILE_CONTENT MEDIUMBLOB DEFAULT NULL,
      PRIMARY KEY (FILE_NAME, FILE_TIMESTAMP)
      );
      Localtab
      idMSSQL-AM_USAGE_UPLOADED_FILES
      titleMSSQL
      Code Block
      CREATE TABLE AM_USAGE_UPLOADED_FILES (
      FILE_NAME varchar(255) NOT NULL,
      FILE_TIMESTAMP DATETIME2(0) DEFAULT GETDATE(),
      FILE_PROCESSED smallint DEFAULT 0,
      FILE_CONTENT VARBINARY(max) DEFAULT NULL,
      PRIMARY KEY (FILE_NAME, FILE_TIMESTAMP)
      );
      Localtab
      idOracle-AM_USAGE_UPLOADED_FILES
      titleOracle
      Code Block
      CREATE TABLE AM_USAGE_UPLOADED_FILES (
      FILE_NAME varchar2(255) NOT NULL,
      FILE_TIMESTAMP TIMESTAMP(0) DEFAULT SYSTIMESTAMP,
      FILE_PROCESSED number(3) DEFAULT 0,
      FILE_CONTENT BLOB DEFAULT NULL,
      PRIMARY KEY (FILE_NAME, FILE_TIMESTAMP)
      );
      Localtab
      idPostgres-AM_USAGE_UPLOADED_FILES
      titlePostgres
      Code Block
      CREATE TABLE IF NOT EXISTS AM_USAGE_UPLOADED_FILES (
      FILE_NAME varchar(255) NOT NULL,
      FILE_TIMESTAMP TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP,
      FILE_PROCESSED smallint DEFAULT 0,
      FILE_CONTENT BYTEA DEFAULT NULL,
      PRIMARY KEY (FILE_NAME, FILE_TIMESTAMP)
      );
      Localtab
      idDB2-AM_USAGE_UPLOADED_FILES
      titleDB2
      Code Block
      CREATE TABLE IF NOT EXISTS AM_USAGE_UPLOADED_FILES (
      FILE_NAME varchar(255) NOT NULL,
      FILE_TIMESTAMP TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP,
      FILE_PROCESSED tinyint DEFAULT 0,
      FILE_CONTENT MEDIUMBLOB DEFAULT NULL,
      PRIMARY KEY (FILE_NAME, FILE_TIMESTAMP)
      );
      Localtab
      idINFORMIX-AM_USAGE_UPLOADED_FILES
      titleInformix
      Code Block
      CREATE TABLE IF NOT EXISTS AM_USAGE_UPLOADED_FILES (
      FILE_NAME varchar(255) NOT NULL,
      FILE_TIMESTAMP TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP,
      FILE_PROCESSED tinyint DEFAULT 0,
      FILE_CONTENT MEDIUMBLOB DEFAULT NULL,
      PRIMARY KEY (FILE_NAME, FILE_TIMESTAMP)
      );
  4. Point the following data sources to external databases.
    None of the following databases need DB scripts. The tables will be automatically created.  

  5. Integrate third-party products when configuring the databases.

    Note

    WSO2 SP is a OSGi-based product. Therefore, when you integrate third party products such as Oracle with WSO2 API-M Analytics, you need to check whether the libraries you need to add are OSGi based. If they are not, you need to convert them to OSGi bundles before adding them to the <API-M_ANALYTICS_HOME>/lib directory. 

    To convert the jar files to OSGi bundles, follow the steps below.

    1. Download the non-OSGi jar for the required third party product, and save it in a preferred directory in your machine.

    2. Go to the <API-M_ANALYTICS_HOME>/bin directory. Run the command given below, to generate the converted file in the <API-M_ANALYTICS_HOME>/lib directory.

    Code Block
    ./jartobundle.sh <PATH_TO_NON-OSGi_JAR> ../lib
  6. Start the WSO2 API-M Analytics server.

Step 5 - Configure keystores

Anchor
Step 5 - Configure keystores
Step 5 - Configure keystores
In the SSL handshake between the API Manager and API Manager Analytics servers, the client (i.e. 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 API Manager and/or API Manager Analytics, import the public key certificate of API Manager Analytics into the client-truststore.jks file of the 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.