Query calculation instance indicators¶
Read usage metrics for a compute instance.
GET https://moi.matrixorigin.cn/newmoi/compute-resources/{resource_id}/metrics
Preparation before calling¶
First Query the computing instance details] and confirm the instance you want to query. Prepare a personal access token with access to the target workspace, the target workspace ID, and the compute instance ID.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$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 example¶
curl "https://moi.matrixorigin.cn/newmoi/compute-resources/$RESOURCE_ID/metrics" \
-H "X-API-Key: $AI_STUDIO_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 API Key and Workspace Header. |
|
|
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.