Querying Time Series Data
Function
This API is used to query time series data within a specified period. You can specify a dimension or period to query. (This API will not evolve. You are advised to use Querying Expression Calculation Results in a Specified Period Using the POST Method.)
Calling Method
For details, see Calling APIs.
URI
POST /v2/{project_id}/samples
| 
        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  | 
     
|---|---|---|---|
| 
        fill_value  | 
      
        No  | 
      
        String  | 
      
        Value filled for breakpoints in time series data. Default value: –1. 
  | 
     
Request Parameters
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        samples  | 
      
        Yes  | 
      
        Array of QuerySample objects  | 
      
        List of time series objects. A JSON array can contain up to 20 objects.  | 
     
| 
        statistics  | 
      
        Yes  | 
      
        Array of strings  | 
      
        Statistic. Values: maximum, minimum, sum, average, and sampleCount.  | 
     
| 
        period  | 
      
        Yes  | 
      
        Integer  | 
      
        Monitoring data granularity. Options: 
  | 
     
| 
        time_range  | 
      
        Yes  | 
      
        String  | 
      
        Time range specified to query data of the last N minutes when the client time is inconsistent with the server time. It can also be used to accurately query the data of a specified period. Example: 
 Format: startTimeInMillis.endTimeInMillis.durationInMinutes Parameter description: 
 Constraint: In a single request, the following condition must be met: durationInMinutes × 60/period ≤ 1,440  | 
     
| 
        Parameter  | 
      
        Mandatory  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|---|
| 
        namespace  | 
      
        Yes  | 
      
        String  | 
      
        Namespace of time series objects. Options: PAAS.CONTAINER, PAAS.NODE, PAAS.SLA, PAAS.AGGR, and CUSTOMMETRICS. - PAAS.CONTAINER: namespace of application time series objects. 
 To query namespaces, call the API Querying Tag Values.  | 
     
| 
        dimensions  | 
      
        Yes  | 
      
        Array of DimensionSeries objects  | 
      
        List of time series dimensions. To query the time series dimension list, call the API Querying Time Series Objects.  | 
     
| 
        metric_name  | 
      
        Yes  | 
      
        String  | 
      
        Time series name. Length: 1 to 255 characters. Options: basic time series names (such as cpuUsage and cpuCoreUsed) provided by AOM, and custom time series names. To query time series names, call the API Querying Tag Values.  | 
     
Response Parameters
Status code: 200
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        samples  | 
      
        Array of SampleDataValue objects  | 
      
        List of time series objects.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        sample  | 
      
        QuerySample object  | 
      
        List of time series objects.  | 
     
| 
        data_points  | 
      
        Array of MetricDataPoints objects  | 
      
        Time series data.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        namespace  | 
      
        String  | 
      
        Namespace of time series objects. Options: PAAS.CONTAINER, PAAS.NODE, PAAS.SLA, PAAS.AGGR, and CUSTOMMETRICS. - PAAS.CONTAINER: namespace of application time series objects. 
 To query namespaces, call the API Querying Tag Values.  | 
     
| 
        dimensions  | 
      
        Array of DimensionSeries objects  | 
      
        List of time series dimensions. To query the time series dimension list, call the API Querying Time Series Objects.  | 
     
| 
        metric_name  | 
      
        String  | 
      
        Time series name. Length: 1 to 255 characters. Options: basic time series names (such as cpuUsage and cpuCoreUsed) provided by AOM, and custom time series names. To query time series names, call the API Querying Tag Values.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        name  | 
      
        String  | 
      
        Dimension name.  | 
     
| 
        value  | 
      
        String  | 
      
        Dimension value.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        statistics  | 
      
        Array of StatisticValue objects  | 
      
        Statistic.  | 
     
| 
        timestamp  | 
      
        Long  | 
      
        Timestamp.  | 
     
| 
        unit  | 
      
        String  | 
      
        Time series unit.  | 
     
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        statistic  | 
      
        String  | 
      
        Statistic.  | 
     
| 
        value  | 
      
        Double  | 
      
        Statistical result.  | 
     
Status code: 400
| 
        Parameter  | 
      
        Type  | 
      
        Description  | 
     
|---|---|---|
| 
        error_code  | 
      
        String  | 
      
        Error code.  | 
     
| 
        error_msg  | 
      
        String  | 
      
        Error message.  | 
     
| 
        error_type  | 
      
        String  | 
      
        Error type.  | 
     
| 
        trace_id  | 
      
        String  | 
      
        Request ID.  | 
     
Example Requests
Query time series data in the last five minutes by namespace, metric_name, and dimensions.
https://{Endpoint}/v2/{project_id}/samples
{
    "samples": [
        {
            "namespace": "PAAS.CONTAINER",
            "metric_name": "aom_process_cpu_usage",
            "dimensions": [
                {
                    "name": "appName",
                    "value": "aomApp"
                }
            ]
        }
    ],
    "period": 60,
    "time_range": "-1.-1.5",// Last 5 minutes
      "statistics": [
        "sum"
    ]
}
 Example Responses
Status code: 200
OK: The request is successful.
{
  "samples" : [ {
    "sample" : {
      "namespace" : "PAAS.CONTAINER",
      "metric_name" : "aom_process_cpu_usage",
      "dimensions" : [ {
        "name" : "appName",
        "value" : "aomApp"
      } ]
    },
    "data_points" : [ {
      "timestamp" : 1694673300000,
      "unit" : "Percent",
      "statistics" : [ {
        "statistic" : "sum",
        "value" : "23"
      } ]
    } ]
  } ]
}
  Status code: 400
Bad Request: The request is invalid. The client should not repeat the request without modifications.
{
  "error_code" : "AOM.04008105",
  "error_msg" : "Query metric data samples is invalid",
  "error_type" : "BAD_REQUEST",
  "trace_id" : ""
}
 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.