From b25e9de2a58513708f0d2ba46ff2596444c5de5c Mon Sep 17 00:00:00 2001 From: Ye Ji Date: Fri, 2 Feb 2024 11:46:28 -0500 Subject: [PATCH] [receiver/journald]: add support for `all` configuration (#30971) **Description:** This commit adds support for `all` to journald receiver, which allows full output, including unprintable characters and lines that are too long. **Link to tracking Issue:** #30920 **Testing:** unit test and manual test. **Documentation:** receiver/journaldreceiver/README.md and pkg/stanza/docs/operators/journald_input.md --- .chloggen/add-all-to-journald-receiver.yaml | 27 +++++++++++++++++++ pkg/stanza/docs/operators/journald_input.md | 1 + pkg/stanza/operator/input/journald/config.go | 1 + .../operator/input/journald/journald.go | 4 +++ .../operator/input/journald/journald_test.go | 7 +++++ receiver/journaldreceiver/README.md | 1 + 6 files changed, 41 insertions(+) create mode 100755 .chloggen/add-all-to-journald-receiver.yaml diff --git a/.chloggen/add-all-to-journald-receiver.yaml b/.chloggen/add-all-to-journald-receiver.yaml new file mode 100755 index 000000000000..8cdb7a193178 --- /dev/null +++ b/.chloggen/add-all-to-journald-receiver.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: receiver/journald + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: add a new config option "all" that turns on full output from journalctl, including lines that are too long. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [30920] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/pkg/stanza/docs/operators/journald_input.md b/pkg/stanza/docs/operators/journald_input.md index b4c8d358f26b..f1643d7de1b0 100644 --- a/pkg/stanza/docs/operators/journald_input.md +++ b/pkg/stanza/docs/operators/journald_input.md @@ -21,6 +21,7 @@ The `journald_input` operator will use the `__REALTIME_TIMESTAMP` field of the j | `start_at` | `end` | At startup, where to start reading logs from the file. Options are `beginning` or `end`. | | `attributes` | {} | A map of `key: value` pairs to add to the entry's attributes. | | `resource` | {} | A map of `key: value` pairs to add to the entry's resource. | +| `all` | 'false' | If `true`, very long logs and logs with unprintable characters will also be included. | ### Example Configurations diff --git a/pkg/stanza/operator/input/journald/config.go b/pkg/stanza/operator/input/journald/config.go index 7f2afec5bcac..e7af99b14f24 100644 --- a/pkg/stanza/operator/input/journald/config.go +++ b/pkg/stanza/operator/input/journald/config.go @@ -36,6 +36,7 @@ type Config struct { Identifiers []string `mapstructure:"identifiers,omitempty"` Grep string `mapstructure:"grep,omitempty"` Dmesg bool `mapstructure:"dmesg,omitempty"` + All bool `mapstructure:"all,omitempty"` } type MatchConfig map[string]string diff --git a/pkg/stanza/operator/input/journald/journald.go b/pkg/stanza/operator/input/journald/journald.go index 24a35f1d9f70..477427df7edc 100644 --- a/pkg/stanza/operator/input/journald/journald.go +++ b/pkg/stanza/operator/input/journald/journald.go @@ -113,6 +113,10 @@ func (c Config) buildArgs() ([]string, error) { args = append(args, matches...) } + if c.All { + args = append(args, "--all") + } + return args, nil } diff --git a/pkg/stanza/operator/input/journald/journald_test.go b/pkg/stanza/operator/input/journald/journald_test.go index 40650e056964..29bc15503e8b 100644 --- a/pkg/stanza/operator/input/journald/journald_test.go +++ b/pkg/stanza/operator/input/journald/journald_test.go @@ -203,6 +203,13 @@ func TestBuildConfig(t *testing.T) { }, Expected: []string{"--utc", "--output=json", "--follow", "--priority", "info", "--dmesg"}, }, + { + Name: "all", + Config: func(cfg *Config) { + cfg.All = true + }, + Expected: []string{"--utc", "--output=json", "--follow", "--priority", "info", "--all"}, + }, } for _, tt := range testCases { diff --git a/receiver/journaldreceiver/README.md b/receiver/journaldreceiver/README.md index ddb41bdd11be..4ad8e271b6a6 100644 --- a/receiver/journaldreceiver/README.md +++ b/receiver/journaldreceiver/README.md @@ -35,6 +35,7 @@ Journald receiver requires that: | `grep` | | Filter output to entries where the MESSAGE= field matches the specified regular expression. See [Multiple filtering options](#multiple-filtering-options) examples. | | `dmesg` | 'false' | Show only kernel messages. This shows logs from current boot and adds the match `_TRANSPORT=kernel`. See [Multiple filtering options](#multiple-filtering-options) examples. | | `storage` | none | The ID of a storage extension to be used to store cursors. Cursors allow the receiver to pick up where it left off in the case of a collector restart. If no storage extension is used, the receiver will manage cursors in memory only. | +| `all` | 'false' | If `true`, very long logs and logs with unprintable characters will also be included. | | `retry_on_failure.enabled` | `false` | If `true`, the receiver will pause reading a file and attempt to resend the current batch of logs if it encounters an error from downstream components. | | `retry_on_failure.initial_interval` | `1 second` | Time to wait after the first failure before retrying. | | `retry_on_failure.max_interval` | `30 seconds` | Upper bound on retry backoff interval. Once this value is reached the delay between consecutive retries will remain constant at the specified value. |