WSO2 APIM Correlating analytics event with correlationID

Sometimes it is required to correlate request, response in the gateway messages. This is required if you try to debug, monitor and analyse the messages. But this feature is not support APIM out of the box. But still you can use the APIM extension point to extract required information to implement custom monitoring mechanism. Also note that this CorrelationID is introduce to the event since APIM 2.2.0.

We can list down following use cases,

  1. Analyse request/response messages
  2. Analyse the request and fault, throttled requests
  3. Troubleshoot apim analytics
  4. Analyse the request path

correlationID is a UUID which is APIM introduced to the synapse context and it is a unique to the complete API request path. Which mean a request come to gateway can identify with UUID and it not get changed and will be consistent whether it is a faulty or throttled out. So it is easy to identify a request with it’s response path.

More importantly which can be used to identify the message attributes like headers and payload. But this is not possible to analyse with Analytics since those are not publisher to analyser. In such a cases it is better to analyse with gateway itself using tools available in the synapse like message ID, transaction ID or wire logs.

In order to analyse further with analyser correlationID is publish to the analyser. it is included into the all gateway to analyser events. Unfortunately this feature is not used any out of the box dashboards. But this is very useful if you have an idea to implement custom dashboards with a cumulative analytics event.

Here the sample request analytics event gateway publish to analyser. correlationID is include in the meta_clientType attribute as a json. And all other event used the same format to include correlationID.

 
    meta_clientType: {"keyType":"SANDBOX","correlationID":"97e758f7-0ac0-4cbc-aa0a-84a4fe9f96f1"},
    consumerKey:ivhMcN6YdASfwFIpfhvQjps2jbMa,
    context:/pizzashack/1.0.0,
    api_version:admin--PizzaShackAPI:v1.0.0,
    api:PizzaShackAPI,
    resourcePath:/menu,
    resourceTemplate:/menu,
    method:GET,
    version:1.0.0,
    request:1,
    requestTime:1526717879778,
    userId:admin@carbon.super,
    tenantDomain:carbon.super,
    hostName:192.168.56.1,
    apiPublisher:admin,
    applicationName:DefaultApplication,
    applicationId:1,
    userAgent:curl/7.47.0,
    tier:Unlimited,
    throttledOut:false,
    clientIp:192.168.56.1,
    applicationOwner:admin