Introduction
This section describes and illustrates the API Manager statistic publishing and generating model. It describes the internal components of API Manager, external analyzer information and other data retrieval components. API Manager generates events based on the API Manager invocation pattern and publishes them to all the listening event analyzers. The analyzer is responsible for the accumulation of all events and generates summary data based on the defined summarization logic. After the summarized data is generated, the API Manager Dashboard can retrieve statistics from the analyzer data-source to the UI via the API Manager analytics client.
API Manager usage publisher
The internal API Manager component listens to the API Manager invocations and its behavior. Based on the request and responses, the event is generated and published to all the event receivers. This publisher publishes the following event streams,
org.wso2.apimgt.statistics.request
org.wso2.apimgt.statistics.fault
org.wso2.apimgt.statistics.throttle
API Manager event streams
API-M provides the following types of event streams as listed below.
org.wso2.apimgt.statistics.request
This stream tracks information for the API request.
meta_clientType | : string | : Meta information of Client type |
applicationConsumerKey | : string | : Consumer key of API invoked client application |
applicationName | : string | : Name of the client application |
applicationId | : string | : ID of the client application |
applicationOwner | : string | : Name of the Owner of the Application |
apiContext | : string | : API context depending on the user's request |
apiName | : string | : API Name |
apiVersion | : string | : API version |
apiResourcePath | : string | : API resource path of the API request |
apiResourceTemplate | : string | : API resource URL pattern of API request |
apiMethod | : string | : HTTP Verb of API request [e.g.,GET/POST] |
apiCreator | : string | : Creator of the API |
apiCreatorTenantDomain | : string | : Tenant domain of the API creator |
apiTier | : string | : Subscription tier associated with the API request |
apiHostname | : string | : Hostname or Datacenter ID (if specified) |
username | : string | : Enduser of the API request |
userTenantDomain | : string | : Tenant domain of the user associated with the request |
userIp | : string | : IP address of the client |
userAgent | : string | : User agent of the user |
requestTimestamp | : long | : Timestamp of the API request when received to the gateway |
throttledOut | : bool | : Describes whether the request was allowed after hitting the throttle tier |
responseTime | : long | : Timestamp of the API response when received to the gateway |
serviceTime | : long | : Time taken to serve the API request in APIM side |
backendTime | : long | : Time taken to process the request at the backend |
responseCacheHit | : bool | : Describes if response caching is enabled or not |
responseSize | : long | : Response message size in bytes |
protocol | : string | : Protocol used to send the response (HTTP/HTTPS) and the port |
responseCode | : int | : HTTP Response Code |
destination | : string | : URL of the endpoint |
securityLatency | : long | : Time taken for authentication |
throttlingLatency | : long | : Time taken for throttling the request/response |
requestMediationLatency | : long | : Time taken to mediate the request |
responseMediationLatency | : long | : Time taken to mediate the response |
backendLatency | : long | : Time taken by the backend to return the response |
otherLatency | : long | : Time taken to process tasks other than mentioned above |
gatewayType | : string | : The gateway type (Synapse/Micro) |
label | : string | : The label of the API (if specified |
org.wso2.apimgt.statistics.fault
This stream contains the fault API invocations. It includes the API with back end errors, timeout etc.
meta_clientType | : string | : Meta information of Client type |
applicationConsumerKey | : string | : Consumer key of API invoked client application |
apiName | : string | : API Name |
apiVersion | : string | : API Version |
apiContext | : string | : API context depending on the user's request |
apiResourcePath | : string | : API resource path of the API request |
apiMethod | : string | : HTTP Verb of API request [e.g.,GET/POST] |
apiCreator | : string | : Creator of the API |
username | : string | : Enduser of the API request |
userTenantDomain | : string | : Tenant domain of the user associated with the request |
apiCreatorTenantDomain | : string | : Tenant domain of the API creator |
hostname | : string | : Hostname or Datacenter ID (if specified) |
applicationId | : string | : ID of the client application |
applicationName | : string | : Name of the client application |
protocol | : string | : Protocol used to send the response (HTTP/HTTPS) and the port |
errorCode | : string | : Synapse error code |
errorMessage | : string | : Description of the synapse error message |
requestTimestamp | : long | : Timestamp of the API request when received to the gateway |
org.wso2.apimgt.statistics.throttle
This stream contains the API invocation with throttle information. Throttling can happen due to any of the following reasons:
The application limit has exceeded.
The resource limit has exceeded.
The API limit has exceeded.
The hard level limit has exceeded.
meta_clientType | : string | : Meta information of Client type |
username | : string | : Enduser of the API request |
userTenantDomain | : string | : Tenant domain of the user associated with the request |
apiName | : string | : API Name |
apiVersion | : string | : API Version |
apiContext | : string | : API context depending on the user's request |
apiCreator | : string | : Creator of the API |
apiCreatorTenantDomain | : string | : Tenant domain of the API creator |
applicationId | : string | : ID of the client application |
applicationName | : string | : Name of the client application |
subscriber | : string | : Name of the subscriber of the Application |
throttledOutReason | : string | : The reason describing why the request has been throttled out |
gatewayType | : string | : The gateway type (Synapse/Micro) |
throttledOutTimestamp | : long | : Timestamp when the request is throttled out |
API Manager aggregate tables
The summarized tables are stored in the APIM Analytics internal storage. All events are stored in tables based on granularity (SECONDS, MINUTES, HOURS, DAYS, MONTHS, YEARS
). Each such table contains the aggregation of stream data per granularity level. For example, each record of the _HOURS
table contains the aggregate of the events that arrived each hour.
It is important to note that directly querying the tables is not recommended and instead you can use the WSO2 Stream Processor REST APIs (for retrieving from aggregations), similar to what has been done in API Manager Analytics for Publisher and Store statistic graphs.
The reason for this recommendation is because of the granular level aggregations that are present for a single event use case. Events are processed in-memory before adding them to the granular level tables. Therefore, if queried directly from the database, and if there are any aggregate data related to an ongoing operation, such aggregated data will not be taken into consideration. Furthermore, retrieving information directly from the tables will result in complex queries. Therefore, you can use the Stream Processor REST APIs for querying the tables in order to easily obtain accurate information, because all workings are handled internally by the Stream Processor REST APIs.
Siddhi Apps, which are deployed in the Worker profile of API Manager Analytics instance, are used in order to populate data to the aggregate tables. The latter mentioned Siddhi Apps are available in the <API-M_ANALYTICS_HOME>/wso2/worker/deployment/siddhi-files
directory. The following are the Siddhi Apps that are used for storing data required for charts and graphs:
APIM_ACCESS_SUMMARY.siddhi
APIM_FAULT_SUMMARY.siddhi
APIM_THROTTLED_OUT_SUMMARY.siddhi
The following subsections describe the table schema of each of the Aggregate tables that are present in the Statistics DB.
ApiUserPerAppAgg
This aggregation contains summary data from the request event stream and you can use it to obtain information about each API request.
ApiUserPerAppAgg Table Schema
This schema resembles the the API_REQUEST_SUMMARY
table from the previous Stat DB schema.
CREATE TABLE `ApiUserPerAppAgg_<granularity>` ( `AGG_TIMESTAMP` bigint(20) NOT NULL, `AGG_EVENT_TIMESTAMP` bigint(20) NOT NULL, `apiContext` varchar(254) NOT NULL, `apiHostname` varchar(254) NOT NULL, `applicationId` varchar(254) NOT NULL, `username` varchar(254) NOT NULL, `userTenantDomain` varchar(254) NOT NULL, `AGG_LAST_EVENT_TIMESTAMP` bigint(20) DEFAULT NULL, `apiName` varchar(254) DEFAULT NULL, `apiVersion` varchar(254) DEFAULT NULL, `apiCreator` varchar(254) DEFAULT NULL, `apiCreatorTenantDomain` varchar(254) DEFAULT NULL, `applicationName` varchar(254) DEFAULT NULL, `applicationOwner` varchar(254) DEFAULT NULL, `gatewayType` varchar(254) DEFAULT NULL, `label` varchar(254) DEFAULT NULL, `regionalID` varchar(254) DEFAULT NULL, `AGG_COUNT` bigint(20) DEFAULT NULL, PRIMARY KEY (`AGG_TIMESTAMP`,`AGG_EVENT_TIMESTAMP`,`apiContext`,`apiHostname`,`applicationId`,`username`,`userTenantDomain`) )
ApiResPathPerApp
This aggregation contains summarized data about API usage by resources and it is also derived from the request event stream.
ApiResPathPerApp Table Schema
This schema resembles the API_Resource_USAGE_SUMMARY
table from the previous Stat DB schema.
CREATE TABLE `ApiResPathPerApp_<granularity>` ( `AGG_TIMESTAMP` bigint(20) NOT NULL, `AGG_EVENT_TIMESTAMP` bigint(20) NOT NULL, `apiContext` varchar(254) NOT NULL, `apiHostname` varchar(254) NOT NULL, `applicationId` varchar(254) NOT NULL, `apiResourceTemplate` varchar(254) NOT NULL, `apiMethod` varchar(254) NOT NULL, `AGG_LAST_EVENT_TIMESTAMP` bigint(20) DEFAULT NULL, `apiName` varchar(254) DEFAULT NULL, `apiVersion` varchar(254) DEFAULT NULL, `apiCreator` varchar(254) DEFAULT NULL, `apiCreatorTenantDomain` varchar(254) DEFAULT NULL, `applicationName` varchar(254) DEFAULT NULL, `gatewayType` varchar(254) DEFAULT NULL, `label` varchar(254) DEFAULT NULL, `regionalID` varchar(254) DEFAULT NULL, `AGG_COUNT` bigint(20) DEFAULT NULL, PRIMARY KEY (`AGG_TIMESTAMP`,`AGG_EVENT_TIMESTAMP`,`apiContext`,`apiHostname`,`applicationId`,`apiResourceTemplate`,`apiMethod`) )
ApiPerDestinationAgg
This aggregation contains summarized data of API destinations and is derived from the request event stream.
ApiPerDestinationAgg Table Schema
This schema resembles the API_DESTINATION_SUMMARY
table from the previous Stat DB schema.
CREATE TABLE `ApiPerDestinationAgg_<granularity>` ( `AGG_TIMESTAMP` bigint(20) NOT NULL, `AGG_EVENT_TIMESTAMP` bigint(20) NOT NULL, `apiContext` varchar(254) NOT NULL, `apiHostname` varchar(254) NOT NULL, `destination` varchar(254) NOT NULL, `AGG_LAST_EVENT_TIMESTAMP` bigint(20) DEFAULT NULL, `apiName` varchar(254) DEFAULT NULL, `apiVersion` varchar(254) DEFAULT NULL, `apiCreator` varchar(254) DEFAULT NULL, `apiCreatorTenantDomain` varchar(254) DEFAULT NULL, `gatewayType` varchar(254) DEFAULT NULL, `label` varchar(254) DEFAULT NULL, `regionalID` varchar(254) DEFAULT NULL, `AGG_COUNT` bigint(20) DEFAULT NULL, PRIMARY KEY (`AGG_TIMESTAMP`,`AGG_EVENT_TIMESTAMP`,`apiContext`,`apiHostname`,`destination`) )
ApiVersionPerAppAgg
This aggregation contains summarized data about API usage and is also derived from the request event stream.
ApiVersionPerAppAgg Table Schema
This schema resembles the API_VERSION_USAGE_SUMMARY
table from the previous Stat DB schema.
CREATE TABLE `ApiVersionPerAppAgg_<granularity>` ( `AGG_TIMESTAMP` bigint(20) NOT NULL, `AGG_EVENT_TIMESTAMP` bigint(20) NOT NULL, `apiContext` varchar(254) NOT NULL, `apiHostname` varchar(254) NOT NULL, `applicationId` varchar(254) NOT NULL, `AGG_LAST_EVENT_TIMESTAMP` bigint(20) DEFAULT NULL, `apiName` varchar(254) DEFAULT NULL, `apiVersion` varchar(254) DEFAULT NULL, `apiCreator` varchar(254) DEFAULT NULL, `apiCreatorTenantDomain` varchar(254) DEFAULT NULL, `applicationName` varchar(254) DEFAULT NULL, `gatewayType` varchar(254) DEFAULT NULL, `label` varchar(254) DEFAULT NULL, `regionalID` varchar(254) DEFAULT NULL, `AGG_COUNT` bigint(20) DEFAULT NULL, `AGG_SUM_quotaExceededValue` bigint(20) DEFAULT NULL, PRIMARY KEY (`AGG_TIMESTAMP`,`AGG_EVENT_TIMESTAMP`,`apiContext`,`apiHostname`,`applicationId`) )
ApiExeTime
This aggregation contains information related to API invocation including timestamps and the time taken by the API at different stages of invocation such as service time, backend time etc. This is also derived from the request event stream.
ApiExeTime Table Schema
This schema resembles the API_EXE_TIME_<time>_SUMMARY
table from the previous Stat DB schema.
CREATE TABLE `ApiExeTime_<granularity>` ( `AGG_TIMESTAMP` bigint(20) NOT NULL, `AGG_EVENT_TIMESTAMP` bigint(20) NOT NULL, `apiContext` varchar(254) NOT NULL, `apiHostname` varchar(254) NOT NULL, `apiResourceTemplate` varchar(254) NOT NULL, `apiMethod` varchar(254) NOT NULL, `AGG_LAST_EVENT_TIMESTAMP` bigint(20) DEFAULT NULL, `apiName` varchar(254) DEFAULT NULL, `apiVersion` varchar(254) DEFAULT NULL, `apiCreator` varchar(254) DEFAULT NULL, `apiCreatorTenantDomain` varchar(254) DEFAULT NULL, `regionalID` varchar(254) DEFAULT NULL, `AGG_SUM_responseTime` bigint(20) DEFAULT NULL, `AGG_COUNT` bigint(20) DEFAULT NULL, `AGG_SUM_serviceTime` bigint(20) DEFAULT NULL, `AGG_SUM_backendTime` bigint(20) DEFAULT NULL, `AGG_SUM_securityLatency` bigint(20) DEFAULT NULL, `AGG_SUM_throttlingLatency` bigint(20) DEFAULT NULL, `AGG_SUM_requestMedLat` bigint(20) DEFAULT NULL, `AGG_SUM_responseMedLat` bigint(20) DEFAULT NULL, `AGG_SUM_backendLatency` bigint(20) DEFAULT NULL, `AGG_SUM_otherLatency` bigint(20) DEFAULT NULL, PRIMARY KEY (`AGG_TIMESTAMP`,`AGG_EVENT_TIMESTAMP`,`apiContext`,`apiHostname`,`apiResourceTemplate`,`apiMethod`) )
ApiUserBrowserAgg
This aggregation contains information regarding the user browser summary derived from the request event stream.
ApiUserBrowserAgg Table Schema
This schema resembles the API_REQ_USER_BROW_SUMMARY
table from the previous Stat DB schema
CREATE TABLE `ApiUserBrowserAgg_<granularity>` ( `AGG_TIMESTAMP` bigint(20) NOT NULL, `AGG_EVENT_TIMESTAMP` bigint(20) NOT NULL, `apiContext` varchar(254) NOT NULL, `apiCreator` varchar(254) NOT NULL, `apiCreatorTenantDomain` varchar(254) NOT NULL, `operatingSystem` varchar(254) NOT NULL, `browser` varchar(254) NOT NULL, `AGG_LAST_EVENT_TIMESTAMP` bigint(20) DEFAULT NULL, `apiName` varchar(254) DEFAULT NULL, `apiVersion` varchar(254) DEFAULT NULL, `gatewayType` varchar(254) DEFAULT NULL, `label` varchar(254) DEFAULT NULL, `regionalID` varchar(254) DEFAULT NULL, `AGG_COUNT` bigint(20) DEFAULT NULL, PRIMARY KEY (`AGG_TIMESTAMP`,`AGG_EVENT_TIMESTAMP`,`apiContext`,`apiCreator`,`apiCreatorTenantDomain`,`operatingSystem`,`browser`) )
APIM_ReqCountAgg
This aggregation is derived from the throttle event stream and the request event stream and provides information regarding the throttled out counts and success counts for a particular API.
APIM_ReqCountAgg Table Schema
CREATE TABLE `APIM_ReqCountAgg_<granularity>` ( `AGG_TIMESTAMP` bigint(20) NOT NULL, `AGG_EVENT_TIMESTAMP` bigint(20) NOT NULL, `apiName` varchar(254) NOT NULL, `apiVersion` varchar(254) NOT NULL, `apiCreator` varchar(254) NOT NULL, `apiCreatorTenantDomain` varchar(254) NOT NULL, `applicationName` varchar(254) NOT NULL, `AGG_LAST_EVENT_TIMESTAMP` bigint(20) DEFAULT NULL, `regionalID` varchar(254) DEFAULT NULL, `AGG_SUM_successCount` bigint(20) DEFAULT NULL, `AGG_SUM_throttleCount` bigint(20) DEFAULT NULL, PRIMARY KEY (`AGG_TIMESTAMP`,`AGG_EVENT_TIMESTAMP`,`apiName`,`apiVersion`,`apiCreator`,`apiCreatorTenantDomain`,`applicationName`) )
ApiLastAccessSummary
This table is not an aggregation. It contains information regarding the last access times of the APIs and is derived from the request event stream.
ApiLastAccessSummary Table Schema
This schema resembles the API_LAST_ACCESS_TIME_SUMMARY
table from the previous Stat DB schema.
CREATE TABLE `ApiLastAccessSummary` ( `apiContext` varchar(254) DEFAULT NULL, `apiName` varchar(254) NOT NULL, `apiVersion` varchar(254) DEFAULT NULL, `apiCreator` varchar(254) NOT NULL, `apiCreatorTenantDomain` varchar(254) NOT NULL, `applicationOwner` varchar(254) DEFAULT NULL, `lastAccessTime` bigint(20) DEFAULT NULL, PRIMARY KEY (`apiName`,`apiCreator`,`apiCreatorTenantDomain`) )
GeoLocationAgg
This aggregation contains summarized information regarding the geolocation statistics of API requests and is derived from the request event stream.
GeoLocationAgg Table Schema
This schema resembles the API_REQ_GEO_LOC_SUMMARY
table from the previous Stat DB schema.
CREATE TABLE `GeoLocationAgg_<granularity>` ( `AGG_TIMESTAMP` bigint(20) NOT NULL, `AGG_EVENT_TIMESTAMP` bigint(20) NOT NULL, `apiContext` varchar(254) NOT NULL, `country` varchar(254) NOT NULL, `city` varchar(254) NOT NULL, `AGG_LAST_EVENT_TIMESTAMP` bigint(20) DEFAULT NULL, `apiName` varchar(254) DEFAULT NULL, `apiVersion` varchar(254) DEFAULT NULL, `apiCreator` varchar(254) DEFAULT NULL, `apiCreatorTenantDomain` varchar(254) DEFAULT NULL, `username` varchar(254) DEFAULT NULL, `userTenantDomain` varchar(254) DEFAULT NULL, `totalCount` bigint(20) DEFAULT NULL, `regionalID` varchar(254) DEFAULT NULL, PRIMARY KEY (`AGG_TIMESTAMP`,`AGG_EVENT_TIMESTAMP`,`apiContext`,`country`,`city`) )
ApiFaultyInvocationAgg
This aggregation contains summarized data of the faulty API invocations and is derived from the fault event stream.
ApiFaultyInvocationAgg Table Schema
This schema resembles the API_FAULT_SUMMARY
table from the previous Stat DB schema.
CREATE TABLE `ApiFaultyInvocationAgg_<granularity>` ( `AGG_TIMESTAMP` bigint(20) NOT NULL, `AGG_EVENT_TIMESTAMP` bigint(20) NOT NULL, `apiContext` varchar(254) NOT NULL, `applicationId` varchar(254) NOT NULL, `hostname` varchar(254) NOT NULL, `AGG_LAST_EVENT_TIMESTAMP` bigint(20) DEFAULT NULL, `apiName` varchar(254) DEFAULT NULL, `apiVersion` varchar(254) DEFAULT NULL, `apiCreator` varchar(254) DEFAULT NULL, `apiCreatorTenantDomain` varchar(254) DEFAULT NULL, `applicationConsumerKey` varchar(254) DEFAULT NULL, `applicationName` varchar(254) DEFAULT NULL, `requestTimestamp` bigint(20) DEFAULT NULL, `regionalID` varchar(254) DEFAULT NULL, `AGG_COUNT` bigint(20) DEFAULT NULL, PRIMARY KEY (`AGG_TIMESTAMP`,`AGG_EVENT_TIMESTAMP`,`apiContext`,`applicationId`,`hostname`) )
ApiThrottledOutAgg
This aggregation contains summarized data of the throttled out API invocations. This information is derived from the throttle event stream.
ApiThrottledOutAgg Table Schema
This schema resembles the API_THROTTLED_OUT_SUMMARY
table from the previous Stat DB schema.
CREATE TABLE `ApiThrottledOutAgg_<granularity>` ( `AGG_TIMESTAMP` bigint(20) NOT NULL, `AGG_EVENT_TIMESTAMP` bigint(20) NOT NULL, `apiContext` varchar(254) NOT NULL, `applicationId` varchar(254) NOT NULL, `throttledOutReason` varchar(254) NOT NULL, `hostname` varchar(254) NOT NULL, `AGG_LAST_EVENT_TIMESTAMP` bigint(20) DEFAULT NULL, `apiName` varchar(254) DEFAULT NULL, `apiVersion` varchar(254) DEFAULT NULL, `apiCreator` varchar(254) DEFAULT NULL, `apiCreatorTenantDomain` varchar(254) DEFAULT NULL, `username` varchar(254) DEFAULT NULL, `userTenantDomain` varchar(254) DEFAULT NULL, `applicationName` varchar(254) DEFAULT NULL, `subscriber` varchar(254) DEFAULT NULL, `gatewayType` varchar(254) DEFAULT NULL, `regionalID` varchar(254) DEFAULT NULL, `AGG_COUNT` bigint(20) DEFAULT NULL, PRIMARY KEY (`AGG_TIMESTAMP`,`AGG_EVENT_TIMESTAMP`,`apiContext`,`applicationId`,`throttledOutReason`,`hostname`) )
API Manager statistics
API statistics are provided in both the API Publisher and the API Store. Apart from the number of subscriptions per API, all other statistical dashboards require an instance of WSO2 Data Analytics Server installed. For information on the available statistics and how to view them, see Viewing API Statistics.