From 64f0607a8817b7239a2d89fa94cbff07b4b43043 Mon Sep 17 00:00:00 2001 From: morningman Date: Sun, 8 Sep 2024 15:43:03 +0800 Subject: [PATCH] audit --- .../java/org/apache/doris/catalog/InternalSchema.java | 10 ++++++++++ .../apache/doris/plugin/audit/AuditLoaderPlugin.java | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchema.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchema.java index 15bf65c3c737282..25a7d3541f99bd2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchema.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/InternalSchema.java @@ -137,6 +137,14 @@ public class InternalSchema { AUDIT_SCHEMA .add(new ColumnDef("scan_bytes", TypeDef.create(PrimitiveType.BIGINT), ColumnNullableType.NULLABLE)); AUDIT_SCHEMA.add(new ColumnDef("scan_rows", TypeDef.create(PrimitiveType.BIGINT), ColumnNullableType.NULLABLE)); + AUDIT_SCHEMA.add(new ColumnDef("local_scan_bytes", + TypeDef.create(PrimitiveType.BIGINT), ColumnNullableType.NULLABLE)); + AUDIT_SCHEMA.add(new ColumnDef("remote_scan_bytes", + TypeDef.create(PrimitiveType.BIGINT), ColumnNullableType.NULLABLE)); + AUDIT_SCHEMA.add(new ColumnDef("shuffle_bytes", + TypeDef.create(PrimitiveType.BIGINT), ColumnNullableType.NULLABLE)); + AUDIT_SCHEMA.add(new ColumnDef("shuffle_rows", + TypeDef.create(PrimitiveType.BIGINT), ColumnNullableType.NULLABLE)); AUDIT_SCHEMA .add(new ColumnDef("return_rows", TypeDef.create(PrimitiveType.BIGINT), ColumnNullableType.NULLABLE)); AUDIT_SCHEMA.add(new ColumnDef("stmt_id", TypeDef.create(PrimitiveType.BIGINT), ColumnNullableType.NULLABLE)); @@ -151,6 +159,8 @@ public class InternalSchema { new ColumnDef("peak_memory_bytes", TypeDef.create(PrimitiveType.BIGINT), ColumnNullableType.NULLABLE)); AUDIT_SCHEMA.add( new ColumnDef("workload_group", TypeDef.create(PrimitiveType.STRING), ColumnNullableType.NULLABLE)); + AUDIT_SCHEMA.add( + new ColumnDef("cloud_cluster_name", TypeDef.create(PrimitiveType.STRING), ColumnNullableType.NULLABLE)); AUDIT_SCHEMA.add(new ColumnDef("stmt", TypeDef.create(PrimitiveType.STRING), ColumnNullableType.NULLABLE)); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java b/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java index 4503b5b88027902..fbec3acafa57176 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java +++ b/fe/fe-core/src/main/java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java @@ -142,6 +142,7 @@ private void assembleAudit(AuditEvent event) { } private void fillLogBuffer(AuditEvent event, StringBuilder logBuffer) { + // The order should be exactly the same as the table structure of InternalSchema.AUDIT_SCHEMA logBuffer.append(event.queryId).append("\t"); logBuffer.append(TimeUtils.longToTimeStringWithms(event.timestamp)).append("\t"); logBuffer.append(event.clientIp).append("\t"); @@ -154,6 +155,10 @@ private void fillLogBuffer(AuditEvent event, StringBuilder logBuffer) { logBuffer.append(event.queryTime).append("\t"); logBuffer.append(event.scanBytes).append("\t"); logBuffer.append(event.scanRows).append("\t"); + logBuffer.append(event.scanBytesFromLocalStorage).append("\t"); + logBuffer.append(event.scanBytesFromLocalStorage).append("\t"); + logBuffer.append(event.shuffleSendBytes).append("\t"); + logBuffer.append(event.shuffleSendRows).append("\t"); logBuffer.append(event.returnRows).append("\t"); logBuffer.append(event.stmtId).append("\t"); logBuffer.append(event.stmtType).append("\t"); @@ -164,6 +169,7 @@ private void fillLogBuffer(AuditEvent event, StringBuilder logBuffer) { logBuffer.append(event.sqlDigest).append("\t"); logBuffer.append(event.peakMemoryBytes).append("\t"); logBuffer.append(event.workloadGroup).append("\t"); + logBuffer.append(event.cloudClusterName).append("\t"); // already trim the query in org.apache.doris.qe.AuditLogHelper#logAuditLog String stmt = event.stmt; if (LOG.isDebugEnabled()) {