Help Center/ Data Admin Service/ API Reference/ APIs (in OBT)/ Intelligent O&M/ Exporting the Quantity Trend of Slow Query Logs
Updated on 2025-05-19 GMT+08:00

Exporting the Quantity Trend of Slow Query Logs

Function

After Slow Query Logs is enabled, you can export the quantity trend of slow query logs. For free instances, you can only view data generated in the latest hour. The maximum query interval is one day.

URI

GET /v3/{project_id}/instances/{instance_id}/slow-sql-trend

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Explanation:

Project ID of a tenant in a region

To obtain this value, see Obtaining a Project ID.

Constraints:

N/A

Values:

The value can contain 32 characters. Only letters and digits are allowed.

Default value:

N/A

instance_id

Yes

String

Explanation:

Unique ID of an instance

Constraints:

N/A

Values:

The value can contain 32 characters. Only letters and digits are allowed.

Default value:

N/A

Table 2 Query parameters

Parameter

Mandatory

Type

Description

start_at

Yes

Long

Explanation:

Start time

Constraints:

Unix timestamp, in milliseconds

Values:

[0, 2^31-1]. The actual value depends on the query result.

Default value:

N/A

end_at

Yes

Long

Explanation:

End time

Constraints:

Unix timestamp, in milliseconds

Values:

[0, 2^31-1]. The actual value depends on the query result.

Default value:

N/A

datastore_type

Yes

String

Explanation:

Database type

Constraints:

N/A

Values:

  • MySQL
  • TaurusDB

Default value:

N/A

node_id

No

String

Explanation:

Node ID

Constraints:

N/A

Values:

The value can contain 32 characters. Only letters and digits are allowed.

Default value:

N/A

offset

No

Integer

Explanation:

Index offset. The query starts from the next piece of data indexed by this parameter. If this parameter is set to 1 and limit is set to 10, only the second to eleventh records are displayed.

Constraints:

N/A

Values:

[0, 2^31-1]

Default value:

0: The query starts from the first data record.

limit

No

Integer

Explanation:

Number of records to be queried. If this parameter is set to 10, a maximum of 10 records can be displayed.

Constraints:

N/A

Values:

[1, 100]

Default value:

20

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

slow_sql_trend_items

Array of Table 4 objects

Explanation:

Quantity trend of slow query logs

Values:

N/A

interval_millis

Long

Explanation:

Query interval

Values:

The interval is 10s if the query duration is within one hour, 60s if the query duration is within six hours, and 300s if the query duration is longer than six hours. The unit is millisecond.

total_count

Integer

Explanation:

Total execution time ranges

Values:

N/A

Table 4 slow_sql_trend_items

Parameter

Type

Description

timestamp

Long

Explanation:

Timestamp in milliseconds

Values:

The value ranges from timestamp to timestamp + interval_millis.

slow_log_count

Long

Number of slow query logs

Explanation:

Number of slow query logs

Values:

N/A

Example Request

Exporting the quantity trend of slow query logs

GET https://das.cn-north-1.myhuaweicloud.com/v3/054c630ff780d4cc2f40c00d7f6fb21d/instances/6243b3fcf2f948578d46ed4c52fb54eein01/slow-sql-trend?startAt=1719862675886&endAt=1719905875886&datastore_type=MySQL&offset=0&limit=10

Example Response

Status code: 200

Successful request

{
  "slow_sql_trend_items": [
    {
      "timestamp": 1719900000000,
      "slow_log_count": 10
    },
    {
      "timestamp": 1719903600000,
      "slow_log_count": 11
    }
  ],
  "interval_millis": 3600000,
  "total_count": 2
}

Status Codes

Status Code

Description

200

Successful request

400

Client error

500

Server error

Error Codes

See Error Codes.