Purpose
This function (expression) is used to create a filter.
Syntax
AUDIT_LOG_FILTER_SET_FILTER('filter_name', 'definition_of_filters');
Description
Parameters
filter_name: the name of the filter.Note
AUDIT_LOG_FILTER_SET_FILTERhasCREATE OR REPLACEsemantics. Executing this statement on an existing object will overwrite it.definition_of_filters: Defines the specific configuration of audit filters, expressed in JSON format. The filter design principles of the current version are compatible with MySQL, but only support filtering by audit event type. The following are examples of filter configurations:Logs all events.
{ "filter": { "log": true } }Not all events are recorded.
{ "filter": { "log": false } }Only logins and logouts are recorded.
{ "filter": { "log": true, "class": [ { "name": "connection" } ] } }Another way to write "Record all events."
{ "filter": { "log": true, "class": [ { "name": "connection" }, { "name": "general" }, { "name": "table_access" } ] } }
Audit events are classified as follows:
Event type |
Description |
|---|---|
| connection | Log in and log out. |
| table_access | DML statements. |
| general | Parser failed for cmd statement. |
Return value
The input expression must be a string constant, and the output is of the string type.
- When the DDL statement is executed successfully, the expression returns
OK. - When DDL execution fails, the
SELECTstatement is still executed successfully, and the expression outputs an error message.
Examples
Creates a filter
log_allthat records all events.SELECT AUDIT_LOG_FILTER_SET_FILTER('log_all', '{ "filter": { "log": true } }');The return result is as follows:
+-------------------------------------------------------------------------+ | AUDIT_LOG_FILTER_SET_FILTER('log_all', '{ "filter": { "log": true } }') | +-------------------------------------------------------------------------+ | OK | +-------------------------------------------------------------------------+ 1 row in setWhen the DDL fails, the
SELECTstatement is still executed successfully, and the expression outputs an error message.SELECT AUDIT_LOG_FILTER_SET_FILTER('log_err', '1');The return result is as follows:
+---------------------------------------------+ | AUDIT_LOG_FILTER_SET_FILTER('log_err', '1') | +---------------------------------------------+ | ERROR: JSON parsing error. | +---------------------------------------------+ 1 row in set