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.
Calling Method
For details, see Calling APIs.
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 | Maximum number of returned records. Value range: 1–1000. Default value: 1000. Minimum: 0 Maximum: 4 |
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 the value of type in the URI is not inventory, metrics are queried based on the information carried by metricItems. |
Parameter | Mandatory | Type | Description |
---|---|---|---|
dimensions | No | Array of Dimension objects | List of metric dimensions. |
metricName | No | String | Metric name. Length: 1 to 255 characters. Value range: cpuUsage, cpuCoreUsed, and other basic metrics provided by AOM. cpuUsage: CPU usage. cpuCoreUsed: used CPU cores. Custom metrics. |
namespace | Yes | String | Metric namespace. Values: PAAS.CONTAINER: namespace of component, instance, process, and container metrics. PAAS.NODE: namespace of host, network, disk, and file system metrics. PAAS.SLA: namespace of SLA metrics. PAAS.AGGR: namespace of cluster metrics. CUSTOMMETRICS: default namespace of custom metrics. Enumeration values:
|
Parameter | Mandatory | Type | Description |
---|---|---|---|
name | Yes | String | Dimension name. |
value | Yes | String | Dimension value. |
Response Parameters
Status code: 200
Parameter | Type | Description |
---|---|---|
metaData | MetaDataSeries object | Metadata, including pagination information. |
metrics | Array of MetricItemResultAPI objects | Metric list. |
Parameter | Type | Description |
---|---|---|
count | Integer | Number of returned records. |
offset | Integer | Start of the next page, which is used for pagination. null: No more data. |
total | Integer | Total number of records. |
nextToken | Integer | Offset. |
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. |
Example Requests
- Query metrics by inventory ID.https://{Endpoint}/v1/{project_id}/ams/metrics{"metricItems" : [ {"namespace" : "PAAS.CONTAINER","dimensions" : [ {"name" : "appName","value" : "aomApp"}, {"name" : "clusterName","value" : "aomCluster"} ]} ]}
- Query metrics by namespace, appName, and clusterName.https://{Endpoint}/v1/{project_id}/ams/metrics?type=inventory{"inventoryId" : "application_xxxxxxxx-xxxx-xxxx-xxxx-xxxxx3fee10"}
Example Responses
Status code: 200
OK: The request is successful.
{"errorCode" : "SVCSTG_AMS_2000000","errorMessage" : "success","metaData" : {"count" : 1,"offset" : 1,"nextToken" : null,"total" : 1},"metrics" : [ {"namespace" : "PAAS.CONTAINER","metricName" : "aom_process_cpu_usage","unit" : "Percent","dimensions" : [ {"name" : "appName","value" : "aomApp"} ]} ]}
Status Codes
Status Code | Description |
---|---|
200 | OK: The request is successful. |
400 | Bad Request: The request is invalid. The client should not repeat the request without modifications. |
401 | Unauthorized: The authentication information is incorrect or invalid. |
403 | Forbidden: The 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.
- Function
- Calling Method
- URI
- Request Parameters
- Response Parameters
- Example Requests
- Example Responses
- Status Codes
- Error Codes