Filtering by database for audit plugin
Description
~~~~~~~~~~~
Add two global variables:
- `audit_
include in audit logging
- `audit_
exclude from audit logging
The value can be NULL or comma separated list of database names.
Only one variable can be not NULL at a time. If one is set to be not
NULL, the attempt to set another one will fail. Empty string means
empty list.
Change of `audit_
`audit_
If query accessing any of databases listed in
`audit_
If query accessing only databases listed in
`audit_
Caveats:
Audit plugin doesn't receive table access notification for queries
`CREATE TABLE ...'. Such queries will always be logged.
Example:
mysql> set global audit_log_
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL audit_log_
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL audit_log_
ERROR 1231 (42000): Variable 'audit_
mysql> set global audit_log_
Query OK, 0 rows affected (0.00 sec)
mysql> SET GLOBAL audit_log_
Query OK, 0 rows affected (0.00 sec)
Implementation
~~~~~~~~~~~~~~
*5.7 ONLY*
5.7 audit API added new type of events called
`MYSQL_
to access any table. `struct mysql_event_
`table_database' (the name of the database being accessed).
Changes:
1. Implement `audit_
`audit_
included / excluded checks.
2. Add two global plugin variables, check and update functions.
3. When handling `MYSQL_
number of accessed databases, the number of included ones and the
number of excluded ones.
4. Log query if at least one database has been included.
5. Log query if number of excluded databases is less than a number of
accessed databases.
Testing
~~~~~~~
Test case will be similar to `audit_
Blueprint information
- Status:
- Complete
- Approver:
- Laurynas Biveinis
- Priority:
- High
- Drafter:
- Sergei Glushchenko
- Direction:
- Approved
- Assignee:
- Sergei Glushchenko
- Definition:
- Approved
- Series goal:
- Accepted for 5.7
- Implementation:
-
Implemented
- Milestone target:
-
5.7.14-7
- Started by
- Sergei Glushchenko
- Completed by
- Sergei Glushchenko
Related branches
Related bugs
Bug #1581195: Allow to log only queries for specific DBs in audit log plugin | Fix Released |
Sprints
Work Items
Dependency tree

* Blueprints in grey have been implemented.