The following sections explain how to configure the WSO2 API-M Analytics server to work with the Microgateway.
The current architecture depicting the connection between the API Microgateway and the Analytics server is shown below.
How Analytics works with the Microgateway
The Microgateway receives the requests from the API. To process the requests, there are two main tasks that run in the Microgateway.
When an API is invoked through the Microgateway, the subsequent events related to the invocations are populated and written in a file. To avoid the files attaining a large size, the following tasks are executed at particular time intervals.
File rotating task
- This task creates large files by rotating them at particular time intervals. The size of the files depends on the TPS (Transactions Per Second) of the environment in which the microgateway is running. Once the file is rotated, it is compressed into a zipped file. The
rotatingPeriodcan be configured as shown in the step 2 of the following section.
File uploading task
- This task uploads the zipped file created by the previous task, to a microservice running on the Analytics Server. This zip file is then persisted in the
WSO2AM_STATS_DBdatabase in the Analytics server node. A task running in the Analytics server processes the persisted data and sends it to the event stream. The time interval in which the zipped files are uploaded can be configured by setting the
After successfully completing the upload and persistence is achieved, the corresponding files are deleted from the Microgateway filesystem.
Configuring Analytics for the Microgateway
The following sections describe how to configure the WSO2 API-M Analytics Server for Microgateway.
Step 1 - Configuring the API-M Analytics Server
- Configure API Manager Analytics using the Standard Setup. For instructions, see Configuring APIM Analytics.
The following system properties can be passed to the server if the default values need to be changed.
Java system properties
Property Default value Description
The frequency in which the database is read by the event source. This parameter is defined in milliseconds.
The frequency in which the cleanup task is run, to remove the processed files. This parameter is defined in milliseconds.
The allowed duration for files to remain in the database. This parameter is defined in days
3 The number of worker threads used to read data from the database. Each thread will read from a single file.
Step 2 - Configuring the Microgateway for Analytics
To do the configurations for Microgateway analytics, open the
<MICROGW_HOME>/conf/micro-gw.conf file. The sample below shows the analytics-related configurations.
The configurations are described in the table below.
|Set this to true to enable Microgateway analytics. When enabled, the Microgateway starts persisting files with the analytics data in the |
|The time interval in which the uploading task runs.|
|The endpoint URL of the web application, to which the file has to be uploaded. This web app is deployed in the Analytics server, to retrieve files containing analytics data. If cluster of analytics servers are deployed, specify the load balancer endpoint that fronts the analytics server cluster|
The time interval, after which the file is rotated and compressed. This depends on the TPS (Transactions Per Second) capacity of the environment.
To avoid creating large files, we recommend setting a low
Set this to true to enable the file upload task.
If this property is disabled, the analytics files are not uploaded to the analytics server, although the files are persisted in the Microgateway system.
In a distributed setup, the analytics data is uploaded to a shared location from multiple Microgateway nodes. To avoid multiple nodes competing to upload the same file, we recommend enabling the
You can also opt to have your own design as a workaround.
|Username used in the Analytics server.|
|Password for the corresponding username.|
Generating a Microgateway usage report
A report containing the number of requests served by the microgateway can be generated using the following steps
Before you begin...
Configure API Manager Analytics using the Standard Setup. For instructions, see Configuring APIM Analytics.
- Login to admin portal (https://<host>:<port>/admin/) and navigate to the Microgateway tab and click on 'Usage Reports'.
- Select a year and a month to generate the report for the respective month
- Select 'Generate' button to generate a pdf with the usage information