Loading

How to Get List of Every RTF App's CPU and Memory Allocation of Entire Org

Date de publication: Jul 21, 2025
Étapes

CONTENTS

You are using RTF. You need a list CPU and memory allocation for each RTF app in your entire org.

STEPS TO FOLLOW

1. Primarily, you will need to use this API: link

2. Here is a sample call for 1 specific RTF app, where you will need the following information:

Deployment ID: link
Org ID: How to know my Organization ID (Org ID) on the Anypoint Platform
Environment ID: How to get the Environment ID
Bearer token: How to generate your Authorization Bearer token for Anypoint Platform
 
curl -L -X GET 'https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/<org ID>/environments/<environment>/deployments/<deployment ID>' \
-H 'Authorization: Bearer <bearer token>' \
--data-raw ''

This API will return a lot of information, but please focus on allocation under "target" -> "deploymentSettings" -> "resources":
{
    "id": "9b5ba1ae-4f9f-4d6b-943e-44cf1db78dba",
    "name": "mycpu",
    "creationDate": 1646688513192,
    "lastModifiedDate": 1646688513192,
    "target": {
        "provider": "MC",
        "targetId": "5c769e40-c70b-4bf4-96bd-4351456f85ff",
        "deploymentSettings": {
            "jvm": {},
            "anypointMonitoringScope": "cluster",
            "sidecars": {
                "anypoint-monitoring": {
                    "image": "auto",
                    "resources": {
                        "cpu": {
                            "limit": "50m",
                            "reserved": "0m"
                        },
                        "memory": {
                            "limit": "50Mi",
                            "reserved": "50Mi"
                        }
                    }
                }
            },
            "updateStrategy": "rolling",
            "runtimeVersion": "4.4.0:20220124-2",
            "clustered": false,
            "forwardSslSession": false,
            "http": {
                "inbound": {
                    "publicUrl": "www.kfroogle.com/mycpu",
                    "pathRewrite": null
                }
            },
            "resources": {
                "cpu": {
                    "limit": "1000m",
                    "reserved": "1000m"
                },
                "memory": {
                    "limit": "3000Mi",
                    "reserved": "3000Mi"
                }
            },
            "lastMileSecurity": false,
            "enforceDeployingReplicasAcrossNodes": false
        },
        "replicas": 1
    },
    "status": "APPLYING",
    "application": {
        "status": "NOT_RUNNING",
        "desiredState": "STARTED",
        "ref": {
            "groupId": "d581a7bc-e6c4-475c-8711-a2653959a2f4",
            "artifactId": "simple-http-listener",
            "version": "1.0.31",
            "packaging": "jar"
        },
        "configuration": {
            "mule.agent.application.properties.service": {
                "properties": {},
                "applicationName": "mycpu"
            }
        }
    },
    "desiredVersion": "9e968276-f862-4b2c-a6ec-d256ffd66539",
    "replicas": [
        {
            "state": "UNDEPLOYED",
            "deploymentLocation": "5c769e40-c70b-4bf4-96bd-4351456f85ff",
            "currentDeploymentVersion": "9e968276-f862-4b2c-a6ec-d256ffd66539",
            "reason": ""
        }
    ],
    "lastSuccessfulVersion": null
}




3. Here is a sample Bash script which can retrieve these results. You will need to input the username and password for your account.
#/bin/bash 

#Please install jq first: https://stedolan.github.io/jq/download/

USER=""
PASS=""

output=$(curl -sX POST https://anypoint.mulesoft.com/accounts/login -H 'Content-Type: application/json' -d '{"username": "'"$USER"'", "password": "'"$PASS"'"}')

ACCESS_TOKEN=$(echo $output | jq -r .access_token)

org_id_output=$(curl -sX GET https://anypoint.mulesoft.com/accounts/api/me -H "Authorization: Bearer $ACCESS_TOKEN")

ORG_ID=$(echo $org_id_output | jq -r .user.organizationId)

env_id_output=$(curl -sX GET "https://anypoint.mulesoft.com/accounts/api/organizations/"$ORG_ID"/environments" -H "authorization: bearer $ACCESS_TOKEN")

ENV_IDS=$(echo $env_id_output | jq -r '.data[].id' )

myarr=(${ENV_IDS//,/})

RESULT='{'

for IA in "${myarr[@]}"
do
	res_output=$(curl -sX GET "https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/"$ORG_ID"/environments/"$IA"/deployments/" -H "authorization: bearer $ACCESS_TOKEN")
	
	EC2=$(echo $res_output | jq -r '.items[].id')

	borkstring=$(echo $EC2 | sed -e 's/\[ //g' -e 's/\ ]//g' -e 's/\,//g')
	arr=( $borkstring )

	if [ ${#arr} -gt 1 ]; then
		RESULT1='{'
	else
		RESULT1=''
	fi 

	for dep in "${arr[@]}"
	do
		url="https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/"$ORG_ID"/environments/"$IA"/deployments/"
		url+="${dep}"
		mes_output=$(curl -s -X GET "$url" -H "authorization: bearer $ACCESS_TOKEN")
		
		ECNAME=$(echo $mes_output | jq -r '.name')
		ECRESOURCES=$(echo $mes_output | jq -r '.target.deploymentSettings.resources')

		if [ ${#ECRESOURCES} -lt 5 ]; then
			continue
		fi

		RESULT1+="\"$ECNAME\""
		RESULT1+=":"
		RESULT1+=" ${ECRESOURCES}," 
	done

	if [ ${#RESULT1} -gt 2 ]; then 
		RESULT1=${RESULT1%?}
		RESULT1+='}'
	else
		RESULT1+="[]"
	fi

	RESULT+="\"$IA\""
	RESULT+=":"
	RESULT+=" ${RESULT1}," 
	
done

RESULT=${RESULT%?}

RESULT+='}'

echo ${RESULT} | jq

Here is sample output from the Bash script:
{
  "57127dfd-282a-448e-b61b-048142c1b607": [],
  "119874a5-acdb-46e3-8540-438ce9c02993": [],
  "30441cf5-b36a-433e-8687-ef070eb54b09": {
    "testapp": {
      "cpu": {
        "limit": "300m",
        "reserved": "300m"
      },
      "memory": {
        "limit": "3000Mi",
        "reserved": "3000Mi"
      }
    }
  },
  "c97c8a4a-7ea1-4130-bfe8-2bbe38f71bb3": [],
  "d57641e4-6297-4750-bd3f-7df0540d1888": [],
  "c7895e44-650d-45ad-abc7-2ff6a9c84def": {
    "mytestjvm1": {
      "cpu": {
        "limit": "1000m",
        "reserved": "1000m"
      },
      "memory": {
        "limit": "3000Mi",
        "reserved": "3000Mi"
      }
    },
    "https": {
      "cpu": {
        "limit": "1000m",
        "reserved": "1000m"
      },
      "memory": {
        "limit": "3000Mi",
        "reserved": "3000Mi"
      }
    },
    "testhi": {
      "cpu": {
        "limit": "1000m",
        "reserved": "1000m"
      },
      "memory": {
        "limit": "3000Mi",
        "reserved": "3000Mi"
      }
    },
    "mycpu": {
      "cpu": {
        "limit": "1000m",
        "reserved": "1000m"
      },
      "memory": {
        "limit": "3000Mi",
        "reserved": "3000Mi"
      }
    },
    "monday2": {
      "cpu": {
        "limit": "1000m",
        "reserved": "1000m"
      },
      "memory": {
        "limit": "3000Mi",
        "reserved": "3000Mi"
      }
    }
  },
  "d5167780-46e2-44e8-b9aa-c9e6de0ec345": []
}

 
Numéro d’article de la base de connaissances

001115724

 
Chargement
Salesforce Help | Article