O StarRocks armazena todos os logs de auditoria no arquivo local fe/log/fe.audit.log. Esses logs não estão acessíveis pelo banco de dados interno do sistema. O recurso de log de auditoria vem ativado por padrão e o plugin AuditLoader já está instalado. Esse plugin lê os logs do arquivo local e os importa para um banco de dados StarRocks por meio do método HTTP PUT. Assim, é possível visualizar e analisar todas as operações executadas no seu banco de dados.
Observações
O recurso de log de auditoria é ativado por padrão e cria automaticamente o banco de dados _starrocks_audit_db_ e a tabela starrocks_audit_tbl. Todos os logs de auditoria subsequentes são armazenados nessa tabela. Não exclua o banco de dados _starrocks_audit_db_ nem a tabela starrocks_audit_tbl, pois isso causará falha no recurso de consulta de tarefas SQL no Manager.
Os logs de auditoria utilizam particionamento dinâmico e retêm os dados de auditoria por 30 dias, por padrão. Para ajustar o período de retenção de dados, modifique os parâmetros
dynamic_partition.startedynamic_partition.end.Não é possível desativar o recurso de log de auditoria.
Recursos
Na página do EMR StarRocks Manager, clique em Metadata Management no painel de navegação à esquerda. Em default_catalog, localize o banco de dados _starrocks_audit_db_ criado automaticamente e sua tabela starrocks_audit_tbl.
Para visualizar a instrução CREATE TABLE da tabela starrocks_audit_tbl, execute SHOW CREATE TABLE starrocks_audit_tbl;:
CREATE TABLE `starrocks_audit_tbl` (
`queryId` varchar(64) NOT NULL COMMENT "Unique ID for the query",
`timestamp` datetime NOT NULL COMMENT "Start time of the query",
`queryTime` bigint(20) NOT NULL COMMENT "Query execution time (milliseconds)",
`queryType` varchar(12) NULL COMMENT "Query type (query, slow_query, connection)",
`clientIp` varchar(32) NULL COMMENT "IP address of the client",
`user` varchar(64) NULL COMMENT "Username for the query",
`authorizedUser` varchar(64) NULL COMMENT "Unique user identifier, that is, user_identity",
`resourceGroup` varchar(64) NULL COMMENT "Name of the resource group",
`catalog` varchar(32) NULL COMMENT "Name of the data catalog",
`db` varchar(96) NULL COMMENT "Database where the query was run",
`state` varchar(8) NULL COMMENT "Query status (EOF, ERR, OK)",
`errorCode` varchar(512) NULL COMMENT "Error code",
`scanBytes` bigint(20) NULL COMMENT "Bytes scanned by the query",
`scanRows` bigint(20) NULL COMMENT "Rows scanned by the query",
`returnRows` bigint(20) NULL COMMENT "Rows returned by the query",
`cpuCostNs` bigint(20) NULL COMMENT "CPU time consumed by the query (nanoseconds)",
`memCostBytes` bigint(20) NULL COMMENT "Memory consumed by the query (bytes)",
`stmtId` int(11) NULL COMMENT "Incremental ID for the SQL statement",
`isQuery` tinyint(4) NULL COMMENT "Whether the SQL statement is a query (1 or 0)",
`feIp` varchar(128) NULL COMMENT "IP address of the frontend (FE) that executed the statement",
`stmt` varchar(1048576) NULL COMMENT "Original SQL statement",
`digest` varchar(32) NULL COMMENT "Fingerprint of the slow SQL statement",
`planCpuCosts` double NULL COMMENT "CPU time consumed during the query planning phase (nanoseconds)",
`planMemCosts` double NULL COMMENT "Memory consumed during the query planning phase (bytes)",
`warehouse` varchar(96) NULL COMMENT "Compute group that the query uses",
`stmtType` varchar(8) NULL COMMENT "SQL type (DQL, DML, DDL, DCL, OTHER)",
`isFilter` tinyint(4) NULL COMMENT "Whether the SQL statement was filtered (1 or 0)",
`errorMsg` varchar(1048576) NULL COMMENT "Error details",
`pendingTimeMs` bigint(20) NULL COMMENT "Time the query spent waiting in the queue (milliseconds)",
`candidateMVs` varchar(65533) NULL COMMENT "A list of candidate materialized views considered for the query.",
`hitMvs` varchar(65533) NULL COMMENT "A list of materialized views that the query successfully used (hit)."
) ENGINE=OLAP
DUPLICATE KEY(`queryId`, `timestamp`, `queryTime`)
COMMENT "Audit log table"
PARTITION BY RANGE(`timestamp`)
(PARTITION p20250909 VALUES [("0000-01-01 00:00:00"), ("2025-09-10 00:00:00")),
PARTITION p20250910 VALUES [("2025-09-10 00:00:00"), ("2025-09-11 00:00:00")),
PARTITION p20250911 VALUES [("2025-09-11 00:00:00"), ("2025-09-12 00:00:00")),
PARTITION p20250912 VALUES [("2025-09-12 00:00:00"), ("2025-09-13 00:00:00")),
PARTITION p20250913 VALUES [("2025-09-13 00:00:00"), ("2025-09-14 00:00:00")))
DISTRIBUTED BY HASH(`queryId`) BUCKETS 3
PROPERTIES (
"compression" = "LZ4",
"datacache.enable" = "true",
"dynamic_partition.buckets" = "3",
"dynamic_partition.enable" = "true",
"dynamic_partition.end" = "3",
"dynamic_partition.history_partition_num" = "0",
"dynamic_partition.prefix" = "p",
"dynamic_partition.start" = "-30",
"dynamic_partition.time_unit" = "DAY",
"dynamic_partition.time_zone" = "Asia/Shanghai",
"enable_async_write_back" = "false",
"replication_num" = "1",
"storage_volume" = "builtin_storage_volume"
);