@@ -5,10 +5,10 @@ Audit module
5
5
6
6
**Example on GitHub **: `audit_log <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/audit_log >`_
7
7
8
- The audit module available in Tarantool Enterprise Edition writes messages that record Tarantool events in plain text,
9
- CSV, or JSON format.
8
+ The audit module available in Tarantool Enterprise Edition allows you to record various events occurred in Tarantool.
10
9
Each :ref: `event <audit-log-events-types >` is an action related to authorization and authentication, data manipulation,
11
10
administrator activity, or system events.
11
+
12
12
The module provides detailed reports of these activities and helps you find and
13
13
fix breaches to protect your business. For example, you can see who created a new user
14
14
and when.
@@ -19,8 +19,8 @@ audit different events for different reasons. Tarantool provides such an option
19
19
20
20
.. _audit-log-configure :
21
21
22
- Configuring audit log
23
- ---------------------
22
+ Configure audit log
23
+ -------------------
24
24
25
25
The section describes how to enable and configure audit logging and write logs to a selected destination -- a file, a pipe,
26
26
or a system logger.
@@ -33,20 +33,17 @@ Enable audit logging
33
33
~~~~~~~~~~~~~~~~~~~~
34
34
35
35
To enable audit logging, define the log location using the
36
- :ref: `audit_log.to <configuration_reference_audit_to >` option in the `` audit_log `` section of the configuration file.
36
+ :ref: `audit_log.to <configuration_reference_audit_to >` option in the configuration file.
37
37
Possible log locations:
38
38
39
39
* a :ref: `file <configuration_reference_audit_file >`
40
40
* a :ref: `pipe <configuration_reference_audit_pipe >`
41
41
* a :ref: `system logger <configuration_reference_audit_syslog-server >`
42
42
43
- To disable audit logging, set the ``audit_log `` option to ``devnull ``.
44
-
45
43
In the configuration below, the :ref: `audit_log.to <configuration_reference_audit_to >` option is set to ``file ``.
46
44
It means that the logs are written to a file.
47
- In this case, you should also define a file path (for example, ``audit_tarantool.log ``) using
48
- the :ref: `audit_log.file <configuration_reference_audit_file >` option.
49
- If the option is omitted, the default path is used: ``var/log/instance001/audit.log ``.
45
+ By default, audit logs are saved in the ``var/log/{{ instance_name }}/audit.log `` file.
46
+ To specify the path to an audit log file explicitly, use the :ref: `audit_log.file <configuration_reference_audit_file >` option.
50
47
51
48
.. literalinclude :: /code_snippets/snippets/config/instances.enabled/audit_log/config.yaml
52
49
:language: yaml
@@ -56,6 +53,8 @@ If the option is omitted, the default path is used: ``var/log/instance001/audit.
56
53
57
54
If you log to a file, Tarantool reopens the audit log at `SIGHUP <https://en.wikipedia.org/wiki/SIGHUP >`_.
58
55
56
+ To disable audit logging, set the ``audit_log.to `` option to ``devnull ``.
57
+
59
58
.. _audit-log-filters :
60
59
61
60
Filter the events
@@ -84,7 +83,7 @@ Possible filtering options:
84
83
filter : [ auth,priv ]
85
84
86
85
- Filter by group and event. You can specify a group and a certain event depending on the purpose.
87
- In the configuration below, ``user_create ``, ``data_operations ``, ``ddl ``, and ``custom `` are selected to see the events related to
86
+ In the configuration below, ``user_create ``, ``data_operations ``, ``ddl ``, and ``custom `` are selected to see the events related to:
88
87
89
88
* user creation
90
89
* space creation, altering, and dropping
@@ -105,22 +104,22 @@ Set the format of audit log events
105
104
Use the :ref: `audit_log.format <configuration_reference_audit_format >` option to choose the format of audit log events
106
105
-- plain text, CSV, or JSON.
107
106
108
- JSON is used by default. It is more convenient to receive log events, analyze them, and integrate them with other systems if needed.
109
- The plain format can be efficiently compressed.
110
- The CSV format allows you to view audit log events in tabular form.
111
-
112
107
.. literalinclude :: /code_snippets/snippets/config/instances.enabled/audit_log/config.yaml
113
108
:language: yaml
114
109
:start-at: format:
115
110
:end-at: json
116
111
:dedent:
117
112
113
+ JSON is used by default. It is more convenient to receive log events, analyze them, and integrate them with other systems if needed.
114
+ The plain format can be efficiently compressed.
115
+ The CSV format allows you to view audit log events in tabular form.
116
+
118
117
.. _audit-log-spaces :
119
118
120
119
Specify the spaces to be logged
121
120
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122
121
123
- Since :doc: ` 3.0.0 < /release/3.0.0 >`, : ref: `audit_log.spaces <configuration_reference_audit_spaces >` is used to specify
122
+ The : ref: `audit_log.spaces <configuration_reference_audit_spaces >` option is used to specify
124
123
a list of space names for which data operation events should be logged.
125
124
126
125
In the configuration below, only the events from the ``bands `` space are logged:
@@ -136,28 +135,28 @@ In the configuration below, only the events from the ``bands`` space are logged:
136
135
Specify the logging mode in DML events
137
136
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138
137
139
- Since :doc: `3.0.0 </release/3.0.0 >`, it is possible to
140
- force the audit subsystem to log the primary key instead of a full tuple in DML operations.
141
- To do so, set the :ref: `audit_log.extract_key <configuration_reference_audit_extract_key >` option to ``true ``.
138
+ If set to ``true ``, the :ref: `audit_log.extract_key <configuration_reference_audit_extract_key >` option
139
+ forces the audit subsystem to log the primary key instead of a full tuple in DML operations.
142
140
143
141
.. literalinclude :: /code_snippets/snippets/config/instances.enabled/audit_log/config.yaml
144
142
:language: yaml
145
143
:start-at: extract_key:
146
144
:end-at: true
147
145
:dedent:
148
146
149
- .. _audit-log-run-read :
147
+ .. _audit-log-run-example :
150
148
151
- Reading audit logs
152
- ------------------
149
+ Examples of audit log entries
150
+ -----------------------------
153
151
154
152
In the example, the logs are written to the ``audit_tarantool.log `` file.
155
- Let's create a space ``bands `` and check the logs in the file after the creation:
153
+
154
+ First, create a space ``bands `` and check the logs in the file after the creation:
156
155
157
156
.. literalinclude :: /code_snippets/snippets/config/instances.enabled/audit_log/myapp.lua
158
157
:language: lua
159
- :start-after: Create space
160
- :end-before: -- Insert data
158
+ :start-after: function create_space()
159
+ :end-before: box.space.bands:format({
161
160
:dedent:
162
161
163
162
The audit log entry for the ``space_create `` event might look as follows:
@@ -185,7 +184,7 @@ Then insert one tuple to space:
185
184
:end-before: box.space.bands:insert { 2
186
185
:dedent:
187
186
188
- As the ``extract_key `` option is set to ``true ``, the audit system prints the primary key instead of the full tuple:
187
+ If the ``extract_key `` option is set to ``true ``, the audit system prints the primary key instead of the full tuple:
189
188
190
189
.. code-block :: json
191
190
@@ -219,21 +218,6 @@ If the ``extract_key`` option is set to ``false``, the audit system prints the f
219
218
"description" : " Insert tuple [1, \" Roxette\" , 1986] into space bands"
220
219
}
221
220
222
- .. note ::
223
-
224
- To easily read the audit log events in the needed form, you can use these commands:
225
-
226
- * ``cat `` -- print one or more files
227
-
228
- * ``grep `` -- print a specific text
229
-
230
- * ``head `` -- print the first N lines of the file
231
-
232
- * ``tail `` -- print the last N lines of the file
233
-
234
- These are the basic commands to help you read the logs. If necessary, you can use other commands.
235
-
236
-
237
221
.. _audit-log-events :
238
222
239
223
Audit log events
@@ -258,7 +242,7 @@ decide whether you need to take actions:
258
242
* System events -- events related to modification or configuration of resources.
259
243
For example, such logs record the replacement of a space.
260
244
261
- * :ref: `Custom events <audit-log-custom >`-- any events added manually using
245
+ * :ref: `Custom events <audit-log-custom >` -- any events added manually using
262
246
the audit module API.
263
247
264
248
The full list of available audit log events is provided in the table below:
@@ -270,14 +254,14 @@ The full list of available audit log events is provided in the table below:
270
254
:header-rows: 1
271
255
272
256
* - Event
273
- - Type of event written to the audit log
257
+ - Event type
274
258
- Severity level
275
- - Example of an event description
259
+ - Example
276
260
* - Audit log enabled for events
277
261
- ``audit_enable ``
278
262
- ``VERBOSE ``
279
263
-
280
- * - :ref: `User-defined events <audit-log-custom >`
264
+ * - :ref: `Custom events <audit-log-custom >`
281
265
- ``custom ``
282
266
- ``INFO `` (default)
283
267
-
@@ -420,7 +404,7 @@ Each event consists of the following fields:
420
404
421
405
* - Field
422
406
- Description
423
- - Example of a log field display
407
+ - Example
424
408
* - ``time ``
425
409
- Time of the event
426
410
- ``2024-01-15T16:33:12.368+0300 ``
@@ -440,7 +424,7 @@ Each event consists of the following fields:
440
424
- ``console ``
441
425
* - ``module ``
442
426
- Audit log module. Set to ``tarantool `` for system events;
443
- can be overwritten for user-defined events
427
+ can be overwritten for custom events
444
428
- ``tarantool ``
445
429
* - ``user ``
446
430
- User who triggered the event
@@ -466,8 +450,7 @@ Event groups
466
450
~~~~~~~~~~~~
467
451
468
452
Built-in event groups are used to filter the event types that you want to audit.
469
- For example, you can set to record only authorization events,
470
- or only events related to a space.
453
+ For example, you can set to record only authorization events or only events related to a space.
471
454
472
455
Tarantool provides the following event groups:
473
456
@@ -510,24 +493,24 @@ Tarantool provides the following event groups:
510
493
511
494
.. _audit-log-custom :
512
495
513
- Creating custom events
514
- ----------------------
496
+ Custom events
497
+ -------------
515
498
516
- Tarantool provides an API for writing user-defined audit log events.
517
- To enable custom events, specify the ``custom `` value in the :ref: `audit_log.filter <configuration_reference_audit_filter >` option:
499
+ Tarantool provides an API for writing custom audit log events.
500
+ To enable these events, specify the ``custom `` value in the :ref: `audit_log.filter <configuration_reference_audit_filter >` option:
518
501
519
502
.. literalinclude :: /code_snippets/snippets/config/instances.enabled/audit_log/config.yaml
520
503
:language: yaml
521
504
:start-at: filter:
522
505
:end-at: custom ]
523
506
:dedent:
524
507
525
- .. _audit-log-custom-new :
508
+ .. _audit-log-custom-log :
526
509
527
- Add a new custom event
528
- ~~~~~~~~~~~~~~~~~~~~~~
510
+ Log a custom event
511
+ ~~~~~~~~~~~~~~~~~~
529
512
530
- To add a new event, use the ``audit.log() `` function that takes one of the following values:
513
+ To log an event, use the ``audit.log() `` function that takes one of the following values:
531
514
532
515
* Message string. Printed to the audit log with type ``message ``:
533
516
@@ -584,7 +567,7 @@ If omitted, the ``session_type`` is set to the current session type, ``remote``
584
567
585
568
To avoid confusion with system events, the value of the type field must either be ``message `` (default)
586
569
or begin with the ``custom_ `` prefix. Otherwise, you receive the error message.
587
- User-defined events are filtered out by default.
570
+ Custom events are filtered out by default.
588
571
589
572
.. _audit-log-custom-severity :
590
573
@@ -635,7 +618,7 @@ How many events can be recorded?
635
618
If you write to a file, the size of the Tarantool audit module is limited by the disk space.
636
619
If you write to a system logger, the size of the Tarantool audit module is limited by the system logger.
637
620
If you write to a pipe, the size of the Tarantool audit module is limited by the system buffer.
638
- If the ``audit_nonblock = false ``, if ``audit_nonblock `` = ``true ``, there is no limit.
621
+ If the ``audit_log.nonblock = false ``, if ``audit_log.nonblock `` = ``true ``, there is no limit.
639
622
However, it is not recommended to use the entire memory, as this may cause performance degradation
640
623
and even loss of some logs.
641
624
0 commit comments