To use the Metrics API, use the following RESTful workflow to programmatically retrieve metrics for your vCloud Air environment.

Note

Before you access the Metric API, you must meet the API prerequisites. See Prerequisites for Using the Metrics API for information.

At a high level, you will follow these super-steps:

1

Log in to vCloud Air using a role that has permission to view virtual machine statistics or with permission to manage edge gateways, respectively. See Log in to vCloud Air.

2

Create a login session with vCloud Director. See Create a Session for a Virtual Data Center in a Service.

Note

Alternatively, you can log in directly to vCloud Director if you have vCloud Director organization credentials. See Logging In in the vCloud API Programming Guide for information. Obtain the vCloud Director API endpoint from the vCloud Air Web UI.

3

Query vCloud Director for the virtual machine, virtual data center, or edge gateway ID for which you require metrics. See Query the vCloud API for IDs.

4

Issue a GET (to retrieve the previous 5 minutes of data) or POST (to retrieve a specific time range) request with one of the following URIs:

GET|POST https://hostname.vchs.vmware.com:443/hybridity/api/metrics/target/targetID[?count=count]
Accept: application/json
Content-Type: application/json
X-Vcloud-Authorization: "vcloud-auth-token"

Where hostname is the host from the vCloud Director API endpoint displayed in the vCloud Air Web UI.

Note

When issuing a POST request to retrieve a specific time range, include the time range parameters in the request body. See Retrieving Metrics for vCloud Air.

If the request is successful, the server returns HTTP response code 200 and the first page of data. If the data spans multiple pages, the response body will include a next page token.

5

If the data returned spans multiple pages, submit the GET or POST request again and include the next page token you received in the response body:

GET|POST https://hostname.vchs.vmware.com:443/hybridity/api/metrics/target/targetID?next=nexttoken&count=count
Accept: application/json
Content-Type: application/json
X-Vcloud-Authorization: "vcloud-auth-token"

Where hostname is the host from the vCloud Director API endpoint displayed in the vCloud Air Web UI.

Repeat this step until all pages of data are returned.