Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logformat journald to localfile reference #7202

Merged
merged 4 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 49 additions & 3 deletions source/user-manual/reference/ossec-conf/localfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ Options
- `multiline_regex`_
- `ignore`_
- `restrict`_
- `filter`_


location
^^^^^^^^

The location field specifies where the log data comes from. This can be a path to a log file, a Windows event channel, macos, or a journald system.
juliancnn marked this conversation as resolved.
Show resolved Hide resolved

Option to get the location of a log or a group of logs. ``strftime`` format strings may be used for log file names.
juliancnn marked this conversation as resolved.
Show resolved Hide resolved

For instance, a log file named ``file.log-2019-07-30`` can be referenced with ``file.log-%Y-%m-%d`` (assuming today is July 30th, 2019).
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -95,9 +98,8 @@ Below we have some Windows wildcard examples.

* On Windows systems, only character ``*`` is supported as a wildcard. For instance ``*ANY_STRING*``, will match all files that have ``ANY_STRING`` inside its name, another example is ``*.log`` this will match any log file.
* The maximum amount of files monitored at same time is limited to 1000.

.. warning::
* If using ``macos`` as ``log_format``, then ``location`` must be set to ``macos`` as well.
* When setting ``log_format`` to ``macos``, ``location`` should also be set to ``macos``.
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
* When setting ``log_format`` to ``journald``, ``location`` should also be set to ``journald``.
juliancnn marked this conversation as resolved.
Show resolved Hide resolved

.. _command:

Expand Down Expand Up @@ -335,6 +337,10 @@ Set the format of the log to be read. **field is required**
| | | Monitors all the logs that match the query filter. |
| | | See :ref:`How to collect macOS ULS logs <how-to-collect-macoslogs>`. |
+ +--------------------+--------------------------------------------------------------------------------------------------+
| | journald | Used to monitor all systemd-journal events, collecting them in syslog format. |
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
| | | |
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
| | | See `How to collect systemd-joyrnald logs <how-to-collect-journald>`. |
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
+ +--------------------+--------------------------------------------------------------------------------------------------+
| | audit | Used for events from Auditd. |
| | | |
| | | This format chains consecutive logs with the same ID into a single event. |
Expand Down Expand Up @@ -672,6 +678,46 @@ For example, to restrict syslog events related to a particular user name:
The `eventchannel` format already provides a way to filter logs through queries. Therefore, `ignore` and `restrict` settings don't apply to this format.


filter
^^^^^^

The `filter` tag is used to include PCRE2 regex filters for selectively collecting logs based on specific fields within `journald`.
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
Each filter must specify a field and a regex pattern. The `ignore_if_missing` attribute can be used to indicate whether to ignore logs where the specified field is missing.
juliancnn marked this conversation as resolved.
Show resolved Hide resolved


juliancnn marked this conversation as resolved.
Show resolved Hide resolved
+--------------------+---------------------------------------------------------------+
| **Default Value** | n/a |
+--------------------+---------------------------------------------------------------+
| **Allowed values** | Any `PCRE2 <regex.html#pcre2-syntax>`_ expression. |
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
+--------------------+---------------------------------------------------------------+

Use the `field` attribute to define in which journald field to apply the regex (Mandatory).
juliancnn marked this conversation as resolved.
Show resolved Hide resolved

+-----------------------+--------------------------------------------------------------------------------------------------------------+
| **ignore_if_missing** | When the attribute `ignore_if_missing` is set to `yes` it ignores the filter if the field does not exist. |
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
+ +------------------+-------------------------------------------------------------------------------------------+
| | Default value | no |
| +------------------+-------------------------------------------------------------------------------------------+
| | Allowed values | no, yes |
+-----------------------+------------------+-------------------------------------------------------------------------------------------+

juliancnn marked this conversation as resolved.
Show resolved Hide resolved

Configuration example:
juliancnn marked this conversation as resolved.
Show resolved Hide resolved

.. code-block:: xml

<!-- For monitoring log files -->
<localfile>
<location>journald</location>
<log_format>journald</log_format>
<filter field="_SYSTEMD_UNIT">^cron.service$</filter>
<filter field="PRIORITY" ignore_if_missing="yes">[0-3]</filter>
<localfile>

.. note::
Filters within the same `<localfile>` block follow an AND logic, while multiple blocks are evaluated in OR logic regarding log collection.
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
juliancnn marked this conversation as resolved.
Show resolved Hide resolved


Configuration examples
juliancnn marked this conversation as resolved.
Show resolved Hide resolved
----------------------

Expand Down
Loading