API Analytics plays an important role in API Management for understanding API consumption behavior by various applications and users. This gives an insight of statistics/metrics for an organization to know how their APIs are doing per their strategy- which APIs are working well for customers and which ones are not. By configuring alerts, they can also take necessary actions for any unusual activity, for example, abnormal request counts, abnormal resource access pattern, unseen source IP address, tier crossing, et cetera.
The main focus of this blog is to elaborate on some of the key features of the WSO2 API Manager (APIM) Analytics version 3.1.0 release in comparison to the older versions (2.x versions). In all 2.x release, analytics reports were in Publisher (API related reports) and Store portals (Application related reports). The drawback of this design is providing access for users who may not be API developers to check the statistics. This problem is solved in 3.x releases of WSO2 API Manager Analytics server with Internal/analytics Role which I will discuss later in this blog.
Analytics distribution got a new image in the WSO2 API Manager Analytics 3.0.0 release onwards. When you log into Analytics Dashboard by accessing <Protocol>://<Host>:<Port>/analytics-dashboard (ex: https://localhost:9643/analytics-dashboard) you will see APIM Admin, APIM publisher, APIM Developer Portal dashboards as shown below.
- Admin dashboard contains a single widget for admins which allows generating monthly API usage reports in a pdf format.
- Developer Portal dashboard contains widgets useful for application developers to check the usage of their applications.
- Publisher dashboard contains various widgets useful for API developers to monitor their API consumption.
If a user is only an application developer, he/she can access only the APIM Developer Portal dashboard. Similarly, if the user is an API developer and not an application developer, then only the APIM Publisher dashboard will be visible. This permission model is also extensible to allow/deny access to various roles in your organization depending on your requirement. The analytics dashboard portal also facilitates creating new dashboards with existing or custom widgets as required.
Below sections highlight some of the features of Analytics-dashboards:
APIM Developer Portal Dashboard
This dashboard has only one overview section with all the widgets on a single page. Developer Portal statistics dashboard can be viewed by any user having an Analytics role or Subscriber role. These permissions can be changed as per your preferences by going to 'Settings' options available from the Analytics dashboard.
APIM publisher dashboard
API Publisher dashboard has side tabs for the following: Overview, API and Application Statistics, Developer Statistics, Usage Summary, Devices, API Proxy Performance, Faults, and Geo Map.
Publisher statistics dashboard can be viewed by any user with roles in - Analytics, Creator, or Publisher and these permissions can be changed as per your preferences by going to Settings options of the Analytics dashboard.
WSO2 API Manager 3.1.0 includes a new role - Internal/analytics (along with the Internal/creator, Internal/publisher, and Internal/subscriber roles that were previously available) . When a user, who is not an API or application developer wants to view analytics charts, administrators can provide Internal/analytics role to the user to view the API publisher dashboard instead of providing API publishing permissions to the user. It is also helpful for a manager to check how the APIs are being used in their organization with a simple Internal/analytics role. This was not possible in previous releases of APIM analytics.
Date Range Picker and Sync button
This can be used to configure the time period and granularity mode of the data that can be seen in the widgets in all dashboards of the Publisher and Developer portal. The time period can be defined, either choosing from Quick Ranges or defining Custom Ranges. For the quick ranges, we have options for 1 Min, 15 Min, 1 Hour, 1 Day, 7 Days, 1 Month, 3 Months, 6 Months, and 1 Year. For Custom Ranges users can define the start date as From and end date as To.
Sync button is at the top right corner of the data-picker widget. When we toggle it, Analytics Dashboard automatically fetches data from the server regularly at a defined time intervals via a WebSocket connection. The default time interval is 30 seconds. This means a user no longer is required to reload the page to fetch the new data after the initial loading and page refreshes with the latest data every 30 seconds. This will be helpful for real-time monitoring and big-screen displays!
The dark mode is everywhere these days and the dashboard portal also supports dark mode. The default is the dark mode but it can be toggled to light mode. By toggling the light bulb icon on the menu bar, the theme can be changed.
Monthly API usage PDF reports
Monthly API Usage Report widget supports generating PDF report of a specific year, month combination and it can be done from the APIM Admin dashboard. The report can be downloaded into a Pdf format by clicking on the download button.
Custom widget generator tool
In addition to already available widgets in the Analytics dashboards, this feature makes it easier for users to implement their own custom widgets to use them across analytics dashboards. It helps to automatically generate a widget skeleton based on user preferences through a command-line tool that utilizes ReactJS utilities to build. The tool generates three types of widget templates (Subscriber widgets, Publisher Widgets, and Stand-alone Widgets) which supports both RDBMS Data Provider and SiddhiStore Data Provider. By default, the widget generator will generate a subscriber widget using SiddhiStore Data Provider. Visit the WSO2 website for more details.
White Labeling for Tenants
APIM analytics allow us to add an analytics dashboard for tenants. This feature provides the system admins an easier approach to white label the analytics dashboard by changing the logo image and the favicon. The system admin does not need to have React, CSS, or HTML knowledge to do this customization. All you need to do is to place the required images inside the respective tenant folder and update the directives in the configuration file so that the server will pick those directives and display the respective images based on the tenant who is currently logged in to the system.
The below dashboard shows analytics for a sample tenant yenlo.com.
To configure this, go to <API-M_ANALYTICS_HOME>/wso2/dashboard/deployment/web-ui-apps/analytics-dashboard/public/ directory and create a directory with the name of the tenant : yenlo.com
Create the following folder structure inside the tenant folder and add the relevant logo and favicon file.
Restart the analytics-dashboard for tenant yenlo.com to see the white label/ logo changes as shown below on the Analytics dashboard.
Duplicating existing dashboards
APIM-Analytics allows users to modify one of the default dashboards (APIM Admin, APIM Developer Portal and APIM Publisher) by making a copy of the dashboards without modifying the original ones.
When we click on design option on the duplicated dashboard, it will direct to the design portal where customization of the copied dashboard can be done.
Publishing Custom Attributes
WSO2 API Manager's gateway component publishes attributes of each API call to the Analytics Server. These details are published in the form of events and then summarized and persisted in the database. However, not all information related to the request is published to the Analytics Server by default (ex: header, payload). We can engage a custom mediation sequence in request or response path If we need to publish custom attributes of an API call for later analysis. Visit the WSO2 website for more details.
Analytics data fetched can be viewed by applying filters on the data. This can be done by clicking on the search button on each widget and providing the necessary inputs to the fields.
WSO2 API manager Analytics 3.1.0 offers many interesting features compared to the previous releases. If you have any questions on these features or on any other topic of API Management, please leave a comment below or contact us.