Query monitoring data by tag

2024-11-06 03:13:28  Updated

Description

You can call this operation to query the monitoring data of specific metrics and specify tags to group the queried monitoring data. 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 result includes multiple groups, and the items in each group are listed by time.

Call description

Prerequisite

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

Request path

GET /api/v2/monitor/metricsWithLabel

Request parameters

Parameter Type Required? Example value Description
start_time Datetime Yes 2020-02-16T05:32:16+08:00 The start of the time range for querying monitoring data.
end_time 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 group. 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 a sampled monitoring data group, which is determined based on the specified tags
Parameter Type Description
Tag A String The value corresponding to Tag A.
Tag B String The value corresponding to Tag B.
data Array The array of the sampled data. For more information about its data structure, see the following table.
  • 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 generated from 2020-11-11 18:30:00.000+08:00 to 2020-11-11 19:00:00.000+08:00. Request the

sql_all_count metric.

Set the data sampling interval to 1s and specify to filter data based on the app=ob condition and to summarize the monitoring data based on the app, ob_cluster_name, and ob_cluster_id tags.

api/v2/monitor/metricsWithLabel?labels=app%3Aob&groupBy=app%2Cob_cluster_name%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": "a83ad33525",
    "status": 200,
    "successful": true,
    "timestamp": "2020-11-17T19:19:30.209+08:00",
    "traceId": "d972475d85b0405a",
    "data": {
        "contents": [
            {
                "app": "OB",
                "ob_cluster_name": "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",
                "ob_cluster_name": "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
        }
    }
}

Contact Us