JournalD

Collect logs from JournalD

status: stable role: daemon delivery: at-least-once egress: batch state: stateless output: log

Configuration

Example configurations

{
  "sources": {
    "my_source_id": {
      "type": "journald",
      "current_boot_only": true,
      "exclude_units": "badservice",
      "include_units": "ntpd"
    }
  }
}
[sources.my_source_id]
type = "journald"
current_boot_only = true
exclude_units = "badservice"
include_units = "ntpd"
---
sources:
  my_source_id:
    type: journald
    current_boot_only: true
    exclude_units: badservice
    include_units: ntpd
{
  "sources": {
    "my_source_id": {
      "type": "journald",
      "batch_size": 16,
      "current_boot_only": true,
      "exclude_units": "badservice",
      "include_units": "ntpd",
      "data_dir": "/var/lib/vector",
      "journalctl_path": "journalctl"
    }
  }
}
[sources.my_source_id]
type = "journald"
batch_size = 16
current_boot_only = true
exclude_units = "badservice"
include_units = "ntpd"
data_dir = "/var/lib/vector"
journalctl_path = "journalctl"
---
sources:
  my_source_id:
    type: journald
    batch_size: 16
    current_boot_only: true
    exclude_units: badservice
    include_units: ntpd
    data_dir: /var/lib/vector
    journalctl_path: journalctl

batch_size

optional uint
The systemd journal is read in batches, and a checkpoint is set at the end of each batch. This option limits the size of the batch.
default: 16

current_boot_only

common optional bool
Include only entries from the current boot.
default: true

data_dir

optional string
The directory used to persist file checkpoint positions. By default, the global data_dir option is used. Please make sure the Vector project has write permissions to this dir.

exclude_units

common optional [string]
The list of unit names to exclude from monitoring. Unit names lacking a "." will have ".service" appended to make them a valid service unit name.
Array string literal
Examples
[
  "badservice",
  "sysinit.target"
]

include_units

common optional [string]
The list of unit names to monitor. If empty or not present, all units are accepted. Unit names lacking a "." will have ".service" appended to make them a valid service unit name.
Array string literal
Examples
[
  "ntpd",
  "sysinit.target"
]

journalctl_path

optional string
The full path of the journalctl executable. If not set, Vector will search the path for journalctl.
default: journalctl

Output

Logs

event

A Journald event

Telemetry

Metrics

link

events_in_total

counter
The number of events accepted by this component either from tagged origin like file and uri, or cumulatively from other origins.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.
container_name optional
The name of the container from which the event originates.
file optional
The file from which the event originates.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the event originates.
peer_path optional
The pathname from which the event originates.
pod_name optional
The name of the pod from which the event originates.
uri optional
The sanitized URI from which the event originates.

events_out_total

counter
The total number of events emitted by this component.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.

invalid_record_bytes_total

counter
The total number of bytes from invalid records that have been discarded.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.

invalid_record_total

counter
The total number of invalid records that have been discarded.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.

processed_bytes_total

counter
The number of bytes processed by the component.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.
container_name optional
The name of the container from which the bytes originate.
file optional
The file from which the bytes originate.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the bytes originate.
peer_path optional
The pathname from which the bytes originate.
pod_name optional
The name of the pod from which the bytes originate.
uri optional
The sanitized URI from which the bytes originate.

processed_events_total

counter
The total number of events processed by this component. This metric is deprecated in place of using events_in_total and events_out_total metrics.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.

Examples

Sample Output

Given this event...
```text
2019-07-26 20:30:27 reply from 192.168.1.2: offset -0.001791 delay 0.000176, next query 1500s
```
...and this configuration...
[sources.my_source_id]
type = "journald"
---
sources:
  my_source_id:
    type: journald
{
  "sources": {
    "my_source_id": {
      "type": "journald"
    }
  }
}
...this Vector event is produced:
[
  {
    "log": {
      "PRIORITY": "6",
      "SYSLOG_FACILITY": "3",
      "SYSLOG_IDENTIFIER": "ntpd",
      "_BOOT_ID": "124c781146e841ae8d9b4590df8b9231",
      "_CAP_EFFECTIVE": "3fffffffff",
      "_CMDLINE": "ntpd: [priv]",
      "_COMM": "ntpd",
      "_EXE": "/usr/sbin/ntpd",
      "_GID": "0",
      "_MACHINE_ID": "c36e9ea52800a19d214cb71b53263a28",
      "_PID": "2156",
      "_STREAM_ID": "92c79f4b45c4457490ebdefece29995e",
      "_SYSTEMD_CGROUP": "/system.slice/ntpd.service",
      "_SYSTEMD_INVOCATION_ID": "496ad5cd046d48e29f37f559a6d176f8",
      "_SYSTEMD_SLICE": "system.slice",
      "_SYSTEMD_UNIT": "ntpd.service",
      "_TRANSPORT": "stdout",
      "_UID": "0",
      "__MONOTONIC_TIMESTAMP": "98694000446",
      "__REALTIME_TIMESTAMP": "1564173027000443",
      "host": "my-host.local",
      "message": "reply from 192.168.1.2: offset -0.001791 delay 0.000176, next query 1500s",
      "timestamp": "2020-10-10T17:07:36.452332Z"
    }
  }
]

How it works

Checkpointing

Vector checkpoints the current read position after each successful read. This ensures that Vector resumes where it left off if restarted, preventing data from being read twice. The checkpoint positions are stored in the data directory which is specified via the global data_dir option, but can be overridden via the data_dir option in the file source directly.

Communication Strategy

To ensure the journald source works across all platforms, Vector interacts with the Systemd journal via the journalctl command. This is accomplished by spawning a subprocess that Vector interacts with. If the journalctl command is not in the environment path you can specify the exact location via the journalctl_path option. For more information on this communication strategy please see issue #1473.

Context

By default, the journald source augments events with helpful context keys.

Non-ASCII Messages

When journald has stored a message that is not strict ASCII, journalctl will output it in an alternate format to prevent data loss. Vector handles this alternate format by translating such messages into UTF-8 in “lossy” mode, where characters that are not valid UTF-8 are replaced with the Unicode replacement character, .

State

This component is stateless, meaning its behavior is consistent across each input.