Skip to main content
Version: 4.0 Stable

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 URLhttps://cloud-api.celerdata.com/api/1.0/usages/:cluster_id/warehouses
HTTP methodGET
Frequency600/minute

Path variables​

ParameterExample valueRequiredTypeDescription
cluster_id4ae48a3f-f840-46fa-b0e7-0709a220fa40YesStringThe 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​

ParameterExample valueRequiredTypeDescription
AuthorizationBearer OGQ5MDA4MZGTNJMWNS0ZY2Y2LWFJNZYTOTBINMZIYTGZZDUYYesStringThe access token used to access the PhoenixAI Cloud API. Format: Bearer <access_token>.

See Obtain access token.

Query parameters​

ParameterExample valueRequiredTypeDescription
start_date20230701YesStringThe start date of the time range to query, inclusive. Format: yyyyMMdd.
end_date20230731YesStringThe 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_idswh-1a2b3c,wh-4d5e6fNoStringA 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_detailtrueNoBooleanWhether 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​

ParameterExample valueTypeDescription
code20000IntegerThe error code. If the error code returned is 20000, the request succeeded. If any other error code is returned, the request failed.
data-ArrayThe 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:
  • warehouse_id
  • warehouse_name
  • total_usage
  • details
data.0.warehouse_idwh-1a2b3cStringThe ID of the warehouse.
data.0.warehouse_namedefault_warehouseStringThe name of the warehouse.
data.0.total_usage87.025277StringThe total CCU usage of the warehouse over the selected time range.
data.0.details-ArrayThe 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-ObjectThe CCU usage details of the warehouse on a specific date. Each object consists of the following elements:
  • usage
  • date
  • time_stamp
data.0.details.0.usage18.130654StringThe CCU usage on the specific date.
data.0.details.0.date20230703IntegerThe specific date, in yyyyMMdd format (UTC).
data.0.details.0.time_stamp1688342400IntegerThe start of the specific date as a Unix timestamp in seconds (UTC).
messageparam start_date is invalidStringThe 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​

codemessageCause
30000param start_date is invalidstart_date is not specified or is not in yyyyMMdd format.
30000param end_date is invalidend_date is not specified or is not in yyyyMMdd format.
30000param end_date should greeter than or equal to start_dateend_date is earlier than start_date.
30000the time range is out of limits.max:31 daysThe time range spans more than 31 days.
40004cluster not existsThe cluster does not exist or does not belong to your account.
50005-Internal server error. Retry later.