-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix](auditlog) add missing audit log fields and duplicate audit log …
…error (#42262) ### What problem does this PR solve? Problem Summary: #### Issue 1 There are some fields that is missing in audit log table. This PR add them all: - shuffle_send_rows - shuffle_send_bytes - scan_bytes_from_local_storage - scan_bytes_from_remote_storage - is_nereids - compute_group Notice that `compute_group` is previously name `cloudClusterName` in fe.audit.log, which is incorrect, so I change it to the right name. After this PR, all these fields will be saved in both audit log table and fe.audit.log #### Issue 2 The `AuditEventBuilder` need to be reset at each run, the there will be duplicate audit log. #### Issue 3 Add a new statement `call flush_audit_log()`. It will flush the audit log immediately to audit_log table. This is useful in test case, so that we don't need to wait 1min to flush the audit log data. ### Release note [fix](auditlog) add missing audit log fields and duplicate audit log error
- Loading branch information
1 parent
757b0ea
commit e02b1da
Showing
11 changed files
with
165 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...c/main/java/org/apache/doris/nereids/trees/plans/commands/call/CallFlushAuditLogFunc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.apache.doris.nereids.trees.plans.commands.call; | ||
|
||
import org.apache.doris.analysis.UserIdentity; | ||
import org.apache.doris.catalog.Env; | ||
import org.apache.doris.mysql.privilege.PrivPredicate; | ||
import org.apache.doris.nereids.exceptions.AnalysisException; | ||
import org.apache.doris.nereids.trees.expressions.Expression; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* call flush_audit_log() | ||
* This will flush audit log immediately to the audit_log table. | ||
* Mainly for test cases, so that we don't need to wait 60 sec to flush the audit log. | ||
*/ | ||
public class CallFlushAuditLogFunc extends CallFunc { | ||
|
||
private UserIdentity user; | ||
|
||
private CallFlushAuditLogFunc(UserIdentity user) { | ||
this.user = user; | ||
} | ||
|
||
public static CallFunc create(UserIdentity user, List<Expression> args) { | ||
if (!args.isEmpty()) { | ||
throw new AnalysisException("FLUSH_AUDIT_LOG function requires no parameter"); | ||
} | ||
return new CallFlushAuditLogFunc(user); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
// check priv | ||
if (!Env.getCurrentEnv().getAuth().checkGlobalPriv(user, PrivPredicate.ADMIN)) { | ||
throw new AnalysisException("Only admin can flush audit log"); | ||
} | ||
// flush audit log | ||
Env.getCurrentEnv().getPluginMgr().flushAuditLog(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !audit_log_schema -- | ||
query_id varchar(48) Yes true \N | ||
time datetime(3) Yes true \N | ||
client_ip varchar(128) Yes true \N | ||
user varchar(128) Yes false \N NONE | ||
catalog varchar(128) Yes false \N NONE | ||
db varchar(128) Yes false \N NONE | ||
state varchar(128) Yes false \N NONE | ||
error_code int Yes false \N NONE | ||
error_message text Yes false \N NONE | ||
query_time bigint Yes false \N NONE | ||
scan_bytes bigint Yes false \N NONE | ||
scan_rows bigint Yes false \N NONE | ||
return_rows bigint Yes false \N NONE | ||
shuffle_send_rows bigint Yes false \N NONE | ||
shuffle_send_bytes bigint Yes false \N NONE | ||
scan_bytes_from_local_storage bigint Yes false \N NONE | ||
scan_bytes_from_remote_storage bigint Yes false \N NONE | ||
stmt_id bigint Yes false \N NONE | ||
stmt_type varchar(48) Yes false \N NONE | ||
is_query tinyint Yes false \N NONE | ||
is_nereids tinyint Yes false \N NONE | ||
frontend_ip varchar(128) Yes false \N NONE | ||
cpu_time_ms bigint Yes false \N NONE | ||
sql_hash varchar(128) Yes false \N NONE | ||
sql_digest varchar(128) Yes false \N NONE | ||
peak_memory_bytes bigint Yes false \N NONE | ||
workload_group text Yes false \N NONE | ||
compute_group text Yes false \N NONE | ||
stmt text Yes false \N NONE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters