Skip to content

mulesoft-catalyst/rtf-cloudhub-cores-calculator-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RTF CloudHub Cores Calculator API

Introduction

This API enables you to calculate the Runtime Fabric Cores being used by your Organization and business groups so that you are able to keep a tab on the usage of cores and stay within the license limits.

Additionally it also provides details of total CloudHub cores usage under each business group along with details of cores used by each Mule application.

MuleSoft License Compliance for RTF

Features of API

This API currently provides below functionalities -

  • Details of Cores used for Non-Prod and Prod
    • Per Application (Under each Environment)
    • Per Environment (Under each Business Group)
    • Per Business Group
    • Master Org
  • Consolidated Report in CSV format
    • Per Environment (Under each Business Group)
    • Per Business Group
    • Master Org

Prerequisite

  • Mule Runtime 4.2.2 or above
  • All deployments models are supported: CloudHub, OnPrem hosted Runtimes, Runtime Fabric
  • Anypoint Platform credentials - Two options are supported:
    • Anypoint Platform user with the Organization Administrator role, and CloudHub Admin role (or specific permissions - see connected app section). Both roles should be provided in the Master and all Sub Orgs for which you wish to gather data. The CloudHub Admin role is environment specific - therefore should be granted for each environment in each business group.
    • A Connected App (client credentials) with the following scopes (make sure to include all Sub Orgs and all environments you want to collect data):
      • Runtime Manager
        • Cloudhub Network Viewer
        • Read Alerts
        • Read Applications
        • Read Servers
      • Runtime Fabric
        • Read Runtime Fabrics
      • General
        • Profile
        • View Environment
        • View Organization

How to use the API?

**cURL command for Detailed Cores Usage Report - **

curl -L -X POST 'https://{{APP-URI-BASE-PATH}}/api/cores/calculate?filterEmptyOrg=true&includeCloudHub=true&consolidatedReport=false' \
-H 'responseType: json' \
-H 'authType: <insert authType value>' \
-H 'Authorization: Basic <insert base64 token>' \
-H 'Content-Type: application/json' \
--data-raw '{
  "masterOrgId": "<insert master-org-id>",
  "includeSubOrgs": true,
  "environments": "<insert environment type>"
}' -o <FileName>.json

The following is the explanation for the above URL

Method

POST

Headers

responseType: This API can provide you the response as a JSON Object. The values taken by this header are "json". The header is optional and if you don't provide a value, it defaults to JSON

authType: This API provides 2 modes of authentication. You can either use an Anypoint Username and Password or you can use Client ID and Client Secret generated by a Connected App that has been configured and given appropriate access. In both the cases you would need to ensure that you provide the right permissions to the user or to the connected app.

If using an individual user the value for the authType header is userpass

If using Connected App, the value of the authType header is connectedApp

This header is required.

Content-Type: Set this value to application/json

Authorization: This is the authorization header. This header is required.

When the authType is set to userpass, the value of this header is base64(anypoint_username:anypoint_password)

When the authType is set to connectedApp, the value of this header is base64(client_id:client_secret)

Body

The body for this call is as follows,

{
  "masterOrgId": "master-org-id",
  "includeSubOrgs": true,
  "environments": "type"
}

masterOrgId: This is the parent organization for which you need to get the core usage count. This parent organization may or may not have child organizations or business groups

includeSubOrgs: If your parent organization has one or more sub organizations in a nested structure and you want to get the core usage count for those as well, set this value to true. If you need to skip those, set it to false

environments: You can get a core count for either the Production or Non Production environments. If you only need to get a count of the production enviornments set this to production, else set it to sandbox

**Note - **The API takes around 5-6 minutes to return report for large organizations. This is due to the fact that certain platform APIs have rate limit restrictions due to which it can't be called too frequently.

There is a sleep in the implmentation to overcome this issue. However, the response time can be improved with parallel calls in future enhancements.

Sample response for Detailed Core Usage report -

{
    "Global Total RTF CPU Reserved": 7.05,
    "Global Total RTF CPU Limit": 19.68,
    "Global Total CloudHub vCores": 14.8,
    "Details": {
        "Product": {
            "BG RTF Total CPU Reserved": 0.2,
            "BG RTF Total CPU Limit": 7.9,
            "BG CH Total vCores": 0,
            "Details": [
                {
                    "Business Group": "Product",
                    "Environment": "Production",
                    "RTF Total CPU Reserved": 0.2,
                    "RTF Total CPU Limit": 7.9,
                    "CH Total vCores": 0,
                    "RTF Application Details": [
                        {
                            "applicationName": "app1",
                            "cpuReserved": 0.2,
                            "cpuLimit": 7.9
                        },
                        {
                            "applicationName": "app-sample",
                            "cpuReserved": 0,
                            "cpuLimit": 0
                        }
                    ]
                }
            ]
        },
        "Commercial": {
            "BG RTF Total CPU Reserved": 4,
            "BG RTF Total CPU Limit": 6,
            "BG CH Total vCores": 0,
            "Details": [
                {
                    "Business Group": "Commercial",
                    "Environment": "Production",
                    "RTF Total CPU Reserved": 4,
                    "RTF Total CPU Limit": 6,
                    "CH Total vCores": 0,
                    "RTF Application Details": [
                        {
                            "applicationName": "integrator",
                            "cpuReserved": 4,
                            "cpuLimit": 6
                        }
                    ]
                }
            ]
        }...
    }
}

**cURL command for Consolidated Cores Usage Report - **

curl -L -X POST 'https://{{APP-URI-BASE-PATH}}/api/cores/calculate?filterEmptyOrg=true&includeCloudHub=true&consolidatedReport=true' \
-H 'authType: <insert authType value>' \
-H 'Authorization: Basic <insert base64 token>' \
-H 'Content-Type: application/json' \
--data-raw '{
  "masterOrgId": "<insert master-org-id>",
  "includeSubOrgs": true,
  "environments": "<insert environment type>"
}' -o <FileName>.csv

Sample response for Consolidate report -

image

Note - Consolidated report is currently supported in CSV format only.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published