Query CCU usage of warehouses
Queries the CCU usage of each warehouse in a PhoenixAI cluster over a date range of up to 31 days. Use it to break a cluster's total CCU usage (see Query CCU usage of a cluster) down by warehouse.
NOTE
This operation requires the View and manage billing privilege.
Request
| Basic information | |
|---|---|
| HTTP URL | https://cloud-api.celerdata.com/api/1.0/usages/:cluster_id/warehouses |
| HTTP method | GET |
| Frequency | 600/minute |
Path variables
| Parameter | Example value | Required | Type | Description |
|---|---|---|---|---|
| cluster_id | 4ae48a3f-f840-46fa-b0e7-0709a220fa40 | Yes | String | The ID of the cluster. You can sign in to the PhoenixAI Cloud console and then navigate to the Cluster properties section of the cluster's Overview page to obtain the cluster ID. |
:<variable_name> indicates a URL path variable in web development tools such as Postman. :cluster_id in the above URL path, as such, indicates the ID of the cluster you want to query. However, if you use other tools such as curl, you need to replace :cluster_id with the actual cluster ID by hand in the curl command.
Header parameters
| Parameter | Example value | Required | Type | Description |
|---|---|---|---|---|
| Authorization | Bearer OGQ5MDA4MZGTNJMWNS0ZY2Y2LWFJNZYTOTBINMZIYTGZZDUY | Yes | String | The access token used to access the PhoenixAI Cloud API. Format: Bearer <access_token>. |
See Obtain access token.
Query parameters
| Parameter | Example value | Required | Type | Description |
|---|---|---|---|---|
| start_date | 20230701 | Yes | String | The start date of the time range to query, inclusive. Format: yyyyMMdd. |
| end_date | 20230731 | Yes | String | The end date of the time range to query, inclusive. Format: yyyyMMdd.The end_date must be greater than or equal to the start_date, and the time range can span at most 31 days. |
| warehouse_ids | wh-1a2b3c,wh-4d5e6f | No | String | A comma-separated list of the IDs of the warehouses to query. If this parameter is not specified, all warehouses of the cluster that have CCU usage in the time range are returned, including warehouses that have since been released. |
| show_detail | true | No | Boolean | Whether to return CCU usage details on a daily basis. Default value: false. |
Dates are interpreted in UTC.
Sample request
curl -X GET \
'https://cloud-api.celerdata.com/api/1.0/usages/82964bc5-a8ce-4236-9fe6-1ad1e0f80e15/warehouses?start_date=20230701&end_date=20230731&show_detail=true' \
-H 'Authorization: Bearer <access_token>'
Response
Sample response
{
"code":20000,
"data":[
{
"warehouse_id":"wh-1a2b3c",
"warehouse_name":"default_warehouse",
"total_usage":"87.025277",
"details":[
{
"usage":"18.130654",
"date":20230703,
"time_stamp":1688342400
}
]
}
]
}
If show_detail is set to false or is not specified, each object in the data array contains "details": null.
Response elements
| Parameter | Example value | Type | Description |
|---|---|---|---|
| code | 20000 | Integer | The error code. If the error code returned is 20000, the request succeeded. If any other error code is returned, the request failed. |
| data | - | Array | The result of the API call. data is an array that consists of one object for each warehouse that has CCU usage in the selected time range. Warehouses without CCU usage are not returned, and the array is empty if no warehouse has CCU usage. The order of the objects is not guaranteed. Each object consists of the following elements:
|
| data.0.warehouse_id | wh-1a2b3c | String | The ID of the warehouse. |
| data.0.warehouse_name | default_warehouse | String | The name of the warehouse. |
| data.0.total_usage | 87.025277 | String | The total CCU usage of the warehouse over the selected time range. |
| data.0.details | - | Array | The daily CCU usage details of the warehouse. details is an array that consists of one object for each date with CCU usage.The details array is returned only when the show_detail parameter in the request is set to true. Otherwise, details is null. |
| data.0.details.0 | - | Object | The CCU usage details of the warehouse on a specific date. Each object consists of the following elements:
|
| data.0.details.0.usage | 18.130654 | String | The CCU usage on the specific date. |
| data.0.details.0.date | 20230703 | Integer | The specific date, in yyyyMMdd format (UTC). |
| data.0.details.0.time_stamp | 1688342400 | Integer | The start of the specific date as a Unix timestamp in seconds (UTC). |
| message | param start_date is invalid | String | The error message. This element is returned only when the code returned is not 20000.NOTICE Do not conclude whether a request succeeded or failed based on the return value of message. |
Error codes
| code | message | Cause |
|---|---|---|
| 30000 | param start_date is invalid | start_date is not specified or is not in yyyyMMdd format. |
| 30000 | param end_date is invalid | end_date is not specified or is not in yyyyMMdd format. |
| 30000 | param end_date should greeter than or equal to start_date | end_date is earlier than start_date. |
| 30000 | the time range is out of limits.max:31 days | The time range spans more than 31 days. |
| 40004 | cluster not exists | The cluster does not exist or does not belong to your account. |
| 50005 | - | Internal server error. Retry later. |