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: 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:
|
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. |
Example Requests
-
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" : "test" } ] } ] }
-
Query metrics by inventory ID.
POST https://{Endpoint}/v1/{project_id}/ams/metrics?type=inventory { "inventoryId" : "application_************7-b56f-fa163e3fee10" }
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" : "abc", "metricName" : "cpuUsage", "unit" : "Percent", "dimensions" : [ { "name" : "instance_id", "value" : "demo1" } ] } ] }
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 |
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.
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