diff --git a/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoader.java b/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoader.java index fd86ff80415c6a6..8e1a7b57497a64c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoader.java +++ b/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoader.java @@ -159,6 +159,7 @@ private void fillLogBuffer(AuditEvent event, StringBuilder logBuffer) { logBuffer.append(event.stmtId).append("\t"); logBuffer.append(event.stmtType).append("\t"); logBuffer.append(event.isQuery ? 1 : 0).append("\t"); + logBuffer.append(event.isNereids ? 1 : 0).append("\t"); logBuffer.append(event.feIp).append("\t"); logBuffer.append(event.cpuTimeMs).append("\t"); logBuffer.append(event.sqlHash).append("\t"); @@ -244,3 +245,4 @@ public void run() { } } } + diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java index 0bbc37cd47b1321..af8374b4c277c35 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java @@ -186,6 +186,7 @@ private static void logAuditLogImpl(ConnectContext ctx, String origStmt, Stateme String cluster = Config.isCloudMode() ? cloudCluster : ""; AuditEventBuilder auditEventBuilder = ctx.getAuditEventBuilder(); + auditEventBuilder.reset(); auditEventBuilder .setTimestamp(ctx.getStartTime()) .setClientIp(ctx.getClientIP()) diff --git a/regression-test/suites/audit/test_audit_log_behavior.groovy b/regression-test/suites/audit/test_audit_log_behavior.groovy index 2829474560e1cfb..865bb534dab6024 100644 --- a/regression-test/suites/audit/test_audit_log_behavior.groovy +++ b/regression-test/suites/audit/test_audit_log_behavior.groovy @@ -19,7 +19,7 @@ suite("test_audit_log_behavior") { try { sql "set global enable_audit_plugin = true" sql "set global audit_plugin_max_sql_length = 58" - sql "set global audit_plugin_max_batch_interval_sec = 1" + // sql "set global audit_plugin_max_batch_interval_sec = 1" } catch (Exception e) { log.warn("skip this case, because " + e.getMessage()) assertTrue(e.getMessage().toUpperCase().contains("ADMIN")) @@ -71,6 +71,8 @@ suite("test_audit_log_behavior") { ] ] + qt_audit_log_schema """desc internal.__internal_schema.audit_log""" + for (def on : [true, false]) { sql "set enable_nereids_planner=${on}" sql "truncate table __internal_schema.audit_log" @@ -80,6 +82,10 @@ suite("test_audit_log_behavior") { sql tuple2[0] } + // make sure audit event is created. + // see WorkloadRuntimeStatusMgr.getQueryNeedAudit() + Thread.sleep(6000) + sql """call flush_audit_log()""" // check result for (int i = 0; i < cnt; i++) { def tuple2 = sqls.get(i)