查询录制回放结果
功能介绍
获取录制回放结果数据,包括:回放基于时间维度统计信息,异常SQL及统计结果、慢SQL及统计结果。
URI
GET /v5/{project_id}/jobs/{job_id}/replay-results
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
project_id |
是 |
String |
租户在某一Region下的Project ID。 获取方法请参见获取项目ID。 |
|
job_id |
是 |
String |
任务ID。 |
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
type |
是 |
String |
结果类型。取值:
枚举值:
|
|
start_time |
否 |
String |
查询数据的起始时间,在type为shard_statistics、slow_sql、error_sql时必填。 |
|
end_time |
否 |
String |
查询数据的结束时间,在type为shard_statistics、slow_sql、error_sql时必填. |
|
offset |
否 |
Long |
分页查询数据表当前起始偏移量, 在type为slow_sql、error_sql、slow_sql_template、error_sql_template必填。 |
|
limit |
否 |
Long |
分页查询数据表当前页数据总量,在type为slow_sql、error_sql、slow_sql_template、error_sql_template必填。 |
|
sort_key |
否 |
String |
返回结果按该关键字排序(slow_sql_template支持count、maxLatency、avgLatency关键字,error_sql_template支持count关键字)。 |
|
sort_dir |
否 |
String |
排序规则,取值如下:
缺省值:desc 枚举值:
|
|
target_name |
否 |
String |
回放数据库名称,用于在一致性回放策略场景,过滤目标库与源库镜像库回放结果。参数非必须,不提供则默认查询所有数据,其取值如下:
枚举值:
|
|
is_sample |
否 |
Boolean |
是否查询样例,取值true或者false。type取值为slow_sql后者error_sql时生效,值为true时只查询一条样例数据。 |
|
error_type |
否 |
String |
错误分类,type取值为error_sql或者error_sql_template时生效,根据错误分类过滤数据。 |
|
sql_template_md5 |
否 |
String |
SQL模板md5,type取值为slow_sql或者error_sql时生效。根据模板过滤对应的异常SQL和慢SQL。 该参数取值可参考type为slow_sql_template或者error_sql_template时的返回字段。 |
请求参数
|
参数 |
是否必选 |
参数类型 |
描述 |
|---|---|---|---|
|
Content-Type |
是 |
String |
发送的实体的MIME类型。推荐用户默认使用application/json,如果API是对象、镜像上传等接口,媒体类型可按照流类型的不同进行确定。 缺省值:application/json |
|
X-Auth-Token |
是 |
String |
从IAM服务获取的用户Token。用户Token也就是调用IAM获取用户Token接口的响应值,请求响应成功后在响应消息头中包含的“X-Subject-Token”的值即为Token值。 |
|
X-Language |
否 |
String |
请求语言类型。 缺省值:en-us 枚举值:
|
响应参数
状态码: 200
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
total_count |
Long |
数据总量。 |
|
shard_statics |
Array of objects |
回放基于时间统计详细信息列表,在type为shard_statistics时返回。 详情请参见表5。 |
|
slow_sqls |
Array of objects |
慢SQL信息列表,在type为slow_sql时返回。 详情请参见表6。 |
|
slow_sql_templates |
Array of objects |
慢SQL统计信息列表,在type为slow_sql_template时返回。 详情请参见表7。 |
|
error_sqls |
Array of objects |
异常SQL信息列表,在type为error_sql时返回。 详情请参见表8。 |
|
error_sql_templates |
Array of objects |
异常SQL统计信息列表,在type为error_sql_template时返回。 详情请参见表9。 |
|
replaying_sqls |
Array of objects |
正在回放SQL信息列表,在type为replaying_sql时返回。 详情请参见表10。 |
|
error_classifications |
Array of objects |
回放异常SQL分类信息,在type为error_classification时返回。 详情请参见表11。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
time |
String |
回放时间点。 |
|
total |
Long |
SQL总量。 |
|
finish |
Long |
SQL执行量。 |
|
abnormal |
Long |
SQL异常量。 |
|
slow |
Long |
慢SQL数量。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
object_type |
String |
SQL语句类型。 |
|
slow_sql |
String |
SQL语句。 |
|
old_time |
String |
源库执行耗时。 |
|
replay_time |
String |
目标库回放执行耗时。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
sql_template |
String |
SQL语句模板。 |
|
sql_template_md5 |
String |
SQL语句模板MD5。 |
|
target_name |
String |
目标库别名。 |
|
schema_name |
String |
schema名称。 |
|
query_type |
String |
SQL类型。 |
|
min_latency |
Long |
SQL执行最小耗时。 |
|
max_latency |
Long |
SQL执行最大耗时。 |
|
avg_latency |
Long |
SQL执行平均耗时。 |
|
total_latency |
Long |
SQL执行总的耗时。 |
|
target_type |
String |
目标库类型。 |
|
count |
Long |
SQL数量。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
object_type |
String |
SQL类型。 |
|
abnormal_sql |
String |
SQL语句。 |
|
abnormal_info |
String |
异常原因描述。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
sql_template |
String |
SQL模板。 |
|
sql_template_md5 |
String |
SQL模板MD5。 |
|
target_name |
String |
目标库昵称。 |
|
schema_name |
String |
schema名称。 |
|
query_type |
String |
SQL类型。 |
|
target_type |
String |
目标库类型。 |
|
count |
Long |
归类的SQL数量。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
schema_name |
String |
库名或shema名称。 |
|
sql_statement |
String |
SQL语句。 |
|
latency |
Integer |
原始执行耗时。 |
|
execute_latency |
Integer |
回放执行耗时。 |
|
status |
String |
执行状态。 |
|
client |
String |
客户端IP。 |
|
connection_id |
String |
连接ID。 |
|
replay_start_time |
String |
回放开始时间。 |
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
target_name |
String |
目标库标识。 |
|
error_type |
String |
异常SQL分类。 |
|
error_cnt |
String |
异常SQL数量。 |
|
error_template_cnt |
String |
异常SQL模板数量。 |
状态码: 400
|
参数 |
参数类型 |
描述 |
|---|---|---|
|
error_code |
String |
错误码。 最小长度:12 最大长度:12 |
|
error_msg |
String |
错误描述。 最小长度:1 最大长度:512 |
请求示例
- 查询指定时间范围内回放详情基于时间序统计信息
https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/jobs/7b35723d-1525-410e-90c3-70f9ed3jb601/replay-results?type=shard_statistics&start_time=1700421943000&end_time=1700439961000 - 分页查询指定时间范围内回放的慢SQL详情
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 - 分页查询回放中慢SQL统计信息
https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/jobs/7b35723d-1525-410e-90c3-70f9ed3jb601/replay-results?type=slow_sql_template&offset=1&limit=10 - 分页查询指定时间范围内异常SQL详情
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 - 分页查询回放过程中异常SQL统计信息
https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/jobs/7b35723d-1525-410e-90c3-70f9ed3jb601/replay-results?type=error_sql_template&offset=1&limit=10 - 查询正在回放的SQL信息
https://{endpoint}/v5/5237e10fe9aa4ad5b16b6a5245248314/jobs/7b35723d-1525-410e-90c3-70f9ed3jb601/replay-results?type=replaying_sql
响应示例
状态码: 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"
}
]
}
状态码: 400
Bad Request
{
"error_code": "DRS.10020000",
"error_msg": "Incorrect parameter type."
}
状态码
|
状态码 |
描述 |
|---|---|
|
200 |
OK |
|
400 |
Bad Request |
错误码
请参见错误码。