[8.18](backport #46415) [Filebeat/Jourrnald] Convert binary blob to string #46588
+207
−13
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
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Disruptive User Impact
Events that have their message encoded in the binary format are correctly handled now, instead of appearing as a the string representation of a slice of bytes. This brings back the behaviour from before we moved to use
journalctl
.## Author's ChecklistHow to test this PR locally
Run the tests
Or only the tests added by this PR:
Run Filebeat using one of the test journals
Run Filebeat with the following configuration:
Ensure there are 9 entries in the output file:
Look at the message field of every entry:
The output should look like this:
Alternatively, you can edit the configuration to send the events to
Elasticsearch and look on Kibana:
Using your own test data
The following Go program can write directly to Journald's socket using
an encoding that supports binary data and strings containing
\n
. This program is also atfilebeat/input/journald/README.md
.main.go
Then for the input configuration add a filter to the identifier you
defined:
Then run Filebeat and look at your output.
Related issues
## Use casesScreenshots
I also compared how the implementation of this PR compares with Filebeat 8.12.0, which uses

go-systemd
instead of callingjournalctl
, and they both handle the binary format in the same way, see the screenshot below.## LogsThis is an automatic backport of pull request #46415 done by [Mergify](https://mergify.com).