Querying Metrics¶
Function¶
This API is used to query the metrics that can be monitored in the system. You can query specific metrics by specifying a namespace, metric name, dimension, and resource ID (format: resType_resId). You can also specify the start position and the maximum number of returned records for a pagination query.
URI¶
POST /v1/{project_id}/ams/metrics
Parameter | Mandatory | Type | Description |
---|---|---|---|
project_id | Yes | String | Project ID obtained from IAM. Generally, a project ID contains 32 characters. |
Parameter | Mandatory | Type | Description |
---|---|---|---|
type | No | String | Metric query mode. |
limit | No | String | Number of records that can be returned. Value range: 1-1000. Default value: 1000. |
start | No | String | Start position of a pagination query. The value is a non-negative integer. |
Request Parameters¶
Parameter | Mandatory | Type | Description |
---|---|---|---|
X-Auth-Token | Yes | String | User token obtained from IAM. |
Content-Type | Yes | String | Content type, which is application/json. Enumeration values:
|
Parameter | Mandatory | Type | Description |
---|---|---|---|
inventoryId | No | String | Resource ID, which must be in the format of resType_resId. Enumerated values of resType: host, application, instance, container, process, network, storage, and volume. When type (a URI parameter) is inventory, this parameter instead of metricItems is used for associated metric queries. |
metricItems | No | Array of QueryMetricItemOptionParam objects | If type (a URI parameter) is not inventory, the information carried by the array is used to query metrics. |
Parameter | Mandatory | Type | Description |
---|---|---|---|
dimensions | No | Array of Dimension objects | List of metric dimensions. |
metricName | No | String | Metric name. Length: 1 to 255 characters. Values: cpuUsage, cpuCoreUsed, and other basic metrics provided by AOM. cpuUage: CPU usage. cpuCoreUsed: used CPU cores. Custom metrics. |
namespace | Yes | String | Metric namespace. Values:
|
Parameter | Mandatory | Type | Description |
---|---|---|---|
name | Yes | String | Dimension name. |
value | Yes | String | Dimension value. |
Response Parameters¶
Status code: 200
Parameter | Type | Description |
---|---|---|
errorCode | String | Response code. |
errorMessage | String | Response message. |
metrics | Array of MetricItemResultAPI objects | Metric list. |
metaData | MetaData object | Metadata, including pagination information. |
Parameter | Type | Description |
---|---|---|
dimensions | Array of Dimension objects | List of metric dimensions. |
dimensionvaluehash | String | Metric hash value. |
metricName | String | Metric name. |
namespace | String | Namespace. |
unit | String | Metric unit. |
Parameter | Type | Description |
---|---|---|
name | String | Dimension name. |
value | String | Dimension value. |
Parameter | Type | Description |
---|---|---|
count | Integer | Number of records that can be returned. |
start | String | Start of the next page, which is used for pagination. null: No more data. |
total | Integer | Total number of records. |
Example Requests¶
Query metrics by inventory ID.
POST https://{Endpoint}/v1/{project_id}/ams/metrics?type=inventory { "inventoryId" : "application_************7-b56f-fa163e3fee10" }
Query metrics by namespace, appName, and clusterName.
POST https://{Endpoint}/v1/{project_id}/ams/metrics { "metricItems" : [ { "namespace" : "PAAS.CONTAINER", "dimensions" : [ { "name" : "appName", "value" : "demo" }, { "name" : "clusterName", "value" : "aom_cluster" } ] } ] }
Example Responses¶
Status code: 200
OK
The request is successful.
{
"errorCode" : "SVCSTG_AMS_2000000",
"errorMessage" : "success",
"metaData" : {
"count" : 1,
"start" : null,
"total" : 1
},
"metrics" : [ {
"namespace" : "PAAS.CONTAINER",
"metricName" : "cpuUsage",
"unit" : "Percent",
"dimensions" : [ {
"name" : "instance_id",
"value" : "7b6afb****4771358"
} ]
} ]
}
Status Codes¶
Status Code | Description |
---|---|
200 | OK The request is successful. |
400 | Bad Request Invalid request. The client should not repeat the request without modifications. |
401 | Unauthorized The authorization information is incorrect or invalid. |
403 | ForbiddenThe request is rejected. The server has received the request and understood it, but the server refuses to respond to it. The client should not repeat the request without modifications. |
500 | Internal Server Error The server is able to receive the request but unable to understand the request. |
503 | Service Unavailable The requested service is invalid. The client should not repeat the request without modifications. |
Error Codes¶
See Error Codes.