Full Audit Logs #
Background #
Full audit log means that once this function is enabled, the system will record all executed SQL statements, and include the database, user, access address, access time and other information corresponding to the statement. This is convenient for enterprises to conduct audit operations.
Parameters #
- general_query_log: The full audit log has only one parameter. When the value is true, the full log is enabled, and when the value is false, the function is disabled.
Requirements #
Similar to the “slow query log” function, the implementation of the full audit log is also based on the agent, so this function is only applicable to the scenario of ShardingSphere-Proxy and the agent is enabled.
Sample #
The full audit log is an Agent-based feature, so the following configuration is located in agent.yaml:
plugins:
Logging:
props:
# Whether to enable general query log.
general_query_log: false
# Whether to enable slow query log.
#slow_query_log: true
# Long query threshold, in milliseconds.
#long_query_time: 5000
Among them, general_query_log is configured as false, indicating that full logs are not enabled.
When you need to enable full logs, configure general_query_log to true and restart ShardingSphere-Proxy.
Full Audit Log Format #
The full audit log format is as follows:
db: {database} user: {user} host: {host} query_time: {query time}
{sql}
- db: Database name;
- user: Username used in the current connection;
- host: Client access address;
- query_time: SQL execution time, the unit is ms;
- sql: The SQL statement sent by the client.
For example:
[INFO ] 2022-07-01 00:00:00.000 [ShardingSphere-Command-0] GENERAL-QUERY - db: sharding_db user: root host: 127.0.0.1 query_time: 145
CREATE TABLE `t_order` (
`order_id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`status` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
PRIMARY KEY (`order_id`)
)