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, which can be obtained from the console or by calling an API. For details, see Obtaining a Project ID.  | 
     
| 
        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.  | 
     
| 
        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. For details, see Obtaining a Token.  | 
     
| 
        Content-Type  | 
      
        Yes  | 
      
        String  | 
      
        Message body type or format. 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 time series dimensions. To query the time series dimension list, call the API Querying Time Series Objects.  | 
     
| 
        metricName  | 
      
        No  | 
      
        String  | 
      
        Metric name. Length: 1 to 255 characters. Options: basic metrics (such as cpuUsage and cpuCoreUsed) provided by AOM, and custom metrics. To query metric names, call the API Querying Tag Values.  | 
     
| 
        namespace  | 
      
        Yes  | 
      
        String  | 
      
        Metric namespace. Options: 
 Custom namespaces are also supported. To query namespaces, call the API Querying Tag Values. Enumeration values: 
  | 
     
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 time series dimensions. To query the time series dimension list, call the API Querying Time Series Objects.  | 
     
| 
        dimensionvaluehash  | 
      
        String  | 
      
        Metric hash value.  | 
     
| 
        metricName  | 
      
        String  | 
      
        Metric name.  | 
     
| 
        namespace  | 
      
        String  | 
      
        Namespace.  | 
     
| 
        unit  | 
      
        String  | 
      
        Metric unit.  | 
     
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.