Updated on 2024-07-11 GMT+08:00

Querying the Workload Replay Result

Function

This API is used to obtain workload replay results, including time-based replay statistics, abnormal SQL details and statistics, and slow SQL details and statistics.

URI

GET /v5/{project_id}/jobs/{job_id}/replay-results

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region.

For details, see Obtaining a Project ID.

job_id

Yes

String

Task ID.

Table 2 Query parameters

Parameter

Mandatory

Type

Description

type

Yes

String

Result type. The value can be:

  • shard_statistics: time-based replay overview statistics.
  • slow_sql: slow SQL details.
  • error_sql: abnormal SQL details.
  • slow_sql_template: slow SQL statistics.
  • error_sql_template: abnormal SQL statistics.
  • replaying_sql: Details about the SQL that is being replayed.
  • error_classification: Abnormal SQL category during replay.

Enumerated values:

  • shard_statistics
  • slow_sql
  • error_sql
  • slow_sql_template
  • error_sql_template
  • replaying_sql
  • error_classification

start_time

No

String

Start time of data query. This parameter is mandatory when type is set to shard_statistics, slow_sql, or error_sql.

end_time

No

String

End time of data query. This parameter is mandatory when type is set to shard_statistics, slow_sql, or error_sql.

offset

No

Long

Start offset in data pagination. This parameter is mandatory when type is set to slow_sql, error_sql, slow_sql_template, or error_sql_template.

limit

No

Long

Number of data records on the current page in data pagination. This parameter is mandatory when type is set to slow_sql, error_sql, slow_sql_template, or error_sql_template.

sort_key

No

String

The keyword based on which the returned results are sorted. slow_sql_template supports keywords count, maxLatency, and avgLatency, and error_sql_template supports keyword count.

sort_dir

No

String

Sorting type.

  • asc: The query results are displayed in ascending order.
  • desc: The query results are displayed in the descending order.

Default value: desc

Enumerated values:

  • asc
  • desc

target_name

No

String

Name of the replay database, which is used to filter the replay results of the destination database and source database mirror in the consistency replay policy scenario. This parameter is optional. If this parameter is not specified, all data is queried by default. The value can be:

  • target: Queries the replay result of the destination database.
  • target_mirror: Queries the replay result of the source database mirror.

Enumerated values:

  • target
  • target_mirror

is_sample

No

Boolean

Indicates whether to query samples. The value can be true or false. This parameter is valid only when type is set to slow_sql or error_sql. If this parameter is set to true, only one sample data record is queried.

error_type

No

String

Error category. This parameter is valid only when type is set to error_sql or error_sql_template. Data is filtered based on the error category.

sql_template_md5

No

String

SQL template MD5. This parameter is valid only when type is set to slow_sql or error_sql. Abnormal and slow SQL statements are filtered based on the template.

For details about the parameter value, see the returned field when type is set to slow_sql_template or error_sql_template.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

Content-Type

Yes

String

MIME type of the request body. Use the default value application/json. For APIs used to upload objects or images, the value varies depending on the flow type.

The default value is application/json.

X-Auth-Token

Yes

String

User token obtained from IAM. It is a response to the API for obtaining a user token. After a request is processed, the value of X-Subject-Token in the header is the token value.

X-Language

No

String

Request language type.

Default value: en-us

Enumerated values:

  • en-us
  • zh-cn

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

total_count

Long

Total number of records.

shard_statics

Array of objects

List of time-based replay statistics. This parameter is returned when type is set to shard_statistics.

For details, see Table 5.

slow_sqls

Array of objects

List of slow SQL statements. This parameter is returned when type is set to slow_sql.

For details, see Table 6.

slow_sql_templates

Array of objects

List of slow SQL statistics. This parameter is returned when type is set to slow_sql_template.

For details, see Table 7.

error_sqls

Array of objects

List of abnormal SQL statements. This parameter is returned when type is set to error_sql.

For details, see Table 8.

error_sql_templates

Array of objects

List of abnormal SQL statistics. This parameter is returned when type is set to error_sql_template.

For details, see Table 9.

replaying_sqls

Array of objects

List of SQL statements that are being replayed. This parameter is returned when type is set to replaying_sql.

For details, see Table 10.

error_classifications

Array of objects

Abnormal SQL category information during replay, which is returned when type is set to error_classification.

For details, see Table 11.

Table 5 Data structure description of field shard_statics

Parameter

Type

Description

time

String

Time point for replay.

total

Long

Total SQLs.

finish

Long

Executed SQLs.

abnormal

Long

Abnormal SQLs.

slow

Long

Slow SQLs.

Table 6 Data structure description of field slow_sqls

Parameter

Type

Description

object_type

String

SQL type.

slow_sql

String

SQL statement.

old_time

String

Execution duration on the source database.

replay_time

String

Execution duration on the destination database.

Table 7 Data structure description of field slow_sql_templates

Parameter

Type

Description

sql_template

String

SQL template.

sql_template_md5

String

SQL template MD5.

target_name

String

Destination database name.

schema_name

String

Schema name.

query_type

String

SQL type.

min_latency

Long

Minimum SQL execution duration.

max_latency

Long

Maximum SQL execution duration.

avg_latency

Long

Average SQL execution duration.

total_latency

Long

Total SQL execution duration.

target_type

String

Destination database type.

count

Long

Number of SQLs.

Table 8 Data structure description of field error_sqls

Parameter

Type

Description

object_type

String

SQL type.

abnormal_sql

String

SQL statement.

abnormal_info

String

Exception cause description.

Table 9 Data structure description of field error_sql_templates

Parameter

Type

Description

sql_template

String

SQL template.

sql_template_md5

String

SQL template MD5.

target_name

String

Destination database name.

schema_name

String

Schema name.

query_type

String

SQL type.

target_type

String

Destination database type.

count

Long

Number of classified SQL statements.

Table 10 Data structure description of field replaying_sqls

Parameter

Type

Description

schema_name

String

Database or schema name.

sql_statement

String

SQL statement.

latency

Integer

Original execution duration.

execute_latency

Integer

Replay execution duration.

status

String

Execution status.

client

String

Client IP address.

connection_id

String

Connection ID.

replay_start_time

String

Replay start time.

Table 11 Data structure description of field error_classifications

Parameter

Type

Description

target_name

String

Destination database ID.

error_type

String

Abnormal SQL category.

error_cnt

String

Number of abnormal SQL statements.

error_template_cnt

String

Number of abnormal SQL templates.

Status code: 400

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum length: 12

Maximum length: 12

error_msg

String

Error message.

Minimum length: 1

Maximum length: 512

Example Request

  • Querying time-based replay overview statistics within a specified time range
    https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/jobs/7b35723d-1525-410e-90c3-70f9ed3jb601/replay-results?type=shard_statistics&start_time=1700421943000&end_time=1700439961000
  • Querying details about slow SQL statements replayed in a specified time range in data pagination
    https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/jobs/7b35723d-1525-410e-90c3-70f9ed3jb601/replay-results?type=slow_sql&start_time=1700421943&end_time=1700439961&offset=1&limit=10
  • Querying statistics of slow SQL statements in data pagination
    https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/jobs/7b35723d-1525-410e-90c3-70f9ed3jb601/replay-results?type=slow_sql_template&offset=1&limit=10
  • Querying details about abnormal SQL statements replayed in a specified time range in data pagination
    https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/jobs/7b35723d-1525-410e-90c3-70f9ed3jb601/replay-results?type=error_sql&start_time=1700421943&end_time=1700439961&offset=1&limit=10
  • Querying statistics of abnormal SQL statements in data pagination
    https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/jobs/7b35723d-1525-410e-90c3-70f9ed3jb601/replay-results?type=error_sql_template&offset=1&limit=10
  • Querying details about the SQL statement that is being replayed
    https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/jobs/7b35723d-1525-410e-90c3-70f9ed3jb601/replay-results?type=replaying_sql

Example Response

Status code: 200

OK

{
    "total_count": 100,
    "shard_statics": null,
    "slow_sqls": null,
    "slow_sql_templates": null,
    "error_sqls": null,
    "error_sql_templates": null,
    "replaying_sqls": [
        {
            "schema_name": "db",
            "sql_statement": "select * from preple where id = 1",
            "latency": 0,
            "execute_latency": 0,
            "status": "running",
            "replay_start_time": "2024-04-23T12:07:53Z"
        },
        {
            "schema_name": "db",
            "sql_statement": "select * from preple where id = 1",
            "latency": 0,
            "execute_latency": 1,
            "status": "running",
            "replay_start_time": "2024-04-23T12:07:53Z"
        }
    ]
}

Status code: 400

Bad Request

{
	"error_code": "DRS.10020000",
	"error_msg": "Incorrect parameter type."
}

Status Code

Status Code

Description

200

OK

400

Bad Request

Error Code

For details, see Error Code.