This is an automated email from the ASF dual-hosted git repository.

gabriellee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new b49671b31e1 [feature](api) add profile text api (#28697)
b49671b31e1 is described below

commit b49671b31e155919805b8b7407000ce5e24287b0
Author: Mryange <[email protected]>
AuthorDate: Mon Dec 25 10:17:09 2023 +0800

    [feature](api) add profile text api (#28697)
---
 .../admin-manual/http-actions/fe/profile-action.md | 23 ++++++++++++++++++++++
 .../admin-manual/http-actions/fe/profile-action.md | 23 ++++++++++++++++++++++
 .../apache/doris/httpv2/rest/ProfileAction.java    | 18 +++++++++++++++++
 3 files changed, 64 insertions(+)

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 30f623a4bfd..4b3b8c444f2 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 f02380d125b..e12d94a0b98 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 e5679e32caa..4dcac417d57 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 @@ public class ProfileAction extends RestBaseController {
         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;
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to