The added value of the reports are:
- It keeps track of API usage and consequently assesses revenue generated by API, if monetized;
- It gives an idea of which application and user uses an API more compared to others. Hence, helps in driving business decisions;
- It helps manage the availability and performance of a given API based on the usage of the report;
- It provides information about what period of time the API usage is unusually high and hence manages user expectations.
WSO2 API Manager Analytics
The WSO2 API Manager (APIM) integrates with WSO2 APIM Analytics to provide reports, statistics and graphs on the APIs deployed in WSO2 APIM.
The APIM Analytics consists of two components:
- Worker: It is responsible to process the data streams sent from WSO2 APIM and publishes the statistics to a database;
- Dashboard: The dashboard reads the statistics published by the worker and displays the statistics on the dashboard.
The worker and dashboard are connected via the database.
How to configure WSO2 API Manager Analytics:
Before generating analytics data (in this case, the monthly API Usage report ) from an API usage, we need to set up APIM Analytics (powered by WSO2 Streaming Integrator). The steps to set up the WSO2 APIM with Analytics can be found on the WSO2 website.
Once the set up and configuration are done, we need to create two sample APIs so that we can show the usage in the generated report:
- Pizzashack API: This can be directly deployed in APIM as it is available for deployment in publisher with a button click;
- PetStore API: This can be created as described here.
Subscribe and test both APIs from āTry outā option available in Dev Portal of the WSO2 API Manager. Run various resources multiple times to get a better view in the report.
After that, you can login into the Analytics dashboard and select APIM Admin as shown below.
Important to notice here that the permission to access the APIM Admin component of the analytics dashboard is only available for users with admin roles.
The following UI widget generates a PDF report of a specific year and month combination. The report can be downloaded by clicking on the download button.
The PDF report contains a table with the following information:
- API name;
- API version;
- Application name;
- Application owner;
- Request Count.
We can see the sample PDF, as shown below, for the two sample APIs as described above.
Customizing the Report:
The default implementation can be overidden and extended if it requires different data than the ones provided by the default report.
This can be achieved by implementing the ReportGenerator interface.
The default implementation can be used as a reference when implementing the extended version. Check out this sample custom implementation of the WSO2 APIM Analytics Monthly Usage report.
Once the implementation is done, the bundle needs to be placed in {ANALYTICS_HOME/lib} directory and the report:implClass config of the dashboard deployment.yaml should be changed to the fully qualified class name of the custom implementation as follows.
report:
Ā Ā implClass: org.wso2.analytics.apim.custompdf.CustomPDFGenerator
Conclusion
PDF reporting using WSO2 API Manager Analytics can be quite useful for the stakeholders for the reasons mentioned in the opening paragraph of this blog. This release of WSO2 API Manager Analytics 3.1.0 includes the first cut of the implementation of this feature. The default implementation of this feature can be extended if the user’s organization requires different data than the ones provided by the default report.