diff --git a/docs/en/docs/admin-manual/http-actions/fe/profile-action.md b/docs/en/docs/admin-manual/http-actions/fe/profile-action.md index 30f623a4bfd3dee..4b3b8c444f25fd3 100644 --- a/docs/en/docs/admin-manual/http-actions/fe/profile-action.md +++ b/docs/en/docs/admin-manual/http-actions/fe/profile-action.md @@ -29,6 +29,7 @@ under the License. ## Request `GET /api/profile` +`GET /api/profile/text` ## Description @@ -119,6 +120,7 @@ Query: - BlockConvertTime: 97.539us - BlockSeekCount: 0 ``` +If it is a text interface, simply return the plain text content of the profile. ## Path parameters @@ -164,3 +166,24 @@ None "count": 0 } ``` +2. Get the query profile text of the specified query id + ``` + GET /api/profile/text?query_id=f732084bc8e74f39-8313581c9c3c0b58 + + Response: + Summary: + - Profile ID: 48bdf6d75dbb46c9-998b9c0368f4561f + - Task Type: QUERY + - Start Time: 2023-12-20 11:09:41 + - End Time: 2023-12-20 11:09:45 + - Total: 3s680ms + - Task State: EOF + - User: root + - Default Db: tpcds + - Sql Statement: with customer_total_return as + select sr_customer_sk as ctr_customer_sk + ,sr_store_sk as ctr_store_sk + ,sum(SR_FEE) as ctr_total_return + ... + ``` + diff --git a/docs/zh-CN/docs/admin-manual/http-actions/fe/profile-action.md b/docs/zh-CN/docs/admin-manual/http-actions/fe/profile-action.md index f02380d125b4870..e12d94a0b98dde8 100644 --- a/docs/zh-CN/docs/admin-manual/http-actions/fe/profile-action.md +++ b/docs/zh-CN/docs/admin-manual/http-actions/fe/profile-action.md @@ -29,6 +29,7 @@ under the License. ## Request `GET /api/profile` +`GET /api/profile/text` ## Description @@ -119,6 +120,7 @@ Query: - BlockConvertTime: 97.539us - BlockSeekCount: 0 ``` +如果为text接口,直接返回profile的纯文本内容 ## Path parameters @@ -164,3 +166,24 @@ Query: "count": 0 } ``` +2. 获取指定 query_id 的 query profile 的纯文本 + ``` + GET /api/profile/text?query_id=f732084bc8e74f39-8313581c9c3c0b58 + + Response: + Summary: + - Profile ID: 48bdf6d75dbb46c9-998b9c0368f4561f + - Task Type: QUERY + - Start Time: 2023-12-20 11:09:41 + - End Time: 2023-12-20 11:09:45 + - Total: 3s680ms + - Task State: EOF + - User: root + - Default Db: tpcds + - Sql Statement: with customer_total_return as + select sr_customer_sk as ctr_customer_sk + ,sr_store_sk as ctr_store_sk + ,sum(SR_FEE) as ctr_total_return + ... + ``` + diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java index e5679e32caa5bd5..4dcac417d572a32 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java @@ -61,4 +61,22 @@ protected Object profile(HttpServletRequest request, HttpServletResponse respons result.put("profile", queryProfileStr); return ResponseEntityBuilder.ok(result); } + + @RequestMapping(path = "/api/profile/text", method = RequestMethod.GET) + protected Object profileText(HttpServletRequest request, HttpServletResponse response) { + executeCheckPassword(request, response); + checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), PrivPredicate.ADMIN); + + String queryId = request.getParameter("query_id"); + if (Strings.isNullOrEmpty(queryId)) { + return "Missing query_id"; + } + + String queryProfileStr = ProfileManager.getInstance().getProfile(queryId); + if (queryProfileStr == null) { + return "query id " + queryId + " not found"; + } + + return queryProfileStr; + } }