Skip to content

Commit 1e43a1b

Browse files
authored
[receiver/journald]: add support for dmesg (#25910)
Adds support for `--dmesg` to journaldreceiver
1 parent 175bb59 commit 1e43a1b

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

.chloggen/drosiek-journald.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: journaldreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: add support for dmesg
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [20295]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

pkg/stanza/operator/input/journald/journald.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type Config struct {
6060
Priority string `mapstructure:"priority,omitempty"`
6161
Matches []MatchConfig `mapstructure:"matches,omitempty"`
6262
Grep string `mapstructure:"grep,omitempty"`
63+
Dmesg bool `mapstructure:"dmesg,omitempty"`
6364
}
6465

6566
type MatchConfig map[string]string
@@ -119,6 +120,10 @@ func (c Config) buildArgs() ([]string, error) {
119120
args = append(args, "--grep", c.Grep)
120121
}
121122

123+
if c.Dmesg {
124+
args = append(args, "--dmesg")
125+
}
126+
122127
switch {
123128
case c.Directory != nil:
124129
args = append(args, "--directory", *c.Directory)

pkg/stanza/operator/input/journald/journald_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ func TestBuildConfig(t *testing.T) {
190190
},
191191
Expected: []string{"--utc", "--output=json", "--follow", "--priority", "info", "--grep", "test_grep"},
192192
},
193+
{
194+
Name: "dmesg",
195+
Config: func(cfg *Config) {
196+
cfg.Dmesg = true
197+
},
198+
Expected: []string{"--utc", "--output=json", "--follow", "--priority", "info", "--dmesg"},
199+
},
193200
}
194201

195202
for _, tt := range testCases {

receiver/journaldreceiver/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Journald receiver requires that:
3232
| `matches` | | A list of matches to read entries from. See [Matches](#matches) and [Multiple filtering options](#multiple-filtering-options) examples. |
3333
| `priority` | `info` | Filter output by message priorities or priority ranges. See [Multiple filtering options](#multiple-filtering-options) examples. |
3434
| `grep` | | Filter output to entries where the MESSAGE= field matches the specified regular expression. See [Multiple filtering options](#multiple-filtering-options) examples. |
35+
| `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. |
3536
| `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. |
3637
| `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. |
3738
| `retry_on_failure.initial_interval` | `1 second` | Time to wait after the first failure before retrying. |
@@ -85,6 +86,8 @@ which is going to retrieve all entries which match at least one of the following
8586
In case of using multiple following options, conditions between them are logically `AND`ed and within them are logically `OR`ed:
8687

8788
```text
89+
( dmesg )
90+
AND
8891
( priority )
8992
AND
9093
( units[0] OR units[1] OR units[2] OR ... units[U] )

0 commit comments

Comments
 (0)