-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use journald for system module on Debian 12 (#41061)
This commit adds Debian 12 support to our system module, to support Debian 12 we need to use the journald input to collect the system logs. To support it, a new, internal, input `system-logs`is introduced, it is responsible for deciding whether the log input or journald must be used. If `var.paths` is defined in the module configuration, `system-logs` looks at the files, if any of the globs resolves to one or more files the `log` input is used, otherwise the `jouranld` input is used. This behaviour can be overridden by setting `var.use_journald` or `var.use_files`, which will force the use of journald or files. Other changes: - Journald input now support filtering by facilities - System tests for modules now support handling journal files - The `TESTING_FILEBEAT_FILEPATTERN` environment variable now is a comma separated list of globs, it defaults to `.log,*.journal` - Multiple lint warnings are fixed - The documentation has been updated where needed. (cherry picked from commit cfd1f1c)
- Loading branch information
1 parent
c01af07
commit 8b991f4
Showing
51 changed files
with
1,762 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
*`var.use_journald`*:: | ||
|
||
A boolean that when set to `true` will read logs from Journald. When | ||
Journald is used all events contain the tag `journald` | ||
|
||
*`var.use_files`*:: | ||
|
||
A boolean that when set to `true` will read logs from the log files | ||
defined by `vars.paths`. | ||
|
||
If neither `var.use_journald` nor `var.use_files` are set (or both are | ||
`false`) {beatname_uc} will auto-detect the source for the logs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Journald input | ||
|
||
The Journald input reads journal entries by calling `journalctl`. | ||
|
||
## Adding entries to the journal | ||
The easiest way to add entries to the journal is to use `systemd-cat`: | ||
``` | ||
root@vagrant-debian-12:~/filebeat# echo "Hello Journal!" | systemd-cat | ||
root@vagrant-debian-12:~/filebeat# journalctl -n 1 | ||
Oct 02 04:17:01 vagrant-debian-12 CRON[1912]: pam_unix(cron:session): session closed for user root | ||
``` | ||
|
||
The syslog identifier can be specified with the `-t` parameter: | ||
``` | ||
root@vagrant-debian-12:~/filebeat# echo "Hello Journal!" | systemd-cat -t my-test | ||
root@vagrant-debian-12:~/filebeat# journalctl -n 1 | ||
Oct 02 04:17:50 vagrant-debian-12 my-test[1924]: Hello Journal! | ||
``` | ||
|
||
## Crafting a journal file | ||
The easiest way to craft a journal file with the entries you need is | ||
to use | ||
[`systemd-journald-remote`](https://www.freedesktop.org/software/systemd/man/latest/systemd-journal-remote.service.html). | ||
First we need to export some entries to a file: | ||
``` | ||
root@vagrant-debian-12:~/filebeat# journalctl -g "Hello" -o export >export | ||
``` | ||
One good thing of the `-o export` is that you can just concatenate the | ||
output of any number of runs and the result will be a valid file. | ||
|
||
Then you can use `systemd-journald-remote` to generate the journal | ||
file: | ||
``` | ||
root@vagrant-debian-12:~/filebeat# /usr/lib/systemd/systemd-journal-remote -o example.journal export | ||
Finishing after writing 2 entries | ||
`` | ||
Or you can run as a one liner: | ||
``` | ||
root@vagrant-debian-12:~/filebeat# journalctl -g "Hello" -o export | /usr/lib/systemd/systemd-journal-remote -o example.journal - | ||
``` | ||
Then you can read the newly created file: | ||
``` | ||
root@vagrant-debian-12:~/filebeat# journalctl --file ./example.journal | ||
Oct 02 04:16:54 vagrant-debian-12 unknown[1908]: Hello Journal! | ||
Oct 02 04:17:50 vagrant-debian-12 my-test[1924]: Hello Journal! | ||
root@vagrant-debian-12:~/filebeat# | ||
``` | ||
Bear in mind that `systemd-journal-remote` will **append** to the | ||
output file. | ||
## References | ||
- https://systemd.io/JOURNAL_NATIVE_PROTOCOL/ | ||
- https://www.freedesktop.org/software/systemd/man/latest/journalctl.html | ||
- https://www.freedesktop.org/software/systemd/man/latest/systemd-cat.html | ||
- https://www.freedesktop.org/software/systemd/man/latest/systemd-journal-remote.service.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.