CA API Developer Portal: Analytics fail to populate

Document ID : KB000105951
Last Modified Date : 16/07/2018
Show Technical Document Details
Issue:
When navigating to the Portal Analytics page you may experience one or both of the below symptoms:

1) You are presented with an error message: 

"Unable to fetch analytics data. Please contact Portal Administrator." 

2) The page header loads but the body remains blank. You may notice HTTP 401 errors on the below URI's in the browser dev tools

/jarvis/LDDS-rest/masthead?type=product
/jarvis/LDDS-rest/masthead?type=tenant 
/jarvis/LDDS-rest/account 

 
Resolution:
This can occur for various reasons but usually occurs because Jarvis and/or the portal tenants have not been properly on-boarded with the Portal. In some older versions of Portal (4.2.5) there were instances were Jarvis was not properly on-boarded during the initial setup.

First you should confirm that Jarvis is properly on-boarded

1) Log in to the Portal host via SSH
2) Execute the below command to connect the the LDDS container:
docker exec -it $(docker ps --filter name=portal_ldds-web -q) sh

3) Run the below curl command:
curl -v http://apis:8080/onboarding/products

The expected result will be a JSON document with details regarding Jarvis (formatted below for readability). If this does not return something similar or simply returns empty JSON (ie: {}). You will need to proceed to step 4, otherwise proceed to step 5.

{
    "products": [{
        "product_id": "ca_apim",
        "product_name": "APIM Portal Analytics"
    }, {
        "product_id": "jarvis",
        "product_description": "Created internal product: jarvis",
        "product_name": "jarvis"
    }]
}

4) On-board Jarvis:

Execute the below command to connect the the LDDS container:

docker exec -it $(docker ps --filter name=portal_ldds-web -q) sh

4a) Run the below command:
curl -X POST http://apis:8080/onboarding/products -w " Response Code %{http_code}" -H 'Content-Type: application/json' -d '{"product_id":"ca_apim","product_name":"APIM Portal Analytics"}'

The expected result with be a HTTP 204 (Success, no content returned)

4b) Type exit to exit the LDDS container and return to the Portal host.

5) On-board the tenant(s):

Run the following command:
docker service inspect portal_analytics-server | grep JARVIS

6) Copy the JARVIS_PRODUCT_ID and JARVIS_URL for later use.

EXAMPLE
  JARVIS_URL=http://apis:8080/",
  JARVIS_PRODUCT_ID=ca_apim
  
7) Run the following command:
docker exec -it $(docker ps --filter name=portal_analytics-server -q) curl http://tenant-provisioner:9000/tenants
 
This will return a JSON document with details regarding your registered tenants.
 
8) Copy the tenant's uuid, tenantId, and portalName for later use. You may have multiple tenants registered, in this case if you wish to update all of them you will need to copy these details for each tenant returned.

9) Run the following command to connect to the Portal_APIS container:
docker exec -it $(docker ps --filter name=portal_apis -q) sh
 
10) Run the below curl command replacing the details in the angle brackets <> with the values obtained in step 8. Be sure to remove the angle brackets.
curl -X POST "http://<Jarvis_URL>:8080/onboarding/tenants" -w " Response Code %{http_code}" -H 'Content-Type: application/json' -d '{"product_id":"<Jarvis Product ID>","tenant_id":"<tenant UUID>","tenant_details":{ "retention_period":365, "tenantName":"<tenant ID>", "portalName":"<portal name>"}}'

The expected result with be either a HTTP 204 (Success, no content returned) or a HTTP 400 with a message indicating the tenant already exists. Should you receive a message indicating that the product ID does not exist you will need to execute step 4 again substituting the product ID and product name return in step 7.

ie: {"_message":"Tenant already exists.","_code":"1003"} Response Code 400

11) Type exit to exit the container
12) Run the following command to connect to the LDDS container:
docker exec -it $(docker ps --filter name=portal_ldds-web -q) sh
 
13)  Run the below curl command replacing the details in the angle brackets <> with the values obtained in step 8. Be sure to remove the angle brackets.
curl -X POST http://localhost:8080/LDDS-rest/onboarding/product/<JARVIS_PRODUCT_ID>/tenant -w " Response Code %{http_code}" -H 'Content-Type: application/json' -d '{ "tenantCode":"<tenant UUID>", "productAdminRoleName":"PA", "adminRoleName":"TA", "userRoleName":"OA", "ana":"ingress"}'
 
This is expected to return a JSON response with an HTTP 200 return code.
 
14) Type exit to exit the container.

Analytics should now be functional. Log in to your Portal and confirm by going to the Monitor page.