lumberjack: Receive logs from Beats and Logstash
Lumberjack is the protocol that Filebeat
, the other Beats, and Logstash use to send events to Logstash. The lumberjack() transport of the network() source
receives these events. Point the Logstash output of your Beats at AxoSyslog to process and route the events before you forward them to their final destination.
AxoSyslog accepts version 1 and version 2 of the protocol, and compressed frames.
Prerequisites
- AxoSyslog version 4.30 or later. The
lumberjack()transport is part of the core package.
Example: Receiving events from Filebeat
The following source listens for Lumberjack connections on port 5044, the default port of the Beats protocol, over TLS:
source s_beats {
network(
port(5044)
transport(lumberjack(max-window-size(2048)))
tls(
key-file("/etc/syslog-ng/beats.key")
cert-file("/etc/syslog-ng/beats.crt")
)
);
};
log {
source(s_beats);
destination(d_buffered);
flags(flow-control);
};Configure the Logstash output of your Filebeat to point at this address, for example:
output.logstash:
hosts: ["<IP-of-AxoSyslog>:5044"]
ssl.enabled: true
ssl.certificate_authorities: ["/etc/filebeat/ca.crt"]
bulk_max_size: 2048To receive the events without TLS, omit the tls() option from the source, and the ssl.* options from the Filebeat configuration.
How lumberjack() processes the events
- Every event becomes a separate log message.
- AxoSyslog doesn’t parse the event as a syslog message. The
${MESSAGE}macro contains the event as JSON, exactly as the sender sent it. - Version 1 of the protocol sends the events as key-value pairs. AxoSyslog converts them into a JSON object.
- The
${.lumberjack.version}name-value pair contains the version of the protocol that the event arrived in (1or2). - The
${HOST}macro contains the address or the hostname of the sender, depending on theuse-dns()option. - The timestamps of the message are the time when AxoSyslog received it.
To access the fields of the event, parse ${MESSAGE} with the json-parser()
or in FilterX
. The following example uses the =?? operator
, so ${HOST} and ${MESSAGE} keep their original values if the event doesn’t have the host.name or message field:
log {
source(s_beats);
filterx {
event = json($MESSAGE);
$HOST =?? event.host.name;
$MESSAGE =?? event.message;
};
destination(d_buffered);
flags(flow-control);
};Acknowledgements and flow control
The sender sends the events in windows. It considers the events of a window delivered only when AxoSyslog acknowledges the window. AxoSyslog acknowledges a window when it has processed the last event of the window:
- With flow control
(
flags(flow-control)) and a disk-buffer in the destination, the acknowledgement means that the events are stored. If AxoSyslog stops before it stores the events, the sender resends them. - Without flow control, the acknowledgement means only that AxoSyslog has received the events. Logstash works the same way.
While a window waits for its acknowledgement, AxoSyslog sends keepalive messages to the sender (see keepalive-interval()
), so that the sender doesn’t time out.
Options of the lumberjack() transport
You can use the following options in the lumberjack() transport, for example, transport(lumberjack(max-window-size(2048) window-timeout(60))). Without options, you can also use the transport(lumberjack) form.
In addition, the following options of the network() source
apply:
port(): The default port of thelumberjack()transport is 5044.tls(): AxoSyslog starts the TLS handshake with the first byte of the connection, as the protocol requires.log-msg-size(): The maximal size of a single event. AxoSyslog drops larger events, logs a warning, and increases thesyslogng_lumberjack_frames_dropped_totalcounter.idle-timeout(): How long AxoSyslog waits for the next window of the sender.
keepalive-interval()
| Type: | number (seconds) |
| Default: | 5 |
Description: How often AxoSyslog sends a keepalive message to the sender while a window waits for its acknowledgement, for example, because of flow control. Set it to 0 to disable keepalives.
max-inflated-size()
| Type: | number (bytes) |
| Default: | 67108864 (64 MiB) |
Description: The maximal size of a compressed frame after decompression. AxoSyslog closes the connection if a compressed frame inflates to a larger size. This protects AxoSyslog from compression bombs. Set it to 0 to disable the limit.
max-window-size()
| Type: | number |
| Default: | 10000 |
Description: The largest window that AxoSyslog accepts. A window is the number of events that the sender sends before it waits for an acknowledgement. If the sender announces a larger window, AxoSyslog closes the connection. Set it to 0 to accept windows of any size.
CAUTION:
Set this option to at least the batch size of the sender, for example, the bulk_max_size option of Filebeat. The sender cannot learn the limit of AxoSyslog. If its windows are larger, it reconnects and resends the same window indefinitely. In this case, AxoSyslog logs an error message that includes the window size of the sender.
window-timeout()
| Type: | number (seconds) |
| Default: | 30 |
Description: How long a window can stall before all of its events arrive. If the sender stops sending in the middle of a window for longer than this, AxoSyslog closes the connection. Set it to 0 to disable the timeout.
Metrics of the lumberjack() transport
The lumberjack() transport has the following metrics, available at stats(level(1)) and above:
syslogng_lumberjack_frames_total- The number of events received, by protocol version (
versionlabel:1or2). syslogng_lumberjack_acknowledgements_total- The number of acknowledgements sent to the senders.
syslogng_lumberjack_frames_dropped_total- The number of events dropped because they were larger than
log-msg-size()(reason="too_large"). syslogng_lumberjack_protocol_errors_total- The number of connections closed because of a protocol error. The
reasonlabel shows the type of the error:version: unknown protocol versionframe_type: unknown or unexpected frame typewindow_size: the window is larger thanmax-window-size()length: invalid frame lengthcompression: invalid compressed datainflated_size: the decompressed frame is larger thanmax-inflated-size()