Skip to content

Commit b069f43

Browse files
Mryangestephen
authored and
stephen
committed
[feature](api) add profile text api (apache#28697)
1 parent ce29a41 commit b069f43

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

docs/en/docs/admin-manual/http-actions/fe/profile-action.md

+23
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ under the License.
2929
## Request
3030

3131
`GET /api/profile`
32+
`GET /api/profile/text`
3233

3334
## Description
3435

@@ -119,6 +120,7 @@ Query:
119120
- BlockConvertTime: 97.539us
120121
- BlockSeekCount: 0
121122
```
123+
If it is a text interface, simply return the plain text content of the profile.
122124

123125
## Path parameters
124126

@@ -164,3 +166,24 @@ None
164166
"count": 0
165167
}
166168
```
169+
2. Get the query profile text of the specified query id
170+
```
171+
GET /api/profile/text?query_id=f732084bc8e74f39-8313581c9c3c0b58
172+
173+
Response:
174+
Summary:
175+
- Profile ID: 48bdf6d75dbb46c9-998b9c0368f4561f
176+
- Task Type: QUERY
177+
- Start Time: 2023-12-20 11:09:41
178+
- End Time: 2023-12-20 11:09:45
179+
- Total: 3s680ms
180+
- Task State: EOF
181+
- User: root
182+
- Default Db: tpcds
183+
- Sql Statement: with customer_total_return as
184+
select sr_customer_sk as ctr_customer_sk
185+
,sr_store_sk as ctr_store_sk
186+
,sum(SR_FEE) as ctr_total_return
187+
...
188+
```
189+

docs/zh-CN/docs/admin-manual/http-actions/fe/profile-action.md

+23
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ under the License.
2929
## Request
3030

3131
`GET /api/profile`
32+
`GET /api/profile/text`
3233

3334
## Description
3435

@@ -119,6 +120,7 @@ Query:
119120
- BlockConvertTime: 97.539us
120121
- BlockSeekCount: 0
121122
```
123+
如果为text接口,直接返回profile的纯文本内容
122124

123125
## Path parameters
124126

@@ -164,3 +166,24 @@ Query:
164166
"count": 0
165167
}
166168
```
169+
2. 获取指定 query_id 的 query profile 的纯文本
170+
```
171+
GET /api/profile/text?query_id=f732084bc8e74f39-8313581c9c3c0b58
172+
173+
Response:
174+
Summary:
175+
- Profile ID: 48bdf6d75dbb46c9-998b9c0368f4561f
176+
- Task Type: QUERY
177+
- Start Time: 2023-12-20 11:09:41
178+
- End Time: 2023-12-20 11:09:45
179+
- Total: 3s680ms
180+
- Task State: EOF
181+
- User: root
182+
- Default Db: tpcds
183+
- Sql Statement: with customer_total_return as
184+
select sr_customer_sk as ctr_customer_sk
185+
,sr_store_sk as ctr_store_sk
186+
,sum(SR_FEE) as ctr_total_return
187+
...
188+
```
189+

fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/ProfileAction.java

+18
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,22 @@ protected Object profile(HttpServletRequest request, HttpServletResponse respons
6161
result.put("profile", queryProfileStr);
6262
return ResponseEntityBuilder.ok(result);
6363
}
64+
65+
@RequestMapping(path = "/api/profile/text", method = RequestMethod.GET)
66+
protected Object profileText(HttpServletRequest request, HttpServletResponse response) {
67+
executeCheckPassword(request, response);
68+
checkGlobalAuth(ConnectContext.get().getCurrentUserIdentity(), PrivPredicate.ADMIN);
69+
70+
String queryId = request.getParameter("query_id");
71+
if (Strings.isNullOrEmpty(queryId)) {
72+
return "Missing query_id";
73+
}
74+
75+
String queryProfileStr = ProfileManager.getInstance().getProfile(queryId);
76+
if (queryProfileStr == null) {
77+
return "query id " + queryId + " not found";
78+
}
79+
80+
return queryProfileStr;
81+
}
6482
}

0 commit comments

Comments
 (0)