Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
morningman committed Oct 31, 2024
1 parent 88f6f3e commit b0811f1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -244,3 +245,4 @@ public void run() {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
8 changes: 7 additions & 1 deletion regression-test/suites/audit/test_audit_log_behavior.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit b0811f1

Please sign in to comment.