Description
You can call this operation to query monitoring data of a specified metric and attach a value of a group tag to the metric. You must specify the time range of the query and the array of the metric. Specify the query scope and summarize the data based on the tag. The query result includes multiple groups, and each group contains sequential data.
Call description
Prerequisite
You have passed the authentication for the OCP application service.
Request path
GET /api/v2/monitor/metricsWithLabel
Request parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| start_time | Datetime | Yes | 2020-02-16T05:32:16+08:00 | The start time of the monitoring data. |
| end_time | Datetime | Yes | 2020-02-16T07:32:16+08:00 | The end time of the monitoring data. |
| metrics | StringArray | Yes | io_read_time,io_write_time | The array of the monitoring metric. |
| groupBy | StringArray | Yes | app,obregion,ob_cluster_id | The tag used for summarizing the monitoring data. |
| interval | Integer | Yes | 60 | The interval of the monitoring data, in the unit of seconds. |
| labels | StringArray | Yes | app:ob,obregion=foo | The filter condition of the monitoring data. |
Response parameters
- Basic data structure
| Parameter | Type | Description |
|---|---|---|
| data | Object | The request data. |
| ├─ contents | Array | The array of the sample group. For more information about its data structure, see the following table. |
| successful | Boolean | Whether the request is successful. |
| timestamp | Datetime | The timestamp when the server completes the request. |
| duration | Integer | The time that the server takes to process the request, in milliseconds. |
| status | Integer | The encoding in compliance with the HTTP Status specification. |
| 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. |
- The data structure of the monitoring sampling group, which is determined based on the group tag
| Parameter | Type | Description |
|---|---|---|
| Tag A | String | Corresponding to the value of the tag. |
| Tag B | String | Corresponding to the value of the tag. |
| data | Array | The array of the sample. For more information about its data structure, see the following table. |
- Data structure of the sample information, which is determined based on the monitoring metric
| Parameter | Type | Description |
|---|---|---|
| timestamp | Integer | The point in the sampling time, which is counted from 1970-01-01 00:00:00 in the unit of seconds. |
| Metric name A | Float | Corresponding to the sample value of the index |
| Metric name B | Float | Corresponding to the sample value of the index |
Examples
Sample request
Query monitoring data generated from 2020-11-11 18:30:00.000+08:00 to 2020-11-11 19:00:00.000+08:00. The requested metric is sql_all_count.
The data output interval is 1s. The data is filtered based on the app=ob condition. The monitoring data is summarized based on the app, obregion, and ob_cluster_id tags.
api/v2/monitor/metricsWithLabel?labels=app%3Aob&groupBy=app%2Cobregion%2Cob_cluster_id&metrics=sql_all_count&interval=1&limit=5&2020-11-11T18%3A30%3A00.000%2B08%3A00&endTime=2020-11-11T19%3A00%3A00.000%2B08%3A00
Sample response
{
"duration": 514,
"server": "xxx.xxx.xxx.xxx",
"status": 200,
"successful": true,
"timestamp": "2020-11-17T19:19:30.209+08:00",
"traceId": "d972475d85b0405a",
"data": {
"contents": [
{
"app": "OB",
"obregion": "ob1",
"ob_cluster_id": "2",
"data": [
{
"sql_all_count": 38.00,
"timestamp": 1605608370
},
{
"sql_all_count": 43.50,
"timestamp": 1605608372
},
{
"sql_all_count": 38.50,
"timestamp": 1605608374
}
]
},
{
"app": "OB",
"obregion": "ob2",
"ob_cluster_id": "3",
"data": [
{
"sql_all_count": 85.00,
"timestamp": 1605608370
},
{
"sql_all_count": 91.00,
"timestamp": 1605608372
},
{
"sql_all_count": 187.50,
"timestamp": 1605608374
}
]
}
],
"page": {
"number": 2,
"size": 2147483647,
"totalElements": 3,
"totalPages": 1
}
}
}