|
| 1 | +--- |
| 2 | +title: Journald |
| 3 | +description: Collect logs from journald |
| 4 | +--- |
| 5 | + |
| 6 | +## Journald Collector |
| 7 | + |
| 8 | +To collect log entries from the journald service, you can use the `journald` collector. |
| 9 | + |
| 10 | +### Parameters |
| 11 | + |
| 12 | +In addition to the [shared collector properties](/collect/collectors/#shared-properties), the `journald` collector accepts the following parameters to filter journal records: |
| 13 | + |
| 14 | +#### `system` (Optional) |
| 15 | + |
| 16 | +Show messages from system services and the kernel. Default to `false` |
| 17 | + |
| 18 | +#### `dmesg` (Optional) |
| 19 | + |
| 20 | +Include messages from the kernel ring buffer. Default to `false` |
| 21 | + |
| 22 | +#### `units` (Optional) |
| 23 | + |
| 24 | +A list of systemd units to include messages from. If empty, messages from all units will be included. |
| 25 | + |
| 26 | +#### `since` (Optional) |
| 27 | + |
| 28 | +Specify a starting point for the journal entries. This can be a timestamp or a relative time (for example, `"1 day ago"` for the previous day). |
| 29 | + |
| 30 | +#### `until` (Optional) |
| 31 | + |
| 32 | +Specify an endpoint for the journal entries. This can be a timestamp or a relative time. |
| 33 | + |
| 34 | +#### `output` (Optional) |
| 35 | + |
| 36 | +Specify the format for the collected logs. Default is `"short"`. |
| 37 | + |
| 38 | +#### `lines` (Optional) |
| 39 | + |
| 40 | +Limit the number of lines to fetch from the journal. If set to `0`, all lines will be fetched. Default is `0`. |
| 41 | + |
| 42 | +#### `reverse` (Optional) |
| 43 | + |
| 44 | +Show the newest entries first. Default to `false`. |
| 45 | + |
| 46 | +#### `utc` (Optional) |
| 47 | + |
| 48 | +Show timestamps in UTC. Default to `false`. |
| 49 | + |
| 50 | +#### `timeout` (Optional) |
| 51 | + |
| 52 | +Specify a timeout for collecting the logs. Default to `"30s"`. |
| 53 | + |
| 54 | +### Example Collector Definition |
| 55 | + |
| 56 | +```yaml |
| 57 | +apiVersion: troubleshoot.sh/v1beta2 |
| 58 | +kind: SupportBundle |
| 59 | +metadata: |
| 60 | + name: logs |
| 61 | +spec: |
| 62 | + hostCollectors: |
| 63 | + - journald: |
| 64 | + collectorName: "k0s" |
| 65 | + system: false |
| 66 | + dmesg: false |
| 67 | + units: |
| 68 | + - k0scontroller |
| 69 | + - containerd |
| 70 | + since: "1 day ago" |
| 71 | + output: "json" |
| 72 | + lines: 1000 |
| 73 | + reverse: true |
| 74 | + utc: true |
| 75 | + timeout: "30s" |
| 76 | +``` |
| 77 | +
|
| 78 | +### Included Resources |
| 79 | +
|
| 80 | +The results of the `journald` collector are stored in the `host-collectors/journald` directory of the bundle. Two files per collector execution will be stored in this directory. |
| 81 | + |
| 82 | +- `[collector-name].txt` - output of the logs from `journalctl` |
| 83 | +- `[collector-name]-info.json` - the command that was executed, its exit code and any output read from `stderr`. See the example below: |
| 84 | + |
| 85 | +```json |
| 86 | +{ |
| 87 | + "command": "/usr/bin/journalctl -u k0scontroller -n 100 --reverse --utc --no-pager", |
| 88 | + "exitCode": "0", |
| 89 | + "error": "", |
| 90 | + "outputDir": "", |
| 91 | + "input": "", |
| 92 | + "env": null |
| 93 | +} |
| 94 | +``` |
0 commit comments