VMware Chargeback is no longer a standalone appliance. I have a post that goes through the migration from standalone to the integrated with Aria Operations model.
For Tenants to reach VMware Chargeback, there are two options:
- VCD will act as a proxy for VMware Chargeback
- VCD wil redirect to Aria Operations
Option 2 where VCD redirects to Aria Operations requires Aria Operations to be reachable to the tenants. This is normally not the case which makes option 1 very useful and works very well.
As of today VMware has no official support for Tenant API access to VMware Chargeback. This was the case for the standalone model and is still the case with the integrated model.
With option 1, VCD acting as a proxy for VMware Chargeback, I took some time to reverse-engineer the UI and was able to get API calls working so that customers could poll VMware Chargeback metrics for their own monitoring tools.
I will share a script at the end of this post that you can use but these are the high level steps to authenticate with VMware Chargeback via VCD:
- Make a login POST to VCD and export the following important cookies which are:
– vcloud_jwt
– cloud_session_id - Make a GET call to
/ariaops/ui/heartbeat.action
using the cookies from step 1 and export the new important cookies which is:
– JSESSIONID - Make a GET call to
/ariaops/ui/?vcdt=&vcdOrg=<tenant_id>&vcdOrgId=urn%3Avcloud%3Aorg%3A$<org_urn>&isDark=false&originURL=https%3A%2F%2F$<vcd>"
using the cookies from step 2 and export the new important cookies which are:
– JSESSIONID (new)
– rstd - Make a GET call to
ariaops/ui/commonJS.action?_dc=<timestamp>&mainAction=getApplicationGlobalData&timezone=60"
using the cookies from step 3 and the response will contain a secureToken.
The secureToken needs to be added the payload when trying to get any data or metrics from VMware Chargeback. Using developer tools to debug the calls via the UI is the easiest way to construct the API call you need. To obtain any information from Chargeback you can now use the cookies from step 3 along with the secureToken.
In my script below I am getting the CPU usage for the last 24 hours for a VM named “vm1-kUH9‘”. Note for the VM metric I also need the resourceId which I have hard set. I have a second request which is the output of the Organisation VDC dashboard.
base_url="https://dirw001.donagh.com"
authorization="<Base64>"
tenant_id="8538ad74-8269-4e2d-b4d6-69d2cb977e1d"
resource_id="a0f5859a-2cf8-42c2-bb4d-f91d3207b970"
resource_name="vm1-kUH9"
timestamp=$(date +%s)
base_url_no_https=${base_url#*//}
echo ""
echo ""
echo "###### LOGIN #########################################################################################"
curl -D headers.txt --location --request POST "${base_url}/cloudapi/1.0.0/sessions"
--header "Accept: application/json;version=39.0"
--header "Authorization: Basic ${authorization}"
-c cookies-1.txt "${base_url}" > /dev/null 2> /dev/null
token=$(cat headers.txt | grep X-VMWARE-VCLOUD-ACCESS-TOKEN | cut -c 31-)
#cat cookies-1.txt
echo "###### LOGIN #########################################################################################"
echo ""
echo ""
echo "###### ORG URN #######################################################################################"
urn_result=`curl --location --request GET "${base_url}/cloudapi/1.0.0/orgs"
--header "Accept: application/json;version=39.0"
--header "Authorization: Bearer $token" 2> /dev/null`
#echo ${urn_result}
org_urn=${urn_result:106:36}
echo ${org_urn}
echo "###### ORG URN #######################################################################################"
echo ""
echo ""
echo "###### JSESSIONID ####################################################################################"
curl "${base_url}/ext-ui/tenant/${tenant_id}/ariaops/ui/heartbeat.action"
-b cookies-1.txt "${base_url}"
-c cookies-2.txt "${base_url}"
#cat cookies-2.txt
echo "###### JSESSIONID ####################################################################################"
echo ""
echo ""
echo "###### JSESSIONID + RSTD #############################################################################"
curl "${base_url}/ext-ui/tenant/${tenant_id}/ariaops/ui/?vcdt=&vcdOrg=${tenant_id}&vcdOrgId=urn%3Avcloud%3Aorg%3A${org_urn}&isDark=false&originURL=https%3A%2F%2F${base_url_no_https}"
-b cookies-2.txt "${base_url}"
-c cookies-3.txt "${base_url}"
#cat cookies-3.txt
echo "###### JSESSIONID + RSTD #############################################################################"
echo ""
echo ""
echo "###### SECURETOKEN ###################################################################################"
result=`curl "${base_url}/ext-ui/tenant/${tenant_id}/ariaops/ui/commonJS.action?_dc=${timestamp}&mainAction=getApplicationGlobalData&timezone=60"
-b cookies-3.txt "${base_url}"
-c cookies-4.txt "${base_url}" 2> /dev/null`
secure_token=${result:16:36}
echo ${secure_token}
#cat cookies-4.txt
echo "###### SECURETOKEN ##################################################################################"
echo ""
echo ""
echo "###### METRICS ######################################################################################"
curl "${base_url}/ext-ui/tenant/${tenant_id}/ariaops/ui/metricChart.action"
--compressed -X POST
-H "Accept: */*"
-H "Content-Type: application/x-www-form-urlencoded"
-b cookies-4.txt "${base_url}"
--data-raw "mainAction=getMetricValues&isStacked=false&isRealTimeEnabled=&smoothingFactor=2&showSmooth=false&showAnomalies=false&showEntireDT=false&showDT=false&historicalDT=false&yellowBound=&orangeBound=&redBound=&datePeriod=&resourceId=${resource_id}&resourceName=${resource_name}&resourceKindId=&metricKey=cpu%7Cusage_average&metricName=CPU%7CUsage%20(%25)&metricFullName=CPU%7CUsage%20(%25)&metricFullNameWithoutUnit=CPU%7CUsage&metricUnitId=percent&metricUnit=%25&isKPI=false&isMultimodal=false&isStringMetric=false&isOnTheFlySuperMetric=false&isBadge=false&dateRange=%7B%22dateRange%22%3A%22last24Hour%22%2C%22dateRangeText%22%3A%22Last%2024%20hours%22%7D&periodIndex=0¤tComponentInfo=TODO&secureToken=${secure_token}"
echo "###### METRICS ######################################################################################"
echo ""
echo ""
echo "###### CHARGEBACK ######################################################################################"
curl "${base_url}/ext-ui/tenant/${tenant_id}/ariaops/ui/bridge/getChargebackOrgVDCs?_dc=${timestamp}"
--compressed -X POST
-H "Accept: */*"
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8'
-b cookies-4.txt "${base_url}"
--data-raw "searchCriteria=%7B%22sortAsc%22%3Afalse%2C%22start%22%3A0%2C%22sortField%22%3Anull%2C%22limit%22%3A50%2C%22fetchCount%22%3Atrue%2C%22searchOVdcCriterias%22%3A%5B%5D%7D&page=1&start=0&limit=50¤tComponentInfo=TODO&secureToken=${secure_token}"
echo "###### CHARGEBACK ######################################################################################"
echo ""
echo ""
This is what a successful script run would look like:
donaghmoynihan@Donaghs-MacBook-Pro ~ % ./chargeback_api.sh
###### LOGIN #########################################################################################
###### LOGIN #########################################################################################
###### ORG URN #######################################################################################
d9a6f9c8-2f24-4b5c-8426-cc3bf51e833a
###### ORG URN #######################################################################################
###### JSESSIONID ####################################################################################
ok
###### JSESSIONID ####################################################################################
###### JSESSIONID + RSTD #############################################################################
###### JSESSIONID + RSTD #############################################################################
###### SECURETOKEN ###################################################################################
c9e1b664-6f38-4d76-a90f-043d138110c7
###### SECURETOKEN ##################################################################################
###### METRICS ######################################################################################
{"metric":{"metricUnitId":"percent","resourceId":"a0f5859a-2cf8-42c2-bb4d-f91d3207b970","adapterKind":"VMWARE","metricName":"Usage","metricKey":"cpu|usage_average","dateRange":"{"dateRange":"last24Hour","dateRangeText":"Last 24 hours"}","resourceName":"vm1-kUH9","resourceKindName":"Virtual Machine","resourceKindId":"002006VMWAREVirtualMachine","metricUnit":"%","metricFullName":"CPU|Usage (%)","isRealTimeEnabled":false,"isOnTheFlySuperMetric":false,"isPropertyMetric":false,"resourceKindIcon":"images/resknd/default/vrops-light/VMWARE_VirtualMachine.svg"},"endDate":1732907480930,"smoothingFactor":"2","startTime":1732806680930,"endTime":1732907480930,"periodIndex":0,"startDate":1732806680930,"metricChart":{"dataPoints":[[1732807567588,0.2693333327770233],[1732807867635,0.26866665482521057],[1732809667947,0.27000001072883606],[1732809968566,0.28600001335144043],[1732810268608,0.28066667914390564],[1732815070901,0.2666666805744171],[1732818072734,0.2553333342075348],[1732818673592,0.35466668009757996],[1732819574533,0.2759999930858612],[1732821374794,0.26466667652130127],[1732821674832,0.2759999930858612],[1732823475518,0.2879999876022339],[1732823775574,0.2693333327770233],[1732824375919,0.2919999957084656],[1732824676337,0.2626666724681854],[1732824977519,0.2786666750907898],[1732828578688,0.2693333327770233],[1732828879052,0.2526666522026062],[1732829479632,0.26600000262260437],[1732829779837,0.26866665482521057],[1732832180236,0.2693333327770233],[1732832480271,0.26866665482521057],[1732834880952,0.5173333287239075],[1732835181595,0.273333340883255],[1732836081973,0.26733332872390747],[1732837883440,0.2746666669845581],[1732838183485,0.2619999945163727],[1732842684147,0.2800000011920929],[1732847185444,0.2666666805744171],[1732848985691,0.27000001072883606],[1732851986374,0.2759999930858612],[1732852286591,0.35466668009757996],[1732852587062,0.2800000011920929],[1732854387477,0.27399998903274536],[1732856488455,0.27000001072883606],[1732857088823,0.27666667103767395],[1732858889479,0.2693333327770233],[1732859190317,0.273333340883255],[1732859490450,0.27666667103767395],[1732861290980,0.26866665482521057],[1732861591037,0.26733332872390747],[1732865792356,0.2759999930858612],[1732867592626,0.28600001335144043],[1732867892724,0.2840000092983246],[1732872093468,0.2720000147819519],[1732876297698,0.27133333683013916],[1732878397986,0.27933332324028015],[1732878699976,0.28066667914390564],[1732881102013,0.2800000011920929],[1732881402544,0.26866665482521057],[1732885003500,0.5040000081062317],[1732885304049,0.27666667103767395],[1732888006486,0.2786666750907898],[1732890106987,0.2759999930858612],[1732892210067,0.28066667914390564]]}}
###### METRICS ######################################################################################
###### CHARGEBACK ######################################################################################
{"dtoList":[{"metrics":{"CPU_LIMIT":{"value":0.0,"originalValue":0.0,"id":"cpu|limit","name":"limit","fullName":"cpu|limit","metricUnit":"MHz","metricUnitId":"mhz"},"CPU_UTILIZATION":{"value":100.0,"originalValue":100000.0,"id":"cpu|used","name":"used","fullName":"cpu|used","metricUnit":"GHz","metricUnitId":"ghz"},"STORAGE_LIMIT":{"value":0.0,"originalValue":0.0,"id":"storage|limit","name":"limit","fullName":"storage|limit","metricUnit":"MB","metricUnitId":"mb"},"STORAGE_UTILIZATION_PERCENT":{},"MEMORY_UTILIZATION_PERCENT":{},"NUMBER_OF_VAPPS":{"value":48.0,"originalValue":48.0,"id":"others|number_of_vapps","name":"number_of_vapps","fullName":"others|number_of_vapps"},"NUMBER_OF_VMS":{"value":18.0,"originalValue":18.0,"id":"others|number_of_vms","name":"number_of_vms","fullName":"others|number_of_vms"},"MEMORY_LIMIT":{"value":0.0,"originalValue":0.0,"id":"memory|limit","name":"limit","fullName":"memory|limit","metricUnit":"MB","metricUnitId":"mb"},"STORAGE_UTILIZATION":{"value":970.0,"originalValue":993280.0,"id":"storage|used","name":"used","fullName":"storage|used","metricUnit":"GB","metricUnitId":"gb"},"NUMBER_OF_CPU":{"value":36.0,"originalValue":36.0,"id":"vcpu|used","name":"used","fullName":"vcpu|used"},"MEMORY_UTILIZATION":{"value":100.0,"originalValue":102400.0,"id":"memory|used","name":"used","fullName":"memory|used","metricUnit":"GB","metricUnitId":"gb"},"CPU_UTILIZATION_PERCENT":{}},"resource":{"id":"06916256-85c4-4993-9fb9-52e4d9df4357","name":"vdc-eff-rk","isResourceCollecting":false},"vCloudDirector":{"id":"e674db93-23d3-440f-be5a-f06ff4f6e7a0","name":"sdirw425.jp-tok.vmware.test.cloud.ibm.com","isResourceCollecting":false},"organization":{"id":"f516508b-cb53-44a2-b258-154449f33033","name":"8538ad74-8269-4e2d-b4d6-69d2cb977e1d","isResourceCollecting":false}},{"metrics":{"CPU_LIMIT":{"value":0.0,"originalValue":0.0,"id":"cpu|limit","name":"limit","fullName":"cpu|limit","metricUnit":"MHz","metricUnitId":"mhz"},"CPU_UTILIZATION":{"value":4.0,"originalValue":4000.0,"id":"cpu|used","name":"used","fullName":"cpu|used","metricUnit":"GHz","metricUnitId":"ghz"},"STORAGE_LIMIT":{"value":0.0,"originalValue":0.0,"id":"storage|limit","name":"limit","fullName":"storage|limit","metricUnit":"MB","metricUnitId":"mb"},"STORAGE_UTILIZATION_PERCENT":{},"MEMORY_UTILIZATION_PERCENT":{},"NUMBER_OF_VAPPS":{"value":1.0,"originalValue":1.0,"id":"others|number_of_vapps","name":"number_of_vapps","fullName":"others|number_of_vapps"},"NUMBER_OF_VMS":{"value":1.0,"originalValue":1.0,"id":"others|number_of_vms","name":"number_of_vms","fullName":"others|number_of_vms"},"MEMORY_LIMIT":{"value":0.0,"originalValue":0.0,"id":"memory|limit","name":"limit","fullName":"memory|limit","metricUnit":"MB","metricUnitId":"mb"},"STORAGE_UTILIZATION":{"value":34.0,"originalValue":34816.0,"id":"storage|used","name":"used","fullName":"storage|used","metricUnit":"GB","metricUnitId":"gb"},"NUMBER_OF_CPU":{"value":2.0,"originalValue":2.0,"id":"vcpu|used","name":"used","fullName":"vcpu|used"},"MEMORY_UTILIZATION":{"value":4.0,"originalValue":4096.0,"id":"memory|used","name":"used","fullName":"memory|used","metricUnit":"GB","metricUnitId":"gb"},"CPU_UTILIZATION_PERCENT":{}},"resource":{"id":"a7c6b6ad-59ae-4c24-89e4-edc4b83449e3","name":"vdc-private1","isResourceCollecting":false},"vCloudDirector":{"id":"e674db93-23d3-440f-be5a-f06ff4f6e7a0","name":"sdirw425.jp-tok.vmware.test.cloud.ibm.com","isResourceCollecting":false},"organization":{"id":"f516508b-cb53-44a2-b258-154449f33033","name":"8538ad74-8269-4e2d-b4d6-69d2cb977e1d","isResourceCollecting":false}},{"metrics":{"CPU_LIMIT":{"value":0.0,"originalValue":0.0,"id":"cpu|limit","name":"limit","fullName":"cpu|limit","metricUnit":"MHz","metricUnitId":"mhz"},"CPU_UTILIZATION":{"value":12.0,"originalValue":12000.0,"id":"cpu|used","name":"used","fullName":"cpu|used","metricUnit":"GHz","metricUnitId":"ghz"},"STORAGE_LIMIT":{"value":0.0,"originalValue":0.0,"id":"storage|limit","name":"limit","fullName":"storage|limit","metricUnit":"MB","metricUnitId":"mb"},"STORAGE_UTILIZATION_PERCENT":{},"MEMORY_UTILIZATION_PERCENT":{},"NUMBER_OF_VAPPS":{"value":1.0,"originalValue":1.0,"id":"others|number_of_vapps","name":"number_of_vapps","fullName":"others|number_of_vapps"},"NUMBER_OF_VMS":{"value":1.0,"originalValue":1.0,"id":"others|number_of_vms","name":"number_of_vms","fullName":"others|number_of_vms"},"MEMORY_LIMIT":{"value":0.0,"originalValue":0.0,"id":"memory|limit","name":"limit","fullName":"memory|limit","metricUnit":"MB","metricUnitId":"mb"},"STORAGE_UTILIZATION":{"value":102.0,"originalValue":104448.0,"id":"storage|used","name":"used","fullName":"storage|used","metricUnit":"GB","metricUnitId":"gb"},"NUMBER_OF_CPU":{"value":2.0,"originalValue":2.0,"id":"vcpu|used","name":"used","fullName":"vcpu|used"},"MEMORY_UTILIZATION":{"value":12.0,"originalValue":12288.0,"id":"memory|used","name":"used","fullName":"memory|used","metricUnit":"GB","metricUnitId":"gb"},"CPU_UTILIZATION_PERCENT":{}},"resource":{"id":"acfa5051-9724-41eb-b8ba-381aed711f80","name":"ST-IPSec","isResourceCollecting":false},"vCloudDirector":{"id":"e674db93-23d3-440f-be5a-f06ff4f6e7a0","name":"sdirw425.jp-tok.vmware.test.cloud.ibm.com","isResourceCollecting":false},"organization":{"id":"f516508b-cb53-44a2-b258-154449f33033","name":"8538ad74-8269-4e2d-b4d6-69d2cb977e1d","isResourceCollecting":false}}],"totalCount":3}
###### CHARGEBACK ######################################################################################

Leave a comment Cancel reply