VMware Cloud Foundation APIs: Deploying Real-Time Metrics

Following the release of VMware Cloud Foundation 9.1, Real-time metrics capabilities were added to collect real-time, granular data from core VMware Cloud Foundation infrastructure. The real-time metrics component collects performance data directly from vCenter, ESX, NSX, and vSAN and stores the data in a dedicated Real-Time Metrics Store which is then displayed on-demand within the Observability Workbench in VCF Operations. This outbound connection originates from the real-time metrics component that operates within VCF management services (see the Deploy Real-Time Metrics section of the product documentation to deploy using the VCF Operations UI).

In this post we will look at how the Real-time metrics component can be deployed using the public APIs, this is achieved via the VCF Fleet Lifecycle Service which is tightly integrated into VCF Operations.

VCF Fleet Lifecycle Service APIs Used

VCF Fleet LCM Service APIs

  • POST /api/v1/identity/token
  • GET /fleet-lcm/v1/sddc-lcms
  • POST /fleet-lcm/v1/components/validations
  • POST /fleet-lcm/v1/components
  • GET /fleet-lcm/v1/tasks/{taskId}

Procedure

  1. Connect to a system that has access to the infrastructure and is capable of running CURL.

  2. Replace the values in the sample code with values for your VCF Fleet Lifecycle Service and paste the commands in the console. If your not sure which endpoint this FQDN should be log into VCF Operations, go to Build > Lifecycle > VCF Management and select the Components tab and locate the component named Fleet lifecycle the FQDN is shown in the FQDN column.

1export vcfFleetLifecycleFqdn='flt-fc01.rainpole.io'
2export vcfFleetLifecycleUser='[email protected]'
3export vcfFleetLifecyclePass='VMw@re1!VMw@re1!'
  1. Authenticate to the VCF Fleet Lifecycle Service and obtain a token by running the following command:
1vcfFleetLifecycleToken=$(curl -k -X POST "https://$vcfFleetLifecycleFqdn/api/v1/identity/token" \
2    -H 'Content-Type: application/x-www-form-urlencoded' \
3    --data "grant_type=password" \
4    --data "username=$vcfFleetLifecycleUser" \
5    --data "password=$vcfFleetLifecyclePass" \
6    | jq -r '.access_token')
  1. Verify you successfully obtained an authentication token by running the following command:
1echo $vcfFleetLifecycleToken

Example Output:

1eyJhbGciOiJFZERTQSIsImtpZCI6Ilg4Mk5veGNJRlVCVEFiY0xPM1NUdU12UTF6Qlo4d01xeUxDTGNuOGZYdFUiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2ZsdC1mYzAxLnJhaW5wb2xlLmlvIiwic3ViIjoiYWRtaW5AdnNwLmxvY2FsIiwiYXVkIjpbInZzcCJdLCJleHAiOjE3ODM0MzU1NTIsImlhdCI6MTc4MzQyMTE1MiwianRpIjoiMjA3OTg0MDgtZGE3OC00N2UzLTgxMDctNDAyMThkNjM1ZThmIiwiYXpwIjoicGFzc3dvcmRfZ3JhbnRfY2xpZW50IiwiYWNjdCI6ImFkbWluQHZzcC5sb2NhbCIsImF1dGhvcml6YXRpb25fZGV0YWlscyI6bnVsbH0.OsXjW3cgwZaEMXwZC6MOqOped5MX1wdf3wpUmjZLaRiXeug4rtm9dnWHvPrp5pM74MNsVEjhbeT3u0TJjgIIBQ
  1. First we retrieve the unique ID of the SDDC instance by running the following command:
1primarySddcLcms=$(curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/sddc-lcms" \
2  --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3  --header "Accept: application/json" \
4  --header "Content-Type: application/json" \
5  | jq -r '.sddcLcms[] | select(.isPrimary == true) | .id')
  1. Verify you successfully obtained the SDDC instance by running the following command:
1echo $primarySddcLcms

Example Output:

13e8d0034-906b-49cb-9c47-3afa8d919192
  1. Create the JSON payload for the Real-Time Metrics instance deployment by running the following command:
 1cat << EOF > real-time-metrics-deploy.json
 2{
 3  "componentSpecs": [
 4    {
 5      "sddcLcmId": "${primarySddcLcms}",
 6      "deploymentType": "VspComponentSpec",
 7      "componentType": "OPS_DATA_PLATFORM",
 8      "version": "9.1.0.0"
 9    }
10  ]
11}
12EOF
  1. Verify the JSON payload has been populated correctly by running the following command:
1 cat real-time-metrics-deploy.json

Example Output:

 1{
 2  "componentSpecs": [
 3    {
 4      "sddcLcmId": "3e8d0034-906b-49cb-9c47-3afa8d919192",
 5      "deploymentType": "VspComponentSpec",
 6      "componentType": "OPS_DATA_PLATFORM",
 7      "version": "9.1.0.0"
 8    }
 9  ]
10}
  1. Validate the JSON payload by running the following command:
1validationId=$(curl -k -X POST "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/components/validations" \
2  --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3  --header "Accept: application/json" \
4  --header "Content-Type: application/json" \
5   -d @real-time-metrics-deploy.json | jq -r ".id")
  1. Check the status of the validation by running the following command:
1curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$validationId" \
2    --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3    --header "Accept: application/json" \
4    --header "Content-Type: application/json" \
5    | jq
  1. The command in step 11 may need to be run multiple times, alternatively you can run the command over and over by running the following command:
1while curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$validationId" \
2    --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3    --header "Accept: application/json" \
4    --header "Content-Type: application/json" \
5    | jq '{status: .status}' \
6    | grep -q "RUNNING"; do
7    echo "Still in 'RUNNING' state... waiting 2 seconds."
8    sleep 2
9done
  1. Start the deployment by running the following command:
1deploymentId=$(curl -k -X POST "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/components" \
2  --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3  --header "Accept: application/json" \
4  --header "Content-Type: application/json" \
5  -d @real-time-metrics-deploy.json | jq -r ".id")
  1. Check the status of the deployment by running the following command:
1curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$deploymentId" \
2    --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3    --header "Accept: application/json" \
4    --header "Content-Type: application/json" \
5    | jq
  1. The command in step 11 would need to be run multiple times, alternatively you can run the command over and over by running the following command:
1while curl -k -X GET "https://$vcfFleetLifecycleFqdn/fleet-lcm/v1/tasks/$deploymentId" \
2    --header "Authorization: Bearer ${vcfFleetLifecycleToken}" \
3    --header "Accept: application/json" \
4    --header "Content-Type: application/json" \
5    | jq '{status: .status}' \
6    | grep -q "RUNNING"; do
7    echo "Still in 'RUNNING' state... waiting 60 seconds."
8    sleep 60
9done

Posts in this Series