Skip to content

Commit 8906522

Browse files
committed
[Enhancement] add warehouse parameter to audit log table
Signed-off-by: Rohit Satardekar <[email protected]>
1 parent 9f14938 commit 8906522

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ CREATE TABLE starrocks_audit_db__.starrocks_audit_tbl__ (
5151
`planMemCosts` DOUBLE COMMENT "查询规划阶段内存占用(字节)",
5252
`pendingTimeMs` BIGINT COMMENT "查询在队列中等待的时间(毫秒)",
5353
`candidateMVs` varchar(65533) NULL COMMENT "候选MV列表",
54-
`hitMvs` varchar(65533) NULL COMMENT "命中MV列表"
54+
`hitMvs` varchar(65533) NULL COMMENT "命中MV列表",
55+
`warehouse` VARCHAR(128) NULL COMMENT "仓库名称"
5556
) ENGINE = OLAP
5657
DUPLICATE KEY (`queryId`, `timestamp`, `queryType`)
5758
COMMENT "审计日志表"

lib/starrocks-fe.jar

3.4 MB
Binary file not shown.

src/main/java/com/starrocks/plugin/audit/AuditLoaderPlugin.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ private void assembleAudit(AuditEvent event) {
196196
"\"planMemCosts\":" + event.planMemCosts + "," +
197197
"\"pendingTimeMs\":" + event.pendingTimeMs + "," +
198198
"\"candidateMVs\":\"" + candidateMvsVal + "\"," +
199-
"\"hitMvs\":\"" + hitMVsVal + "\"}";
199+
"\"hitMvs\":\"" + hitMVsVal + "\"," +
200+
"\"warehouse\":\"" + event.warehouse + "\"}";
200201
if (auditBuffer.length() > 0) {
201202
auditBuffer.append(",");
202203
}

src/main/java/com/starrocks/plugin/audit/StarrocksStreamLoader.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private HttpURLConnection getConnection(String urlStr, String label) throws IOEx
8181

8282
conn.addRequestProperty("label", label);
8383
conn.addRequestProperty("max_filter_ratio", "1.0");
84-
conn.addRequestProperty("columns", "queryId,timestamp,queryType,clientIp,user,authorizedUser,resourceGroup,catalog,db,state,errorCode,queryTime,scanBytes,scanRows,returnRows,cpuCostNs,memCostBytes,stmtId,isQuery,feIp,stmt,digest,planCpuCosts,planMemCosts,pendingTimeMs,candidateMVs,hitMvs");
84+
conn.addRequestProperty("columns", "queryId,timestamp,queryType,clientIp,user,authorizedUser,resourceGroup,catalog,db,state,errorCode,queryTime,scanBytes,scanRows,returnRows,cpuCostNs,memCostBytes,stmtId,isQuery,feIp,stmt,digest,planCpuCosts,planMemCosts,pendingTimeMs,candidateMVs,hitMvs,warehouse");
8585
if(!StringUtils.isBlank(this.streamLoadFilter)) {
8686
conn.addRequestProperty("where", streamLoadFilter);
8787
}
@@ -104,7 +104,7 @@ private String toCurl(HttpURLConnection conn) {
104104
sb.append("-H \"").append("where\":").append(streamLoadFilter).append(" \\\n ");
105105
}
106106
sb.append("-H \"").append("columns\":").append("\"queryId, timestamp, queryType, clientIp, user, authorizedUser, resourceGroup, catalog, db, state, errorCode," +
107-
"queryTime, scanBytes, scanRows, returnRows, cpuCostNs, memCostBytes, stmtId, isQuery, feIp, stmt, digest, planCpuCosts, planMemCosts, pendingTimeMs, candidateMVs, hitMvs\" \\\n ");
107+
"queryTime, scanBytes, scanRows, returnRows, cpuCostNs, memCostBytes, stmtId, isQuery, feIp, stmt, digest, planCpuCosts, planMemCosts, pendingTimeMs, candidateMVs, hitMvs, warehouse\" \\\n ");
108108
sb.append("\"").append(conn.getURL()).append("\"");
109109
return sb.toString();
110110
}

0 commit comments

Comments
 (0)