Query calculation instance indicators¶
Read usage metrics for a compute instance.
GET $CLOUDSIGMA_API_BASE/compute-resources/{resource_id}/metrics
Before you call this API¶
Configure the regional API endpoint and authentication, and select the target workspace.
First Query the computing instance details] and confirm the instance you want to query.
Set the operation-specific values used in the request:
$RESOURCE_ID: The computing instance ID to be queried.
The indicator items in data.breakdown will evolve with the service implementation, and the caller should be able to accept new fields.
Request¶
curl "$CLOUDSIGMA_API_BASE/compute-resources/$RESOURCE_ID/metrics" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID"
Path parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Compute instance ID. |
Successful response¶
Returns 200 on success, and the business data is located at data. The requested resource ID is used to identify the indicator ownership; the current interface can return empty indicator objects.
{
"code": "OK",
"msg": "OK",
"data": {
"compute_resource_id": "cr-001",
"total_credit": 0,
"breakdown": {}
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
object |
Indicator object. |
|
string |
The calculation instance ID to which the indicator belongs. |
|
integer |
The total Credit value returned by the server. |
|
object |
Indicator details; the keys and values are provided by the server and may be added. |
Error response¶
{
"code": "GET_METRICS_FAILED",
"msg": "服务端错误",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
— |
Missing or invalid access credentials. |
Check the regional endpoint, API key, and workspace ID. |
|
|
The current identity does not have permission to read instance metrics. |
Use valid credentials, or contact your administrator for authorization. |
|
|
The service cannot read the indicator. |
Record the request time and error message and try again. |
Follow-up operations¶
Query calculation instance details to associate indicators with the current status of the instance.