@@ -5,10 +5,10 @@ Audit module
55
66**Example on GitHub **: `audit_log <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/config/instances.enabled/audit_log >`_
77
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.
109Each :ref: `event <audit-log-events-types >` is an action related to authorization and authentication, data manipulation,
1110administrator activity, or system events.
11+
1212The module provides detailed reports of these activities and helps you find and
1313fix breaches to protect your business. For example, you can see who created a new user
1414and when.
@@ -19,8 +19,8 @@ audit different events for different reasons. Tarantool provides such an option
1919
2020.. _audit-log-configure :
2121
22- Configuring audit log
23- ---------------------
22+ Configure audit log
23+ -------------------
2424
2525The section describes how to enable and configure audit logging and write logs to a selected destination -- a file, a pipe,
2626or a system logger.
@@ -33,20 +33,17 @@ Enable audit logging
3333~~~~~~~~~~~~~~~~~~~~
3434
3535To 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.
3737Possible log locations:
3838
3939* a :ref: `file <configuration_reference_audit_file >`
4040* a :ref: `pipe <configuration_reference_audit_pipe >`
4141* a :ref: `system logger <configuration_reference_audit_syslog-server >`
4242
43- To disable audit logging, set the ``audit_log `` option to ``devnull ``.
44-
4543In the configuration below, the :ref: `audit_log.to <configuration_reference_audit_to >` option is set to ``file ``.
4644It 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.
5047
5148.. literalinclude :: /code_snippets/snippets/config/instances.enabled/audit_log/config.yaml
5249 :language: yaml
@@ -56,6 +53,8 @@ If the option is omitted, the default path is used: ``var/log/instance001/audit.
5653
5754If you log to a file, Tarantool reopens the audit log at `SIGHUP <https://en.wikipedia.org/wiki/SIGHUP >`_.
5855
56+ To disable audit logging, set the ``audit_log.to `` option to ``devnull ``.
57+
5958.. _audit-log-filters :
6059
6160Filter the events
@@ -84,7 +83,7 @@ Possible filtering options:
8483 filter : [ auth,priv ]
8584
8685 - 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:
8887
8988 * user creation
9089 * space creation, altering, and dropping
@@ -105,22 +104,22 @@ Set the format of audit log events
105104Use the :ref: `audit_log.format <configuration_reference_audit_format >` option to choose the format of audit log events
106105-- plain text, CSV, or JSON.
107106
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-
112107.. literalinclude :: /code_snippets/snippets/config/instances.enabled/audit_log/config.yaml
113108 :language: yaml
114109 :start-at: format:
115110 :end-at: json
116111 :dedent:
117112
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+
118117.. _audit-log-spaces :
119118
120119Specify the spaces to be logged
121120~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122121
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
124123a list of space names for which data operation events should be logged.
125124
126125In 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:
136135Specify the logging mode in DML events
137136~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138137
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.
142140
143141.. literalinclude :: /code_snippets/snippets/config/instances.enabled/audit_log/config.yaml
144142 :language: yaml
145143 :start-at: extract_key:
146144 :end-at: true
147145 :dedent:
148146
149- .. _audit-log-run-read :
147+ .. _audit-log-run-example :
150148
151- Reading audit logs
152- ------------------
149+ Examples of audit log entries
150+ -----------------------------
153151
154152In 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:
156155
157156.. literalinclude :: /code_snippets/snippets/config/instances.enabled/audit_log/myapp.lua
158157 :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({
161160 :dedent:
162161
163162The audit log entry for the ``space_create `` event might look as follows:
@@ -185,7 +184,7 @@ Then insert one tuple to space:
185184 :end-before: box.space.bands:insert { 2
186185 :dedent:
187186
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:
189188
190189.. code-block :: json
191190
@@ -219,21 +218,6 @@ If the ``extract_key`` option is set to ``false``, the audit system prints the f
219218 "description" : " Insert tuple [1, \" Roxette\" , 1986] into space bands"
220219 }
221220
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-
237221 .. _audit-log-events :
238222
239223Audit log events
@@ -258,7 +242,7 @@ decide whether you need to take actions:
258242* System events -- events related to modification or configuration of resources.
259243 For example, such logs record the replacement of a space.
260244
261- * :ref: `Custom events <audit-log-custom >`-- any events added manually using
245+ * :ref: `Custom events <audit-log-custom >` -- any events added manually using
262246 the audit module API.
263247
264248The 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:
270254 :header-rows: 1
271255
272256 * - Event
273- - Type of event written to the audit log
257+ - Event type
274258 - Severity level
275- - Example of an event description
259+ - Example
276260 * - Audit log enabled for events
277261 - ``audit_enable ``
278262 - ``VERBOSE ``
279263 -
280- * - :ref: `User-defined events <audit-log-custom >`
264+ * - :ref: `Custom events <audit-log-custom >`
281265 - ``custom ``
282266 - ``INFO `` (default)
283267 -
@@ -420,7 +404,7 @@ Each event consists of the following fields:
420404
421405 * - Field
422406 - Description
423- - Example of a log field display
407+ - Example
424408 * - ``time ``
425409 - Time of the event
426410 - ``2024-01-15T16:33:12.368+0300 ``
@@ -440,7 +424,7 @@ Each event consists of the following fields:
440424 - ``console ``
441425 * - ``module ``
442426 - Audit log module. Set to ``tarantool `` for system events;
443- can be overwritten for user-defined events
427+ can be overwritten for custom events
444428 - ``tarantool ``
445429 * - ``user ``
446430 - User who triggered the event
@@ -466,8 +450,7 @@ Event groups
466450~~~~~~~~~~~~
467451
468452Built-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.
471454
472455Tarantool provides the following event groups:
473456
@@ -510,24 +493,24 @@ Tarantool provides the following event groups:
510493
511494.. _audit-log-custom :
512495
513- Creating custom events
514- ----------------------
496+ Custom events
497+ -------------
515498
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:
518501
519502.. literalinclude :: /code_snippets/snippets/config/instances.enabled/audit_log/config.yaml
520503 :language: yaml
521504 :start-at: filter:
522505 :end-at: custom ]
523506 :dedent:
524507
525- .. _audit-log-custom-new :
508+ .. _audit-log-custom-log :
526509
527- Add a new custom event
528- ~~~~~~~~~~~~~~~~~~~~~~
510+ Log a custom event
511+ ~~~~~~~~~~~~~~~~~~
529512
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:
531514
532515* Message string. Printed to the audit log with type ``message ``:
533516
@@ -584,7 +567,7 @@ If omitted, the ``session_type`` is set to the current session type, ``remote``
584567
585568 To avoid confusion with system events, the value of the type field must either be ``message `` (default)
586569 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.
588571
589572.. _audit-log-custom-severity :
590573
@@ -635,7 +618,7 @@ How many events can be recorded?
635618If you write to a file, the size of the Tarantool audit module is limited by the disk space.
636619If you write to a system logger, the size of the Tarantool audit module is limited by the system logger.
637620If 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.
639622However, it is not recommended to use the entire memory, as this may cause performance degradation
640623and even loss of some logs.
641624
0 commit comments