Query monitoring data

2025-03-26 07:47:21  Updated

Description

You can call this operation to specify metrics to query the monitoring data of the metrics. You must specify the time range of the data to query and an array of metrics. You can also specify the query scope and summarize the data based on tags. The query results are listed by time.

The number of sampled monitoring data records in the query results approximate to 1440, regardless of the time range of the query.

Call description

Prerequisite

You have passed the authentication for the OceanBase Cloud Platform (OCP) application service.

Request path

GET /api/v2/monitor/metric

Request parameters

Parameter Type Required? Example value Description
startTime Datetime Yes 2020-02-16T05:32:16+08:00 The start of the time range for querying monitoring data.
endTime Datetime Yes 2020-02-16T07:32:16+08:00 The end of the time range for querying monitoring data.
metrics StringArray Yes io_read_time,io_write_time The array of the metrics to query.
groupBy StringArray Yes app,ob_cluster_name,ob_cluster_id The tags used for summarizing the monitoring data.
interval Integer Yes 60 The interval of the monitoring data, in seconds.
minStep Integer No 10 The minimum sampling interval of the metrics. Default value: 0.
maxPoints Integer No 360 The maximum number of monitoring data records that can be returned. Default value: 1440.
labels StringArray Yes app:ob,ob_cluster_name=foo The filter condition of the monitoring data.

Note

In OCP V4.2.1 and later, the ob_cluster_name parameter is used instead of the obregion parameter. Operations that use the obregion parameter are not affected.

Response parameters

  • Basic data structure
Parameter Type Description
data Object The requested data.
├─ contents Array The array of the sampled monitoring data. For more information about its data structure, see the following table.
successful Boolean Indicates whether the request is successful.
timestamp Datetime The timestamp when the server completes the request.
duration Integer The amount of time taken by the server to process the request, in milliseconds.
status Integer The HTTP status code.
traceId String The trace ID of the request. This trace ID is used for troubleshooting.
server String The address of the server that responds to the request.
  • Structure of the sampled data, which is determined based on the specified metrics
Parameter Type Description
timestamp Integer The point in time when data is sampled, which is a timestamp counted from 1970-01-01 00:00:00 in the unit of seconds.
Metric A Float The sampled monitoring data corresponding to Metric A.
Metric B Float The sampled monitoring data corresponding to Metric B.

Examples

Sample request

Query the monitoring data that is generated from 2020-11-11 18:30:00.000+08:00 to 2020-11-11 19:00:00.000+08:00. Request the net_recv and net_send metrics, and set the sampling interval to 60s. Set the value of app to ob, ob_cluster_name to ob1, and ob_cluster_id to 1. Specify that the monitoring data is summarized based on the app, ob_cluster_name, and ob_cluster_id tags.

/api/v2/monitor/metric?startTime=2020-11-11T18%3A30%3A00.000%2B08%3A00&endTime=2020-11-11T19%3A00%3A00.000%2B08%3A00&interval=60&metrics=net_recv%2Cnet_send&labels=app%3Aob%2Cob_cluster_name%3Aob1%2Cob_cluster_id%3A1&groupBy=app%2Cob_cluster_name%2Cob_cluster_id

Sample response

{
    "duration":113,
    "server": "a83ad33525",
    "status":200,
    "successful":true,
    "timestamp":"2020-11-17T19:01:45.404+08:00",
    "traceId":"0d40b2d8e6984e49",
    "data":{
        "contents":[
            {
                "net_recv":0.3,
                "net_send":0.31,
                "timestamp":1605609840
            },
            {
                "net_recv":0.29,
                "net_send":0.3,
                "timestamp":1605610800
            }
        ],
        "page":{
            "number":2,
            "size":2147483647,
            "totalElements":30,
            "totalPages":1
        }
    }
}

Contact Us