Feature description
Queries monitoring data for the specified metric. The query needs to specify the time range and the array of metrics. The query range is specified by tags, and the data is summarized by the specified tags. The results are output in a time series format.
No matter how large the time range is, the result data size will approach 1,440 sampling points.
Call instructions
Interface constraints
The caller needs to authenticate through the OCP application service.
Request path
GET /api/v2/monitor/metric
Request parameters
body:
Parameter |
Type |
Required |
Example Value |
Description |
|---|---|---|---|---|
| startTime | Datetime | Yes | 2020-02-16T05:32:16+08:00 | The start time of the monitored data. |
| endTime | Datetime | Yes | 2020-02-16T07:32:16+08:00 | The end time of the monitored data. |
| metrics | StringArray | Yes | io_read_time,io_write_time | The array of monitored metrics. |
| groupBy | StringArray | Yes | app,ob_cluster_name,ob_cluster_id | The summary tags of the monitored data. The values are as follows: host, ob, and obproxy, which respectively represent host monitoring, OceanBase monitoring, and OBProxy monitoring. |
| interval | Integer | Yes | 60 | The time granularity of the monitored data, in seconds. |
| minStep | Integer | No | 10 | The query sampling interval, which is the minimum monitoring result sampling interval. The default value is 0. |
| maxPoints | Integer | No | 360 | The maximum number of points in the monitoring result. The default value is 1440. |
| labels | StringArray | Yes | app:ob,ob_cluster_name=foo | The filter conditions of the monitored data. |
Note
Starting from OCP V4.2.1, the parameter name obregion is updated to ob_cluster_name. The existing interface calls that use this parameter are not affected.
Return result
Basic data structure
Parameter |
Type |
Description |
|---|---|---|
| data | Object | The requested data. |
| ├─ contents | Array | The array of monitoring samples. The data structure varies based on the queried monitoring metrics. For more information, see Monitoring sample data structure. |
| ├─ page | Object | The pagination information. For more information, see page data structure. |
| successful | Boolean | Indicates whether the request was successful. |
| timestamp | Datetime | The timestamp when the server completed the request. |
| duration | Integer | The time taken by the server to process the request, in milliseconds. |
| status | Integer | The HTTP status code that conforms to the HTTP Status specification. |
| traceId | String | The Trace ID of the request, which is used for troubleshooting. |
| server | String | The address of the server that responded to the request. |
Monitoring sample data structure
Parameter |
Type |
Description |
|---|---|---|
| timestamp | Integer | The timestamp of the sample, which is the number of seconds since 1970-01-01 00:00:00. |
| Metric A | Float | The sampled value of the corresponding metric. |
| Metric B | Float | The sampled value of the corresponding metric. |
page data structure
Parameter |
Type |
Description |
|---|---|---|
| totalElements | Integer | The total number of records. |
| totalPages | Integer | The total number of pages. |
| number | Integer | The current page number. |
| size | Integer | The size of the current page. |
Example
Request example
Request monitoring data from 2020-11-11 18:30:00.000+08:00 to 2020-11-11 19:00:00.000+08:00; the monitoring metrics are net_recv and net_send, with a sampling interval of 60 seconds; the metric values are app=ob, ob_cluster_name=ob1, ob_cluster_id=1; 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
where:
- app: the source of the monitoring data. Valid values:
host,ob, andobproxy, representing host monitoring, OceanBase monitoring, and OBProxy monitoring, respectively. - ob_cluster_name: the name of the OceanBase cluster being monitored.
- ob_cluster_id: the ID of the OceanBase cluster being monitored.
Response example
{
"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
}
}
}
