Scenario 7 - Analytics¶
This is a tutorial that is part of a series and can be used as a standalone tutorial on how to set up and view analytics for an API. For more details on the scenario and general prerequisites, please see the scenario overview page.
Time to Complete : 5 minutes
User story¶
GOGO Transit has identified a new business opportunity; since the train arrival data contains the number of passengers in each arrival, it could be used to predict the crowd in the station for a certain time period. Therefore, the services built around the station such as stores in the mall and cab services could use this data to optimize the number of employees they require for the services for each day. Thus, GOGO Transit decides to provide the passenger details API to the public with the subscription capability that generates revenue based on the number of successful requests completed within a time period.
Choreo API-M Analytics can be used to fulfill the stats and analytics needs of the API Manager. It is a cloud analytics offering for the Choreo API Manager and On-Prem API Manager deployments.
Step 1: Set up analytics¶
Before you begin...
You need to be a registered user to follow the steps below. Refer the Analytics Getting Started Guide for instructions.
To configure analytics,
- Sign up to https://console.choreo.dev/login/.
- Go to https://console.choreo.dev/user-settings/onpremkeys and generate a key
- Open the
/dockerfiles/conf/apim/repository/conf/deployment.toml
file and update the[apim.analytics]
configuration similar to the following. -
Restart the api-manager container using the following command.
Step 2: Try it out¶
Let’s generate some traffic. We have deployed an API (PassengerInfoAPI) in super tenant domain.
- Go to the https://localhost:9443/devportal/ and select carbon.super tenant domain.
- Log on using
peter
with passworduser123
and subscribe to PassengerInfoAPI API and generate an access token. - Invoke the API using the token.
curl -X GET "https://localhost:8243/info/1.0.0/passenger-count" -H "accept: application/json" -H "Authorization: Bearer <token>" -k
Go to Choreo Insights to view statistics. Following are some of the graphs.
What's next¶
Try out the next scenario in the series, Rate Limiting.