Analytics for Microgateway
WSO2 API Microgateway provides the capability to publish events to a configured analytics server, in order to generate analytics. The Microgateway is also capable of generating a usage report to gain insights into the analytics generated. This page describes the feature and explains how the feature could be used to generate useful analytics in order to gain important insights of the APIs deployed on the Microgateway.
Overview
WSO2 API Microgateway supports publishing events to an analytics server in one of the two following methods.
The Following topics introduce and explain the difference between the two methods, as well as provide instructions on how to use them in the Microgateway to generate analytics.
Periodically Publishing Events (file-based)
API Microgateway is capable of publishing events periodically to an analytics server. The period in which the data is published can be configured. A file-based approach is used in this method.
Periodical data publishing has the following advantages:
A persistent connection to the analytics server is not a mandatory requirement (lossless publishing)
No backpressure to the Gateway if the analytics server is loaded, allowing the gateway to operate smoothly.
Architecture
The current architecture depicting the connection between the API Microgateway and the Analytics server is shown below.
How periodical publishing works
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 described below.
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 theuploadingTimeSpanInMillisparameter.
After successfully completing the upload and persistence is achieved, the corresponding files are deleted from the Microgateway filesystem.
Real-Time Publishing Events (gRPC based)
The Micorgateway is capable of publishing events in real-time to an analytics server using gRPC.
Real-Time data publishing has the following advantages:
Transferring analytics data over a secure HTTPS connection.
Efficient, fast and reliable end to end communication.
Lower communication payload for analytics data transferring.
Server-fail detection and failure recovery mechanisms.
Real-Time analytics data viewing capability.
Architecture
<<TO-DO>>
How real-time publishing works
<<TO-DO>>
Configuring Analytics for the Microgateway
The following sections describe how to configure the WSO2 API-M Analytics Server for Microgateway.
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 Quick setup or 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