Baidu AI Cloud
中国站

百度智能云

Cloud Monitor

Custom Monitoring - Query Data Interface

Interface Description

Acquire the time series data for one or more statistical data of the custom monitoring specified metric.

Interface Limit

o The number of data points returned once should not exceed 1,440.

Request Structure

  • Request method:POST
  • Request URL:/csm/api/v1/userId/{userId}/custom/namespaces/{namespace}/metrics/{metricName}/data

List of parameters:

URL Parameter

Name Type Description Required?
userId String The tenant ID Yes URL Parameter
namespace String Scope Yes URL Parameter
metricName String Monitoring metric name Yes URL Parameter

RequestBody Parameters

Name Type Description Required?
statistics The statistics, whose optional values are average, maximum, minimum, sum, and sampleCount Types of statistical methods Yes Query Parameters
dimensions List<String>, which consists of dimensionName:dimensionValue. When the metric has multiple dimensions, connect with the semicolon, e.g., dimensionName: dimensionValue; dimensionName: dimensionValue; and only one dimension value can be designated for the same dimension The dimension list Yes Query Parameters
startTime The String. Refer to the date and time, which should be UTC. The query start time Yes Query Parameters
endTime The String. Refer to the date and time, which should be UTC. The query end time Yes Query Parameters
cycle Integer, unit: s Statistical cycle Yes Query Parameters

Parameter Interpretation

  • For namespace metric, statistic, dimension, and other concepts, see the Core Concept.

Response Parameter

Name Type Description
requestId String The request identification
code String Return code
message String Error information
dataPoints List(DataPoint) Monitoring metric
dimensions List(Dimensions) Combination of dimensions

DataPoint

Name Type Description
average double The mean value of a metric within the statistical period
sum double The sum value of a metric within the statistical period
minimum double The minimum value of a metric within the statistical period
maximum double The maximum value of a metric within the statistical period
sampleCount Integer The number of data points of a metric within the statistical period
timestamp The String. Refer to Date and Time, which should be UTC. The time corresponding to the statistical period of metric

Dimensions

Name Type Description
name String Dimension name
value String Dimension value

Request Example

POST  /csm/api/v1/userId/useer1/custom/namespaces/namespace1/metrics/metricName1/data  HTTP/1.1  
Host:bcm.cnhzpro.agilecloud.com:80  

{ 
    "startTime":"2020-12-31T08:00:00Z",
    "endTime":"2020-12-31T08:02:00Z",
    "dimensions":[
        "dimension1:myMachine;dimension2:myService"
    ],
    "statistics":"average",
    "cycle":60
}   

Response Example

Example of successful response

When you query the data, you need to fill in the statistics parameter. The value of this parameter determines which attributes exist for a dataPoint in the response.

When statistics=average, an example of the returned result is as follows:

HTTP/1.1 200 OK
x-bce-request-id: dwegvad4-dwea-4d3dsa-8ew2-4b7263fs1ecd
Content-Type: application/json;charset=UTF-8
[
    {
        "dataPoints": [
            {
                "average": 2.24,
                "timestamp": "1609387200"
            },
            {
                "average": 0.22,
                "timestamp": "1609387260"
            },
            {
                "average": 0.19,
                "timestamp": "1609387320"
            }
        ],
        "dimensions":[
            {
                "name": "dimension1",
                "value": "myMachine"
            },
            {
                 "name": "dimension2",
                    "value": "myService"
            }
        ]
    }
]

Failed response example

Case 1 No data is queried. No monitoring data is queried from the start time to the end time under the specified user, namespace, monitor item, and dimension in the request.

When this case occurs, the corresponding time point is returned for you, but there is no monitoring data.

HTTP/1.1 200 OK
x-bce-request-id: dd00bad4-d22a-4d1c-8f12-4b513f0b91ec
Content-Type: application/json;charset=UTF-8
[
    {
        "dataPoints": [
            {
                "timestamp": "1609387200"
            },
            {
                "timestamp": "1609387260"
            },
            {
                "timestamp": "1609387320"
            }
        ],
        "dimensions":[
            {
                "name": "dimension1",
                "value": "myMachine"
            },
            {
                 "name": "dimension2",
                    "value": "myService"
            }
        ]
    }
]

Case 2 The parameter is incorrect. The following example shows that the statistics parameter is not a value in an optional set range.

HTTP/1.1 200 OK
x-bce-request-id: dd00bad4-d22a-4d1c-8f12-4b513f0b91ec
Content-Type: application/json;charset=UTF-8
{
    "requestId": "dd00bad4-d22a-4d1c-8f12-4b513f0b91ec",
    "code": "ParameterValueException",
    "message": "The request param value: max is misMatch."
}

The following example shows that the format of value for the dimension parameter is incorrect.

HTTP/1.1 200 OK
x-bce-request-id: dd00bad4-d22a-4d1c-8f12-4b513f0b91ec
Content-Type: application/json;charset=UTF-8
{
    "requestId": "dd00bad4-d22a-4d1c-8f12-4b513f0b91ec",
    "code": "ParamValueNotInScopeException",
    "message": "The request param dimension value mismatch."
}
Previous
Baidu AI Cloud Product Mmonitoring and Parameters
Next
Custom Monitoring-Push Data Interface