Skip to content

Commit

Permalink
[receiver/journald]: add support for all configuration (#30971)
Browse files Browse the repository at this point in the history
**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
  • Loading branch information
meridional authored Feb 2, 2024
1 parent c11044b commit b25e9de
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .chloggen/add-all-to-journald-receiver.yaml
Original file line number Diff line number Diff line change
@@ -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]
1 change: 1 addition & 0 deletions pkg/stanza/docs/operators/journald_input.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions pkg/stanza/operator/input/journald/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions pkg/stanza/operator/input/journald/journald.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func (c Config) buildArgs() ([]string, error) {
args = append(args, matches...)
}

if c.All {
args = append(args, "--all")
}

return args, nil
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/stanza/operator/input/journald/journald_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions receiver/journaldreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down

0 comments on commit b25e9de

Please sign in to comment.