Querying the Metrics
Function
This API is used to list metrics. You can specify the namespace, metric name, dimension, sorting order, start records, and the maximum number of records.
Notes:
After a cloud service resource is deleted, its data is cached for 3 hours, so metrics of the resource can still be queried within the 3 hours.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
ces:metrics:list
List
-
-
-
-
URI
GET /V1.0/{project_id}/metrics
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. It is used to specify the project that an asset belongs to. You can query the assets of a project by project ID. You can obtain the project ID from the API or console. For details, see Obtaining a Project ID. Constraints N/A Range 1 to 64 characters. Default Value N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| namespace | No | String | Definition Service namespace, for example, the namespace of ECS is SYS.ECS . For details about service namespaces, see Services Interconnected with Cloud Eye. Constraints N/A Range The value is in the format of service.item, where service and item are separated by a period (.). service and item each must start with a letter. They can contain letters, digits, and underscores (_) and allow 3 to 32 characters. Default Value N/A |
| metric_name | No | String | Definition Metric name of the resource, for example, cpu_util of the ECS monitoring metric. For details about the metric names of each resource, see their service documentation. You can navigate there from Services Interconnected with Cloud Eye. Constraints N/A Range The value must start with a letter. It can contain letters, digits, underscores (_), and hyphens (-) and allows 1 to 96 characters. Default Value N/A |
| dim.0 | No | String | Definition First dimension of a metric. A maximum of four dimensions are supported. The dimension format is dim.{i}=key,value. A key,value example is instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d . For details about the dimension names of each resource, see their service documentation. You can navigate there from Services Interconnected with Cloud Eye. Constraints N/A Range Format: dim.0=key,value. key and value are separated by a comma (,). key must start with a letter. It can contain letters, digits, underscores (), and hyphens (-) and allows 1 to 32 characters. value can contain letters, digits, underscores (), hyphens (-), periods (.), slashes (/), number signs (#), and parentheses. It cannot start with a hyphen (-) but can start with an asterisk (*) or other allowed characters. It allows 1 to 256 characters. Default Value N/A |
| dim.1 | No | String | Definition Second dimension of a metric. A maximum of four dimensions are supported. The dimension format is dim.{i}=key,value. A key,value example is instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d . For details about the dimension names of each resource, see their service documentation. You can navigate there from Services Interconnected with Cloud Eye. Constraints N/A Range Format: dim.1=key,value. key and value are separated by a comma (,). key must start with a letter. It can contain letters, digits, underscores (), and hyphens (-) and allows 1 to 32 characters. value can contain letters, digits, underscores (), hyphens (-), periods (.), slashes (/), number signs (#), and parentheses. It cannot start with a hyphen (-) but can start with an asterisk (*) or other allowed characters. It allows 1 to 256 characters. Default Value N/A |
| dim.2 | No | String | Definition Third dimension of a metric. A maximum of four dimensions are supported. The dimension format is dim.{i}=key,value. A key,value example is instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d . For details about the dimension names of each resource, see their service documentation. You can navigate there from Services Interconnected with Cloud Eye. Constraints N/A Range Format: dim.2=key,value. key and value are separated by a comma (,). key must start with a letter. It can contain letters, digits, underscores (), and hyphens (-) and allows 1 to 32 characters. value can contain letters, digits, underscores (), hyphens (-), periods (.), slashes (/), number signs (#), and parentheses. It cannot start with a hyphen (-) but can start with an asterisk (*) or other allowed characters. It allows 1 to 256 characters. Default Value N/A |
| dim.3 | No | String | Definition Fourth dimension of a metric. A maximum of four dimensions are supported. The dimension format is dim.{i}=key,value. A key,value example is instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d . For details about the dimension names of each resource, see their service documentation. You can navigate there from Services Interconnected with Cloud Eye. Constraints N/A Range Format: dim.3=key,value. key and value are separated by a comma (,). key must start with a letter. It can contain letters, digits, underscores (), and hyphens (-) and allows 1 to 32 characters. value can contain letters, digits, underscores (), hyphens (-), periods (.), slashes (/), number signs (#), and parentheses. It cannot start with a hyphen (-) but can start with an asterisk (*) or other allowed characters. It allows 1 to 256 characters. Default Value N/A |
| start | No | String | Definition Start value of pagination. The format is namespace.metric_name.key:value. Example: start=SYS.ECS.cpu_util.instance_id:d9112af5-6913-4f3b-bd0a-3f96711e004d Constraints N/A Range The first request is sent with an empty string. Subsequent requests are sent with the value of marker in the return value of the previous page as the pagination start value of the next page. Default Value N/A |
| limit | No | Integer | Definition Maximum number of records that can be queried at a time. Constraints N/A Range [1,1000] Default Value 1000 |
| order | No | String | Definition Sorting order of query results. Constraints N/A Range The value can be: Default Value asc |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| Content-Type | No | String | Definition MIME type of the request body. Constraints N/A Range 1 to 64 characters Default Value Default value application/json; charset=UTF-8 is recommended. For APIs used to upload objects or images, the MIME type varies with the flow type. |
| X-Auth-Token | No | String | Definition User token. Constraints N/A Range 1 to 16,384 characters Default Value N/A |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| metrics | Array of MetricInfoList objects | Definition Metric information list. |
| meta_data | MetricListMetaDataResp object | Definition Metadata of query results, including the pagination information. |
| Parameter | Type | Description |
|---|---|---|
| dimensions | Array of MetricsDimensionResp objects | Definition Metric dimension. |
| metric_name | String | Definition Metric name. Range N/A |
| namespace | String | Definition Service namespace. Range N/A |
| unit | String | Definition Metric unit. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| name | String | Definition Dimension of a resource. For example, the dimension of an ECS is instance_id . A maximum of four dimensions are supported. For details about the dimension names of each resource, see their service documentation. You can navigate there from Services Interconnected with Cloud Eye. Range The value starts with a letter and allows 1 to 32 characters. It can contain only letters, digits, underscores (_), and hyphens (-). |
| value | String | Definition Resource dimension value, which is an instance ID, for example, 4270ff17-aba3-4138-89fa-820594c39755. Range 1 to 256 characters |
| Parameter | Type | Description |
|---|---|---|
| count | Integer | Definition Number of records that can be returned. Range N/A |
| total | Integer | Definition Total number of records. Range N/A |
| marker | String | Definition Start of the next page, which is used for pagination. Range N/A |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| - | String | Request error. |
Status code: 401
| Parameter | Type | Description |
|---|---|---|
| - | String | The authentication information is not provided or is incorrect. |
Status code: 403
| Parameter | Type | Description |
|---|---|---|
| - | String | Access to the requested page is forbidden. |
Status code: 408
| Parameter | Type | Description |
|---|---|---|
| - | String | The request timed out. |
Status code: 429
| Parameter | Type | Description |
|---|---|---|
| - | String | Too many requests. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| - | String | Failed to complete the request because of an internal service error. |
Status code: 503
| Parameter | Type | Description |
|---|---|---|
| - | String | The system is currently unavailable. |
Example Requests
/V1.0/{project_id}/metrics?namespace=SYS.ECS&metric_name=cpu_util&dim.0=instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d&limit=10&order=desc Example Responses
Status code: 200
OK
{
"metrics" : [ {
"namespace" : "SYS.ECS",
"dimensions" : [ {
"name" : "instance_id",
"value" : "d9112af5-6913-4f3b-bd0a-3f96711e004d"
} ],
"metric_name" : "cpu_util",
"unit" : "%"
} ],
"meta_data" : {
"count" : 1,
"marker" : "SYS.ECS.cpu_util.instance_id:d9112af5-6913-4f3b-bd0a-3f96711e004d",
"total" : 7
}
} Status Codes
| Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 408 | Request Timeout |
| 429 | Too Many Requests |
| 500 | Internal Server Error |
| 503 | Service Unavailable |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot