Access the Choreo Insights API¶
The Usage Insights page in the Choreo Console displays data retrieved from the Insights API exposed over the Internet. However, in some scenarios, you may need to retrieve data from external systems and implement custom dashboards to display the data.
Choreo provides a secure and user-friendly approach to accomplish this requirement. Follow the steps given below:
Become a member of the Choreo System organization¶
-
Access the Developer Portal of the
Choreo System
organization via https://devportal.choreo.dev/choreosystem/applications and sign in using your preferred method. -
To obtain access to the
Choreo System
organization, click Request Access.
Create an application and generate keys¶
To create an application and generate keys, follow the steps below:
-
To create a new application in the
Choreo System
organization, click + Create Application. -
Enter a name for the application and click Create. This creates the application and takes you to the Overview page.
-
To subscribe to the Insights API via the newly created application, follow the steps below:
- In the left navigation menu, click Subscriptions.
- In the Subscription Management pane, click + Add APIs.
- Search for
Insights
and click Add.
-
To generate credentials for the application, follow the steps given below:
- In the left navigation menu, click Production under Credentials.
- Click Generate Credentials. Choreo generates tokens and populates the Consumer Key and Consumer Secret fields in the Application Keys pane.
-
To specify an appropriate token expiry time for the application, follow the steps given below:
-
Execute the following cURL command to generate an access token:
curl --location --request POST 'https://sts.choreo.dev/oauth2/token' \ --header 'Authorization: Basic <BASE64_ENCODED_CONSUMER_KEY_AND_CONSUMER_SECRET_OF_YOUR_APP_HERE>' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=client_credentials' \ --data-urlencode 'orgHandle=<YOUR_ORG_HANDLE_HERE>' \ --data-urlencode 'scope=apim:api_manage'
Info
To obtain your organization handle, follow the steps given below:
- Go to https://console.choreo.dev and sign in using your preferred method.
- In the Choreo Console, click your username in the top right corner.
- In the drop-down menu, click Settings.
- In the Organization pane, click Copy Handle.
You can use the generated token to access the Insights API exposed via https://choreocontrolplane.choreo.dev/93tu/insights/1.0.0/query-api.
The following is a sample cURL command to invoke the Insights API:
curl --location --request POST 'https://choreocontrolplane.choreo.dev/93tu/insights/1.0.0/query-api' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <TOKEN_HERE>' \ --data-raw '{"query":"query ($org: OrgFilter!) {listEnvironments(org: $org){id\n name}}","variables":{"org":{"orgId":"<ORG_UUID_HERE>"}}}'