Query Profile Action

Request

GET /rest/v2/manager/query/query_info

GET /rest/v2/manager/query/trace/{trace_id}

GET /rest/v2/manager/query/sql/{query_id}

GET /rest/v2/manager/query/profile/text/{query_id}

GET /rest/v2/manager/query/profile/graph/{query_id}

GET /rest/v2/manager/query/profile/json/{query_id}

GET /rest/v2/manager/query/profile/fragments/{query_id}

GET /rest/v2/manager/query/current_queries

GET /rest/v2/manager/query/kill/{query_id}

Get the query information

GET /rest/v2/manager/query/query_info

Description

Gets information about select queries for all fe nodes in the cluster.

Query parameters

  • query_id

    Optional, specifies the query ID of the query to be returned, default returns information for all queries.

  • search

    Optional, specifies that query information containing strings is returned, currently only string matches are performed.

  • is_all_node

    Optional, if true, returns query information for all fe nodes, if false, returns query information for the current fe node. The default is true.

Response

  1. {
  2. "msg": "success",
  3. "code": 0,
  4. "data": {
  5. "column_names": [
  6. "Query ID",
  7. "FE节点",
  8. "查询用户",
  9. "执行数据库",
  10. "Sql",
  11. "查询类型",
  12. "开始时间",
  13. "结束时间",
  14. "执行时长",
  15. "状态"
  16. ],
  17. "rows": [
  18. [
  19. ...
  20. ]
  21. ]
  22. },
  23. "count": 0
  24. }

SinceVersion 1.2

Admin 和 Root 用户可以查看所有 Query。普通用户仅能查看自己发送的 Query。

Examples

  1. GET /rest/v2/manager/query/query_info
  2. {
  3. "msg": "success",
  4. "code": 0,
  5. "data": {
  6. "column_names": [
  7. "Query ID",
  8. "FE节点",
  9. "查询用户",
  10. "执行数据库",
  11. "Sql",
  12. "查询类型",
  13. "开始时间",
  14. "结束时间",
  15. "执行时长",
  16. "状态"
  17. ],
  18. "rows": [
  19. [
  20. "d7c93d9275334c35-9e6ac5f295a7134b",
  21. "127.0.0.1:8030",
  22. "root",
  23. "default_cluster:testdb",
  24. "select c.id, c.name, p.age, p.phone, c.date, c.cost from cost c join people p on c.id = p.id where p.age > 20 order by c.id",
  25. "Query",
  26. "2021-07-29 16:59:12",
  27. "2021-07-29 16:59:12",
  28. "109ms",
  29. "EOF"
  30. ]
  31. ]
  32. },
  33. "count": 0
  34. }

Get Query Id By Trace Id

GET /rest/v2/manager/query/trace_id/{trace_id}

Description

Get query id by trance id.

Before executing a Query, set a unique trace id:

set session_context="trace_id:your_trace_id";

After executing the Query within the same Session, the query id can be obtained through the trace id.

Path parameters

  • {trace_id}

    User specific trace id.

Query parameters

Response

  1. {
  2. "msg": "success",
  3. "code": 0,
  4. "data": "fb1d9737de914af1-a498d5c5dec638d3",
  5. "count": 0
  6. }

SinceVersion 1.2

Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:

  1. {
  2. "msg": "Bad Request",
  3. "code": 403,
  4. "data": "error messages",
  5. "count": 0
  6. }

Get the sql and text profile for the specified query

GET /rest/v2/manager/query/sql/{query_id}

GET /rest/v2/manager/query/profile/text/{query_id}

Description

Get the sql and profile text for the specified query id.

Path parameters

  • query_id

    The query id.

Query parameters

  • is_all_node

    Optional, if true then query for the specified query id in all fe nodes, if false then query for the specified query id in the currently connected fe nodes. The default is true.

Response

  1. {
  2. "msg": "success",
  3. "code": 0,
  4. "data": {
  5. "sql": ""
  6. },
  7. "count": 0
  8. }
  1. {
  2. "msg": "success",
  3. "code": 0,
  4. "data": {
  5. "profile": ""
  6. },
  7. "count": 0
  8. }

SinceVersion 1.2

Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:

  1. {
  2. "msg": "Bad Request",
  3. "code": 403,
  4. "data": "error messages",
  5. "count": 0
  6. }

### Examples

  1. get sql.

    1. GET /rest/v2/manager/query/sql/d7c93d9275334c35-9e6ac5f295a7134b
    2. Response:
    3. {
    4. "msg": "success",
    5. "code": 0,
    6. "data": {
    7. "sql": "select c.id, c.name, p.age, p.phone, c.date, c.cost from cost c join people p on c.id = p.id where p.age > 20 order by c.id"
    8. },
    9. "count": 0
    10. }

Get the specified query fragment and instance information

GET /rest/v2/manager/query/profile/fragments/{query_id}

Description

Get the fragment name, instance id, host ip/port and execution time for the specified query id.

Path parameters

  • query_id

    The query id.

Query parameters

  • is_all_node

    Optional, if true then query for the specified query id in all fe nodes, if false then query for the specified query id in the currently connected fe nodes. The default is true.

Response

  1. {
  2. "msg": "success",
  3. "code": 0,
  4. "data": [
  5. {
  6. "fragment_id": "",
  7. "time": "",
  8. "instance_id": {
  9. "": {
  10. "host": "",
  11. "active_time": ""
  12. }
  13. }
  14. }
  15. ],
  16. "count": 0
  17. }

SinceVersion 1.2

Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:

  1. {
  2. "msg": "Bad Request",
  3. "code": 403,
  4. "data": "error messages",
  5. "count": 0
  6. }

### Examples

  1. GET /rest/v2/manager/query/profile/fragments/d7c93d9275334c35-9e6ac5f295a7134b
  2. Response:
  3. {
  4. "msg": "success",
  5. "code": 0,
  6. "data": [
  7. {
  8. "fragment_id": "0",
  9. "time": "36.169ms",
  10. "instance_id": {
  11. "d7c93d9275334c35-9e6ac5f295a7134e": {
  12. "host": "172.19.0.4:9060",
  13. "active_time": "36.169ms"
  14. }
  15. }
  16. },
  17. {
  18. "fragment_id": "1",
  19. "time": "20.710ms",
  20. "instance_id": {
  21. "d7c93d9275334c35-9e6ac5f295a7134c": {
  22. "host": "172.19.0.5:9060",
  23. "active_time": "20.710ms"
  24. }
  25. }
  26. },
  27. {
  28. "fragment_id": "2",
  29. "time": "7.83ms",
  30. "instance_id": {
  31. "d7c93d9275334c35-9e6ac5f295a7134d": {
  32. "host": "172.19.0.6:9060",
  33. "active_time": "7.83ms"
  34. },
  35. "d7c93d9275334c35-9e6ac5f295a7134f": {
  36. "host": "172.19.0.7:9060",
  37. "active_time": "10.873ms"
  38. }
  39. }
  40. }
  41. ],
  42. "count": 0
  43. }

Get the specified query id tree profile information

GET /rest/v2/manager/query/profile/graph/{query_id}

Description

Get the tree profile information of the specified query id, same as show query profile command.

Path parameters

  • query_id

    The query id.

Query parameters

  • fragment_id and instance_id

    Optional, both parameters must be specified or not.
    If both are not specified, a simple tree of profiles is returned, equivalent to show query profile '/query_id';
    If both are specified, a detailed profile tree is returned, which is equivalent to show query profile '/query_id/fragment_id/instance_id'.

  • is_all_node

    Optional, if true then query information about the specified query id in all fe nodes, if false then query information about the specified query id in the currently connected fe nodes. The default is true.

Response

  1. {
  2. "msg": "success",
  3. "code": 0,
  4. "data": {
  5. "graph":""
  6. },
  7. "count": 0
  8. }

SinceVersion 1.2

Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:

  1. {
  2. "msg": "Bad Request",
  3. "code": 403,
  4. "data": "error messages",
  5. "count": 0
  6. }

Current running queries

GET /rest/v2/manager/query/current_queries

Description

Same as show proc "/current_query_stmts", return current running queries.

Path parameters

Query parameters

  • is_all_node

    Optional. Return current running queries from all FE if set to true. Default is true.

Response

  1. {
  2. "msg": "success",
  3. "code": 0,
  4. "data": {
  5. "columnNames": ["Frontend", "QueryId", "ConnectionId", "Database", "User", "ExecTime", "SqlHash", "Statement"],
  6. "rows": [
  7. ["172.19.0.3", "108e47ab438a4560-ab1651d16c036491", "2", "", "root", "6074", "1a35f62f4b14b9d7961b057b77c3102f", "select sleep(60)"],
  8. ["172.19.0.11", "3606cad4e34b49c6-867bf6862cacc645", "3", "", "root", "9306", "1a35f62f4b14b9d7961b057b77c3102f", "select sleep(60)"]
  9. ]
  10. },
  11. "count": 0
  12. }

Cancel query

POST /rest/v2/manager/query/kill/{query_id}

Description

Cancel query of specified connection.

Path parameters

  • {query_id}

    query id. You can get query id by trance_id api.

Query parameters

Response

  1. {
  2. "msg": "success",
  3. "code": 0,
  4. "data": null,
  5. "count": 0
  6. }