Skip to content

Commit 28e1f8f

Browse files
authored
Merge pull request #584 from percona/ps-10226-8.4
PS-10226 - [DOCS] Audit log changes in documentation 8.4
2 parents 8af9355 + 78d07df commit 28e1f8f

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

docs/audit-log-filter-new.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The filter writes the audit log filter file in XML. The XML file uses
44
UTF-8.
55

66
The <AUDIT> is the root element and this element contains
7-
<AUDIT_RECORD> elements. Each <AUDIT_RECORD> element contains specific
7+
&lt;AUDIT_RECORD&gt; elements. Each &lt;AUDIT_RECORD&gt; element contains specific
88
information about an event that is audited.
99

1010
For each new file, the Audit Log Filter component writes the XML
@@ -76,7 +76,7 @@ closing element is not available.
7676
</AUDIT>
7777
```
7878

79-
The order of the attributes within an <AUDIT_RECORD> can vary. Certain attributes are in every element. Other attributes are optional and depend on the type of audit record.
79+
The order of the attributes within an &lt;AUDIT_RECORD&gt; can vary. Certain attributes are in every element. Other attributes are optional and depend on the type of audit record.
8080

8181
The attributes in every element are the following:
8282

docs/audit-log-filter-old.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Audit Log Filter format - XML (old style)
22

3-
The old style XML format uses `<AUDIT>` tag as the root element and adds the `</AUDIT>` tag when the file closes. Each audited event is contained in an <AUDIT_RECORD> element.
3+
The old style XML format uses `<AUDIT>` tag as the root element and adds the `</AUDIT>` tag when the file closes. Each audited event is contained in an &lt;AUDIT_RECORD&gt; element.
44

5-
The order of the attributes within an <AUDIT_RECORD> can vary. Certain attributes are in every element. Other attributes are optional and depend on the type of audit record.
5+
The order of the attributes within an &lt;AUDIT_RECORD&gt; can vary. Certain attributes are in every element. Other attributes are optional and depend on the type of audit record.
66

77
```xml
88
<?xml version="1.0" encoding="utf-8"?>

docs/write-filter-definitions.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -350,24 +350,31 @@ Performance impact is a critical consideration when implementing detailed loggin
350350

351351
## Implement the filter
352352

353-
Here's how to define and implement an audit log filter:
353+
Here's how to define and implement an audit log filter in Percona Server for MySQL 8.4.6:
354354

355-
### Add filter identifier
355+
### Create a filter
356356

357-
An audit log filter identifier is your filter's unique name within the `audit_log_filter` system. You create this name to label and track your specific filter setup. The `audit_log_filter_id` system variable stores this name, and you should choose descriptive identifiers like 'finance_audit' or 'security_tracking'.
357+
To create an audit log filter, use the `audit_log_filter_set_filter()` function. This function takes two parameters: the filter name and the filter definition as a JSON string.
358358

359-
After you name your filter with an identifier, you attach your rules. The identifier makes it easy to manage multiple filter setups and update them as needed. When you want to change your logging rules, you first reference your chosen identifier and then add your new filter settings.
359+
```sql
360+
SELECT audit_log_filter_set_filter('log_all', '{ "filter": { "log": true } }');
361+
```
362+
363+
### Assign filter to users
360364

361-
Remember that when you apply new filter settings to an existing identifier, the system replaces the old settings. It doesn't add the new rules to what's already there.
365+
To assign a filter to specific users, use the `audit_log_filter_set_user()` function. This function takes three parameters: username, userhost, and filtername.
362366

363367
```sql
364-
SET GLOBAL audit_log_filter_id = 'financial_tracking';
368+
SELECT audit_log_filter_set_user('%', '%', 'log_all');
365369
```
366370

367-
### Add filter definition
371+
### Example: Financial tracking filter
372+
373+
Here's a complete example of creating and assigning a comprehensive financial tracking filter:
368374

369375
```sql
370-
SET GLOBAL audit_log_filter = '{
376+
-- Create the filter
377+
SELECT audit_log_filter_set_filter('financial_tracking', '{
371378
"filter": {
372379
"class": [
373380
{
@@ -379,7 +386,7 @@ SET GLOBAL audit_log_filter = '{
379386
{"name":"insert"},
380387
{"name":"update"},
381388
{"name":"delete"],
382-
]
389+
],
383390
"status": [0, 1]
384391
},
385392
{
@@ -393,7 +400,10 @@ SET GLOBAL audit_log_filter = '{
393400
}
394401
]
395402
}
396-
}';
403+
}');
404+
405+
-- Assign the filter to all users
406+
SELECT audit_log_filter_set_user('%', '%', 'financial_tracking');
397407
```
398408

399409
The filter monitors two main types of activities. First, it watches all changes to your accounts and transactions tables. This monitoring means that the filter logs when someone adds new data, changes existing information, or removes records. You get a complete picture of who's touching your financial data and what they do with it.
@@ -413,9 +423,14 @@ The filter focuses only on activity in your `financial_db` database. This target
413423
Tracking all these elements gives you a comprehensive view of who's accessing your financial data, what changes they're making, and whether those changes are successful. This ability is beneficial for security monitoring and compliance requirements.
414424

415425

416-
To verify your filter:
426+
To verify your filter, you can check the audit tables:
427+
417428
```sql
418-
SHOW GLOBAL VARIABLES LIKE 'audit_log_filter';
429+
-- Check created filters
430+
SELECT * FROM mysql.audit_log_filter;
431+
432+
-- Check user assignments
433+
SELECT * FROM mysql.audit_log_user;
419434
```
420435

421436
You can examine your audit log file (the default location is the data directory) to check if events are being logged.

0 commit comments

Comments
 (0)