This documentation is for WSO2 API Manager 1.10.0 View documentation for the latest release.
Publishing API Runtime Statistics Using REST Client - API Manager 1.10.0 - WSO2 Documentation
Skip to end of metadata
Go to start of metadata

This section explains how to set up WSO2 Data Analytics Server (WSO2 DAS) with the REST client, to collect, analyze, and publish runtime statistics from the API Manager, using the WSO2 APIM UI.

If you wish to configure Analytics using WSO2 DAS in WSO2 API Manager via XML, see Configuring Analytics in API Manager using XML.

From API Manager 1.10.x onwards, you can fetch summarized data using two clients:

  1. The REST client which fetches data directly from WSO2 DAS.
  2. The RDBMS client which fetches data from RDBMS.

From API Manager 1.10.x onwards, it is no longer possible to publish statistics via BAM. Instead, this is done using WSO2 DAS. In previous versions of API Manager, BAM put the summarized data on a separate RDBMS after which, API Manager fetches data from that RDBMS. With WSO2 DAS, data is shared more efficiently directly to API Manager using the DAS REST API. Therefore, there is no need to configure the RDBMS to generate statistics.

However, API Manager 1.10.x still supports RDBMS to generate summarized data. By default, summarised data is generated without configuring RDBMS. If you still want to use RDBMS, see Publishing API Runtime Statistics Using RDBMS.


Configuring WSO2 DAS

  1. Download WSO2 Data Analytics Server.
  2. If API Manager and DAS run on the same machine, open the <DAS_HOME>/repository/conf/carbon.xml file and increase the default service port of WSO2 DAS by setting the offset value as follows:


    This increments all ports used by the server by 3, which means the WSO2 DAS server will run on port 9446. Port offset is used to increment the default port by a given value. It avoids possible port conflicts when multiple WSO2 products run on same host.

Configuring WSO2 API Manager

  1. Download WSO2 API Manager.

  2. Start the API Manager server and log in to the Admin Dashboard (https://<Server Host>:9443/admin-dashboard).
  3. Click Configure Analytics under the Settings section.
  4. Select the Enable check box to enable statistical data publishing.
  5. Set the event receiver configurations according to WSO2 DAS (e.g. tcp://localhost:7614 as the URL and admin/admin as the username/password). 

    Event receivers refer to the endpoint to which events are published from the API Gateway. WSO2 DAS consists of a thrift receiver, which acts as the default event receiver. By default, this receiver listens on port 7611 when no port offsets are set and increments according to the port offset set for WSO2 DAS in step 2 above.
  6. Click Add URL Group to save the configuration. 
  7. Set the configurations under the Data Analyzer Configurations section (e.g. https://localhost:9446 as the URL and admin/admin as the username/password).

    This is the endpoint at which the data analyzer (WSO2 DAS, in this case) resides. The toolboxes specific to data analytics are deployed to this endpoint. By default, WSO2 DAS listens on port 9443 when no port offsets are set and increments according to the port offset set for WSO2 DAS in step 2 above.

  8. Click Save. It deploys the Analytics toolbox, which describes the information collected, how to analyze the data, and the location of the database where the analyzed data is stored.

You can configure WSO2 API Manager to publish statistics to two WSO2 DAS instances that are not clustered following the steps below.

  1. Add a second receiver URL as shown in step 7 above.
  2. Deploy car files manually, in both instances

For instructions on how to deploy car files, see Deploying Composite Applications in the Server. For additional details about composite applications, go to Working with Composite Applications.

Invoking the sample

Invoke an API to generate traffic and see the statistics. 

  1. Log in to the API Publisher and deploy the sample CalculatorAPI.

    Configuring API for Statistics of Usage by Destination

    To view the API Usage by Destination Statistics in API Publisher, you need to follow below steps and enable Usage Tracking for the API.

    1. Edit the API you have created and go to the implementation Stage.

    2. Open Show more Options under Endpoints and select Enabled for Destination-Based Usage Tracking.

    Now you have configured the Calculator API to track the Destination Based Usage statistics.

  2. Log in to the API Store and subscribe to the API you created. 
  3. Invoke the sample using the API Store or the cURL command and wait a few minutes for the analytics to be generated. 
  4. In the API Publisher, click API Usage under the All Statistics section. For more information, see Viewing API Statistics.

Purging Data (optional)

Data purging is an option to remove historical data in WSO2 DAS. This is important since it is not possible to delete tables or table data in WSO2 DAS. By purging data, you can achieve high performance on data analysing without removing analysed summary data. Only data from the stream data fired by API Manager is purged and it is contained in the following tables:







Make sure you do not purge data in tables other than those mentioned above as that will delete your summarized historical data.

There are two ways to purge data in DAS,

Using the admin console

  1. Navigate to the Data-explorer and select one of the above tables. 
  2. Click Schedule Data Purge.
  3. On the dialog box that appears, set the time and days within which you want to purge data and save.
  4. Repeat the steps for all of the tables above and wait for the data to be purged.

Using the global method

Note that this will affect all tenants.
  1. Open the <DAS_HOME>/repository/conf/analytics/analytics-config.xml file.
  2. Change the contents under the <analytics-data-purging> property as shown below:

        <!-- Below entry will indicate purging is enable or not. If user wants to enable data purging for cluster then this property need to be enable in all nodes -->
        <cron-expression>0 0 12 * * ?</cron-expression>
        <!-- Tables that need include to purging. Use regex expression to specify the table name that need include to purging.-->
        <!-- All records that insert before the specified retention time will be eligible to purge -->
  3. Save your changes.
  4. Restart the server for the changes to take effect.

You can purge all records by setting a minus value (e.g. -1) for <data-retention-days>.

  • No labels