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
    exclude_matches: null
    include_units:
      - ntpd
    include_matches: null
{
  "sources": {
    "my_source_id": {
      "type": "journald",
      "batch_size": 16,
      "current_boot_only": true,
      "exclude_units": [
        "badservice"
      ],
      "include_units": [
        "ntpd"
      ],
      "journalctl_path": "journalctl",
      "data_dir": "/var/lib/vector",
      "journal_directory": "/run/log/journal"
    }
  }
}
[sources.my_source_id]
type = "journald"
batch_size = 16
current_boot_only = true
exclude_units = [ "badservice" ]
include_units = [ "ntpd" ]
journalctl_path = "journalctl"
data_dir = "/var/lib/vector"
journal_directory = "/run/log/journal"
---
sources:
  my_source_id:
    type: journald
    batch_size: 16
    current_boot_only: true
    exclude_units:
      - badservice
    exclude_matches: null
    include_units:
      - ntpd
    include_matches: null
    journalctl_path: journalctl
    data_dir: /var/lib/vector
    journal_directory: /run/log/journal

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 file_system_path
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.
Examples
"/var/lib/vector"

exclude_matches

common optional object
This list contains sets of field/value pairs that, if any are present in a journal entry, will cause the entry to be excluded from this source. If exclude_units is specified, it will be merged into this list.

exclude_matches.*

optional [string]
The set of field values to match in journal entries that are to be excluded.

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_matches

common optional object
This list contains sets of field/value pairs to monitor. If empty or not present, all journal fields are accepted. If include_units is specified, it will be merged into this list.

include_matches.*

optional [string]
The set of field values to match in journal entries that are to be included.

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"
]

journal_directory

optional string literal
The full path of the journal directory. If not set, journalctl will use the default system journal paths
Examples
"/run/log/journal"

journalctl_path

optional string literal
The full path of the journalctl executable. If not set, Vector will search the path for journalctl.
Examples
"/usr/local/bin/journalctl"
default: journalctl

Output

Logs

Event

A Journald event
Fields
* optional string literal
Any Journald field
Examples
/usr/sbin/ntpd
c36e9ea52800a19d214cb71b53263a28
host required string literal
The local hostname, equivalent to the gethostname command.
Examples
my-host.local
message required string literal
The raw line from the file.
Examples
53.126.150.246 - - [01/Oct/2020:11:25:58 -0400] "GET /disintermediate HTTP/2.0" 401 20308
timestamp required timestamp
The exact time the event was ingested into Vector.
Examples
2020-10-10T17:07:36.452332Z

Telemetry

Metrics

link

component_received_events_total

counter
The number of events accepted by this component either from tagged origins like file and uri, or cumulatively from other origins.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
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.
host required
The hostname of the system Vector is running on.
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.
pid required
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the event originates.
uri optional
The sanitized URI from which the event originates.

component_sent_event_bytes_total

counter
The total number of event bytes emitted by this component.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

component_sent_events_total

counter
The total number of events emitted by this component.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

events_in_total

counter
The number of events accepted by this component either from tagged origins like file and uri, or cumulatively from other origins. This metric is deprecated and will be removed in a future version. Use component_received_events_total instead.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
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.
host required
The hostname of the system Vector is running on.
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.
pid required
The process ID of the Vector instance.
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. This metric is deprecated and will be removed in a future version. Use component_sent_events_total instead.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

invalid_record_bytes_total

counter
The total number of bytes from invalid records that have been discarded.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

invalid_record_total

counter
The total number of invalid records that have been discarded.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

processed_bytes_total

counter
The number of bytes processed by the component.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
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.
host required
The hostname of the system Vector is running on.
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.
pid required
The process ID of the Vector instance.
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 component_received_events_total and component_sent_events_total metrics.
component_id required
The Vector component ID.
component_kind required
The Vector component kind.
component_name required
Deprecated, use component_id instead. The value is the same as component_id.
component_type required
The Vector component type.
host required
The hostname of the system Vector is running on.
pid required
The process ID of the Vector instance.

Examples

Sample Output

Given this event...
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.