Integrate Moesif with WSO2 API Manager
This document describes how to integrate Moesif with WSO2 API Manager.
This integration allows you to collect and dispatch API analytics data to Moesif where you can leverage various API and customer analytics to gain insights into API usage, traffic trends, and error tracking.
Supported Versions
Moesif integration is supported in WSO2 API Manager version 4.5.0 update level 11 and later. Make sure that you are using a compatible update level of WSO2 API Manager 4.5.0. See Updating WSO2 API Manager to update your WSO2 API Manager to the required or latest update level.
Analytics Data Flow
The Moesif integration captures both successful and failed API invocations in WSO2 API Manager and makes them available in your Moesif dashboards in near real-time. This allows for powerful analytics and monitoring capabilities.
The following steps cover the necessary steps to integrate Moesif with WSO2 API Manager.
Step 1: Set Up Your Moesif Account
1.1 Create an Account and Log In
If you haven’t already, sign up or log into your Moesif Web Portal.
1.2 Create a New Application
- Once logged in, create a new App from the “Get Started” page.
- Follow the setup steps and select Next.
- Moesif then shows you your Application ID. Copy this ID as since you will later use it to configure WSO2 API Manager.
You can always obtain your Moesif Application ID by following these steps any time:
- Log into Moesif Portal.
- Select the account icon to bring up the settings menu.
- Select Installation or API Keys.
- Copy your Moesif Application ID from the Collector Application ID field.
Step 2 - Configure WSO2 API Manager
To enable Moesif analytics in WSO2 APIM, update the deployment.toml
configuration file.
Step 2.1 - Configuring the deployment.toml
file.
The analytics type defaults to the Choreo-based analytics. To enable Moesif as the
analytics type, you must set the type
key to moesif
.
Open the <APIM-HOME>/repository/conf
directory. Then edit the apim.analyics
configuration in the deployment.toml
file with the following configuration:
[apim.analytics]
enable = true
type = "moesif"
properties."moesifKey" = "MOESIF_APPLICATION_ID"
properties."publisher.reporter.class" = "org.wso2.am.analytics.publisher.reporter.moesif.MoesifReporter"
logger.reporter.level = "INFO"
Replace MOESIF_APPLICATION_ID
with your Application ID that you obtained in step 1.2.
Analytics Log Events
This section describes the details that are available in analytics log events.
Event apim_event_response
The apim_event_response
event triggers for each successful API invocation. When
an API-associated backend returns an error response, the same event triggers and
logs the event details.
{
"apiCreator":"admin",
"apiCreatorTenantDomain":"carbon.super",
"apiId":"43d030dc-427f-4678-98e3-87b7d9882b5f",
"apiMethod":"GET",
"apiName":"SampleAPI",
"apiResourceTemplate":"/*",
"apiType":"HTTP",
"apiVersion":"1.0.0",
"applicationId":"2d6c54b0-7c7d-4b50-83dc-e6ae6f88962e",
"applicationName":"DefaultApplication",
"applicationOwner":"admin",
"backendLatency":13,
"correlationId":"79ed20c3-55b1-434a-adf6-eea25e2d09c3",
"destination":"http://192.168.114.51:8281/services/sampleAPIBackend",
"eventType":"response",
"gatewayType":"SYNAPSE",
"keyType":"SANDBOX",
"userName":"admin@carbon.super",
"proxyResponseCode":202,
"regionId":"default",
"requestMediationLatency":54,
"requestTimestamp":"2022-01-20T03:34:36.451Z",
"responseCacheHit":false,
"responseLatency":73,
"responseMediationLatency":6,
"targetResponseCode":202,
"userAgent":"Chrome",
"userIp":"172.16.2.70",
"properties":{
"commonName":"N/A",
"responseContentType":"application/json; charset=UTF-8",
"subType":"DEFAULT",
"isEgress":false,
"apiContext":"/api1/2.0.0",
"responseSize":133,
"userName":"admin@carbon.super"
}
}
Event apim_event_faulty
The apim_event_faulty
event triggers for each failed and throttled API invocation.
{
"apiCreator":"admin",
"apiCreatorTenantDomain":"carbon.super",
"apiId":"43d030dc-427f-4678-98e3-87b7d9882b5f",
"apiName":"SampleAPI",
"apiType":"HTTP",
"apiVersion":"1.0.0",
"apiMethod":"GET",
"apiResourceTemplate":"/publish",
"applicationId":"0b5ccc91-30e2-4ee5-9355-d1698075c028",
"applicationName":"SampleApp3",
"applicationOwner":"admin",
"correlationId":"ccf2196f-9db8-429b-aaae-98f4c6edf6d7",
"errorCode":900803,
"errorMessage":"APPLICATION_LEVEL_LIMIT_EXCEEDED",
"errorType":"THROTTLED",
"eventType":"fault",
"gatewayType":"SYNAPSE",
"keyType":"PRODUCTION",
"proxyResponseCode":429,
"regionId":"default",
"requestTimestamp":"2022-02-01T04:18:48.023Z",
"responseCacheHit":false,
"targetResponseCode":-1,
"properties":{
"commonName":"N/A",
"responseContentType":"application/json; charset=UTF-8",
"subType":"DEFAULT",
"isEgress":false,
"apiContext":"/api1/2.0.0",
"responseSize":133,
"userName":"admin@carbon.super"
}
}
The following table describes the different entities in the analytics log events data:
Parameter | Type | Description |
---|---|---|
apiCreator |
string | The creator of the API. |
apiCreatorTenantDomain |
string | The tenant domain of the API creator. |
apiId |
string | Unique identifier of the API. |
apiMethod |
string | The HTTP method used by the API—for example, GET , POST . |
apiName |
string | The name of the API. |
apiResourceTemplate |
string | The template of the API resource accessed. |
apiType |
string | The type of the API, for example, HTTP, REST. |
apiVersion |
string | The version of the API. |
applicationId |
string | Unique identifier of the application that makes the API call. |
applicationName |
string | Name of the application that makes the API call. |
applicationOwner |
string | Owner of the application that makes the API call. |
backendLatency |
long | The time taken by the backend to process the request. |
correlationId |
string | Unique identifier for tracking API calls. |
destination |
string | The backend URL to which the API call was redirected. |
eventType |
string | The type of event. |
gatewayType |
string | The type of the API gateway. |
keyType |
string | Indicates whether the API key used was for SANDBOX or PRODUCTION. |
platform |
string | Operating system was used to access the API. |
properties |
object | Properties of the event. |
apiContext |
string | The context of the API call. |
userName |
string | The username of the individual who made the API call. |
proxyResponseCode |
int | The HTTP response code returned by the API gateway. |
regionId |
string | The region identifier for the API call. |
requestMediationLatency |
int | Time taken for request mediation. |
requestTimestamp |
long | Timestamp when the request was made. |
responseCacheHit |
bool | Indicates if the response was served from cache. |
responseLatency |
long | Total time taken to respond to the request. |
responseMediationLatency |
long | Time taken for response mediation. |
targetResponseCode |
int | The HTTP response code received from the backend target. |
userAgent |
string | The user agent of the client making the API call. |
userIp |
string | The IP address of the user making the API call. |
errorCode |
int | The error code generated in a fault. |
errorMessage |
string | The error message associated with the fault. |
errorType |
string | The type of error—for example,THROTTLED . |
Learn More
- Get started with Moesif.
- Learn how to identify customers.
- Learn about dashboards and workspaces.
- Learn to set up real-time monitoring and alerts.
- Invite team members to collaborate.