Skip to content

Commit

Permalink
audit
Browse files Browse the repository at this point in the history
  • Loading branch information
morningman committed Sep 8, 2024
1 parent fe915a9 commit 64f0607
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand All @@ -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()) {
Expand Down

0 comments on commit 64f0607

Please sign in to comment.