[9.2](backport #49445) Fix journald input for journalctl versions < 242 by omitting --boot all#49526
Open
mergify[bot] wants to merge 2 commits into9.2from
Open
[9.2](backport #49445) Fix journald input for journalctl versions < 242 by omitting --boot all#49526mergify[bot] wants to merge 2 commits into9.2from
--boot all#49526mergify[bot] wants to merge 2 commits into9.2from
Conversation
…all` (#49445) journalctl versions < 242 do not support the `--boot all` flag that newer versions require to read all boot messages, this commit fixes this problem by omitting the flag because versins < 242 returns messages from all boots without the need to set `--boot all` The journal files used for tests are updated making them compatible with journalctl >= 239. The integration test TestJournaldInputReadsMessagesFromAllBoots is added to ensure the journald input can always read messages form all boots. This test is intended to be run manually on VMs where the journal has less than 50 000 messages. Some fixes to the life-cycle of `journalctl` are implemented because they were required for the tests to be stable. GenAI-Assisted: Yes Human-Reviewed: Yes Tool: Cursor-CLI, Model: GPT-5.3 Codex Extra High Fast Tool: Cursor-CLI, Model: Claude 4.6 Opus (Thinking) --------- Co-authored-by: Philipp Kahr <philipp.kahr@elastic.co> (cherry picked from commit f6662a9) # Conflicts: # filebeat/input/journald/pkg/journalctl/journalctl.go # filebeat/input/journald/pkg/journalctl/reader_test.go
Contributor
Author
|
Cherry-pick of f6662a9 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
Contributor
🤖 GitHub commentsJust comment with:
|
Contributor
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
7 tasks
Resolve failed backport conflicts for the journald `--boot all` compatibility fix while keeping the `9.2` API and behavior intact. Preserve support for journalctl < 242 and apply process lifecycle/test fixes without introducing `main`-only features. GenAI-Assisted: Yes Human-Reviewed: Yes Tool: Cursor-CLI, Model: GPT-5.3 Codex High
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed commit message
Note for reviewers
There are still some small issues with the process management in
filebeat/input/journald/pkg/journalctl/journalctl.go, I'll fix them in a follow up PR (based on this PR and linked here). This PR has grown too large already to include other fixes.The only fixes unrelated to the original issue I included here are the ones that caused failures on CI or during my tests.
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesstresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.## Disruptive User ImpactAuthor's Checklist
How to test this PR locally
1) Run existing tests (unit + integration)
These cover the new
journalctlargument behavior by version.2) Use the provided VMs to test different versions of
journalctlVAGRANT_VAGRANTFILEmakes Vagrant always usefilebeat/input/journald/Vagrantfile.VAGRANT_CWDdefines where Vagrant will save its state and which folder to use for relative pathsBring up VM matrix and verify versions
vagrant up 239 250 # or any other version/VM you want to test vagrant statusManually validate the new all-boots integration test
TestJournaldInputReadsMessagesFromAllBootsis intentionally skipped bydefault, you'll need to export
JOURNALD_MANUAL_TEST=1for the testto run.
Inside one of the VMs (recommended:
239and250):Expected:
journald.host.boot_idvalues.If there is only one boot, create another boot (
sudo reboot), reconnect, andrun again.
3) Manual test
Run Filebeat with the following configuration:
Details
Look for the log entries with message:
Journalctl command. Paths relative to chroot (if set). They will contain a fieldprocess.command_linewith the wholejournalctlcommand.You can use the following command to filter the logs and format them with
jq:You should see logs like:
{ "log.level": "info", "@timestamp": "2026-03-12T13:14:25.465-0400", "log.logger": "input.journald.reader", "log.origin": { "function": "github.com/elastic/beats/v7/filebeat/input/journald.(*journald).Run.NewFactory.func1", "file.name": "journalctl/journalctl.go", "file.line": 86 }, "message": "Journalctl command. Paths relative to chroot (if set)", "service.name": "filebeat", "id": "test--boot-all", "input_source": "LOCAL_SYSTEM_JOURNAL", "path": "LOCAL_SYSTEM_JOURNAL", "input_id": "test--boot-all", "process.command_line": "journalctl --version", "process.chroot": "", "ecs.version": "1.6.0" } { "log.level": "info", "@timestamp": "2026-03-12T13:14:25.467-0400", "log.logger": "input.journald.reader.journalctl-runner", "log.origin": { "function": "github.com/elastic/beats/v7/filebeat/input/journald.(*journald).Run.NewFactory.func1", "file.name": "journalctl/journalctl.go", "file.line": 86 }, "message": "Journalctl command. Paths relative to chroot (if set)", "service.name": "filebeat", "id": "test--boot-all", "input_source": "LOCAL_SYSTEM_JOURNAL", "path": "LOCAL_SYSTEM_JOURNAL", "input_id": "test--boot-all", "process.command_line": "journalctl --utc --output=json --no-pager --all --follow --after-cursor s=e82795fad4ce42b79fb3da0866d91f7e;i=15502a0;b=e224754c921445279ded5949d3a0dfc9;m=1820a8d806;t=64a18fd40f98c;x=a138e845a98ffe14 --boot all", "process.chroot": "", "ecs.version": "1.6.0" }Related issues
v242#48152--boot all. #49413## Use cases## Screenshots## LogsThis is an automatic backport of pull request #49445 done by [Mergify](https://mergify.com).