The syslog-ng()
destination driver forwards log messages to another AxoSyslog node in EWMM format.
Note: For similar functionality using the OpenTelemetry protocol, see syslog-ng-otlp(): Forward logs to another node using OpenTelemetry.
The Enterprise-wide message model or EWMM allows you to deliver structured messages from the initial receiving AxoSyslog component right up to the central log server, through any number of hops. It does not matter if you parse the messages on the client, on a relay, or on the central server, their structured results will be available where you store the messages. Optionally, you can also forward the original raw message as the first AxoSyslog component in your infrastructure has received it, which is important if you want to forward a message for example, to a SIEM system. To make use of the enterprise-wide message model, you have to use the syslog-ng()
destination on the sender side, and the default-network-drivers()
source on the receiver side.
The syslog-ng()
destination driver is available in version 3.16 and later. The node that receives this message must use the default-network-drivers() source to properly handle the messages.
The following is a sample log message in EWMM format.
<13>1 2018-05-13T13:27:50.993+00:00 my-host @syslog-ng - - -
{"MESSAGE":"<34>Oct 11 22:14:15 mymachine su: 'su root' failed for username on
/dev/pts/8","HOST_FROM":"my-host","HOST":"my-host","FILE_NAME":"/tmp/in","._TAGS":".source.s_file"}
Declaration:
destination d_ewmm {
syslog-ng(server("192.168.1.1"));
};
Note in this driver you have to set the address of the destination server using the server()
parameter (in some other destinations, this parameter does not have an explicit name).
syslog-ng()
destination options
The syslog-ng()
destination is a special version of the network()
destination driver: by default, it sends EWMM-formatted log messages to the TCP514 port of the server.
ca-dir()
Accepted values: | Directory name |
Default: | none |
Description: The name of a directory that contains a set of trusted CA certificates in PEM format. The CA certificate files have to be named after the 32-bit hash of the subject’s name. This naming can be created using the c_rehash utility in openssl. For an example, see Configuring TLS on the AxoSyslog clients. The AxoSyslog application uses the CA certificates in this directory to validate the certificate of the peer.
This option can be used together with the optional ca-file()
option.
ca-file()
Accepted values: | File name |
Default: | empty |
Description: Optional. The name of a file that contains a set of trusted CA certificates in PEM format. The AxoSyslog application uses the CA certificates in this file to validate the certificate of the peer.
Example format in configuration:
ca-file("/etc/pki/tls/certs/ca-bundle.crt")
ca-file()
option can be used together with the ca-dir()
option, and it is relevant when peer-verify()
is set to other than no
or optional-untrusted
.
disk-buffer()
Description: This option enables putting outgoing messages into the disk buffer of the destination to avoid message loss in case of a system failure on the destination side. It has the following options:
capacity-bytes()
Type: | number (bytes) |
---|---|
Default: | 1MiB |
Description: This is a required option. The maximum size of the disk-buffer in bytes. The minimum value is 1048576
bytes. If you set a smaller value, the minimum value will be used automatically. It replaces the old log-disk-fifo-size()
option.
In AxoSyslog version 4.2 and earlier, this option was called disk-buf-size()
.
compaction()
Type: | yes/no |
---|---|
Default: | no |
Description: If set to yes
, AxoSyslog prunes the unused space in the LogMessage representation, making the disk queue size smaller at the cost of some CPU time. Setting the compaction()
argument to yes
is recommended when numerous name-value pairs are unset during processing, or when the same names are set multiple times.
unset()
rewrite operation is not enough, as due to performance reasons that help when AxoSyslog is CPU bound, the internal representation of a LogMessage
will not release the memory associated with these name-value pairs. In some cases, however, the size of this overhead becomes significant (the raw message size can grow up to four times its original size), which unnecessarily increases the disk queue file size. For these cases, the compaction will drop unset
values, making the LogMessage
representation smaller at the cost of some CPU time required to perform compaction.
dir()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the folder where the disk-buffer files are stored.
When creating a new dir()
option for a disk buffer, or modifying an existing one, make sure you delete the persist file.
AxoSyslog creates disk-buffer files based on the path recorded in the persist file. Therefore, if the persist file is not deleted after modifying the dir()
option, then following a restart, AxoSyslog will look for or create disk-buffer files in their old location. To ensure that AxoSyslog uses the new dir()
setting, the persist file must not contain any information about the destinations which the disk-buffer file in question belongs to.
dir()
path provided by the user does not exist, AxoSyslog creates the path with the same permission as the running instance.
flow-control-window-bytes()
Type: | number (bytes) |
---|---|
Default: | 163840000 |
Description: Use this option if the option reliable()
is set to yes
. This option contains the size of the messages in bytes that is used in the memory part of the disk buffer. It replaces the old log-fifo-size()
option. It does not inherit the value of the global log-fifo-size()
option, even if it is provided. Note that this option will be ignored if the option reliable()
is set to no
.
In AxoSyslog version 4.2 and earlier, this option was called mem-buf-size()
.
flow-control-window-size()
Type: | number(messages) |
---|---|
Default: | 10000 |
Description: Use this option if the option reliable()
is set to no
. This option contains the number of messages stored in overflow queue. It replaces the old log-fifo-size()
option. It inherits the value of the global log-fifo-size()
option if provided. If it is not provided, the default value is 10000
messages. Note that this option will be ignored if the option reliable()
is set to yes
.
In AxoSyslog version 4.2 and earlier, this option was called mem-buf-length()
.
front-cache-size()
Type: | number(messages) |
---|---|
Default: | 1000 |
Description: The number of messages stored in the output buffer of the destination. Note that if you change the value of this option and the disk-buffer already exists, the change will take effect when the disk-buffer becomes empty.
Options reliable()
and capacity-bytes()
are required options.
In AxoSyslog version 4.2 and earlier, this option was called qout-size()
.
prealloc()
Type: | yes/no |
---|---|
Default: | no |
Description:
By default, AxoSyslog doesn’t reserve the disk space for the disk-buffer file, since in a properly configured and sized environment the disk-buffer is practically empty, so a large preallocated disk-buffer file is just a waste of disk space. But a preallocated buffer can prevent other data from using the intended buffer space (and elicit a warning from the OS if disk space is low), preventing message loss if the buffer is actually needed. To avoid this problem, when using AxoSyslog 4.0 or later, you can preallocate the space for your disk-buffer files by setting prealloc(yes)
.
In addition to making sure that the required disk space is available when needed, preallocated disk-buffer files provide radically better (3-4x) performance as well: in case of an outage the amount of messages stored in the disk-buffer is continuously growing, and using large continuous files is faster, than constantly waiting on a file to change its size.
If you are running AxoSyslog on a dedicated host (always recommended for any high-volume settings), use prealloc(yes)
.
Available in AxoSyslog 4.0 and later.
reliable()
Type: | yes/no |
---|---|
Default: | no |
Description: If set to yes
, AxoSyslog cannot lose logs in case of reload/restart, unreachable destination or AxoSyslog crash. This solution provides a slower, but reliable disk-buffer option. It is created and initialized at startup and gradually grows as new messages arrive. If set to no
, the normal disk-buffer will be used. This provides a faster, but less reliable disk-buffer option.
reliable()
option when there are messages in the disk-buffer, the messages stored in the disk-buffer will be lost.
truncate-size-ratio()
Type: | number((between 0 and 1)) |
---|---|
Default: | 1 (do not truncate) |
Description: Limits the truncation of the disk-buffer file. Truncating the disk-buffer file can slow down the disk IO operations, but it saves disk space. By default, AxoSyslog version 4.0 and later doesn’t truncate disk-buffer files by default (truncate-size-ratio(1)
). Earlier versions freed the disk-space when at least 10% of the disk-buffer file could be freed (truncate-size-ratio(0.1)
).
AxoSyslog only truncates the file if the possible disk gain is more than truncate-size-ratio()
times capacity-bytes()
.
- Smaller values free disk space quicker.
- Larger ratios result in better performance.
If you want to avoid performance fluctuations:
- use
truncate-size-ratio(1)
(never truncate), or - use
prealloc(yes)
to reserve the entire size of the disk-buffer on disk.
truncate-size-ratio()
. Only change its value if you understand the performance implications of doing so.
Example: Examples for using disk-buffer()
In the following case reliable disk-buffer() is used.
destination d_demo {
network(
"127.0.0.1"
port(3333)
disk-buffer(
flow-control-window-bytes(10000)
capacity-bytes(2000000)
reliable(yes)
dir("/tmp/disk-buffer")
)
);
};
In the following case normal disk-buffer() is used.
destination d_demo {
network(
"127.0.0.1"
port(3333)
disk-buffer(
flow-control-window-size(10000)
capacity-bytes(2000000)
reliable(no)
dir("/tmp/disk-buffer")
)
);
};
failover()
Description: Available only in AxoSyslog version 3.17 and later. For details about how client-side failover works, see Client-side failover.
servers()
Type: | list of IP addresses and fully-qualified domain names |
---|---|
Default: | empty |
Description: Specifies a secondary destination server where log messages are sent if the primary server becomes inaccessible. To list several failover servers, separate the address of the servers with comma. By default, AxoSyslog waits for the a server before switching to the next failover server is set in the time-reopen()
option.
If failback()
is not set, AxoSyslog does not attempt to return to the primary server even if it becomes available. In case the failover server fails, AxoSyslog attempts to connect the next failover server in the list in round-robin fashion.
failback()
Description: Available only in AxoSyslog version 3.17 and later.
When AxoSyslog starts up, it always connects to the primary server first. In the failover()
option there is a possibility to customize the failover modes.
Depending on how you set the failback()
option, AxoSyslog behaves as follows:
-
round-robin mode
: Iffailback()
is not set, AxoSyslog does not attempt to return to the primary server even if it becomes available. In case the failover server fails, AxoSyslog attempts to connect the next failover server in the list in round-robin fashion.In the following example AxoSyslog handles the logservers in round-robin fashion if the primary logserver becomes inaccessible (therefore
failback()
option is not set).destination d_network { network( "primary-server.com" port(601) failover( servers("failover-server1", "failover-server2") ) ); };
-
failback mode
: Iffailback()
is set, AxoSyslog attempts to return to the primary server.After AxoSyslog connects a secondary server during a failover, it sends a probe every
tcp-probe-interval()
seconds towards the primary server. If the primary logserver responds with a TCP ACK packet, the probe is successful. When the number of successful probes reaches the value set in thesuccessful-probes-required()
option, AxoSyslog tries to connect the primary server using the last probe.Note AxoSyslog always waits for the result of the last probe before sending the next message. So if one connection attempt takes longer than the configured interval, that is, it waits for connection time out, you may experience longer intervals between actual probes.In the following example AxoSyslog attempts to return to the primary logserver, as set in the
failback()
option: it will check if the server is accessible everytcp-probe-interval()
seconds, and reconnect to the primary logserver after three successful connection attempts.destination d_network_2 { network( "primary-server.com" port(601) failover( servers("failover-server1", "failover-server2") failback( successful-probes-required() tcp-probe-interval() ) ) ); };
-
Default value for tcp-probe-interval()
: 60 seconds
Default value for successful-probes-required()
: 3
Example: Configuring failover servers
In the following example AxoSyslog handles the logservers in round-robin fashion if the primary logserver becomes uneccassible (therefore failback()
option is not set).
destination demo_failover_roundrobin{
syslog("primary-logserver.example.com"
failover(
servers("first-failover-logserver.example.com", "second-failover-logserver.example.com")
)
transport("tcp")
port(514)
time-reopen(60)
);
};
In the following example AxoSyslog attempts to return to the primary logserver, as set in the failback()
option: it will check if the server is accessible every tcp-probe-interval()
seconds, and reconnect to the primary logserver after three successful connection attempts.
destination demo_failover_returntoprimary{
syslog("primary-logserver.example.com"
failover(
servers("first-failover-logserver.example.com", "second-failover-logserver.example.com")
failback(
tcp-probe-interval(120)
successful-probes-required(3)
)
)
transport("tcp")
port(514)
time-reopen(60)
);
};
Example: Specifying failover servers for syslog() destinations
The following example specifies two failover servers for a simple syslog() destination.
destination d_syslog_tcp{
syslog("10.100.20.40"
transport("tcp")
port(6514)
failover-servers("10.2.3.4", "myfailoverserver")
);
};
The following example specifies a failover server for a network() destination that uses TLS encryption.
destination d_syslog_tls{
network("10.100.20.40"
transport("tls")
port(6514)
failover-servers("10.2.3.4", "myfailoverserver")
tls(peer-verify(required-trusted)
ca-dir('/opt/syslog-ng/etc/syslog-ng/keys/ca.d/')
key-file('/opt/syslog-ng/etc/syslog-ng/keys/client_key.pem')
cert-file('/opt/syslog-ng/etc/syslog-ng/keys/client_certificate.pem'))
);
};
flags()
Type: | no-multi-line, syslog-protocol |
Default: | empty set |
Description: Flags influence the behavior of the destination driver.
- no-multi-line: The
no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. - syslog-protocol: The
syslog-protocol
flag instructs the driver to format the messages according to the new IETF syslog protocol standard (RFC5424), but without the frame header. If this flag is enabled, macros used for the message have effect only for the text of the message, the message header is formatted to the new standard. Note that this flag is not needed for thesyslog
driver, and that thesyslog
driver automatically adds the frame header to the messages.
flush-lines()
Type: | number |
Default: | Use global setting (exception: for http() destination, the default is 1). |
Description: Specifies how many lines are flushed to a destination at a time. The AxoSyslog application waits for this number of lines to accumulate and sends them off in a single batch. Increasing this number increases throughput as more messages are sent in a single batch, but also increases message latency.
The AxoSyslog application flushes the messages if it has sent flush-lines()
number of messages, or the queue became empty. If you stop or reload AxoSyslog or in case of network sources, the connection with the client is closed, AxoSyslog automatically sends the unsent messages to the destination.
For optimal performance when sending messages to an AxoSyslog server, make sure that the value of flush-lines()
is smaller than the window size set in the log-iw-size()
option in the source of your server.
frac-digits()
Type: | number |
Default: | 0 |
Description: The AxoSyslog application can store fractions of a second in the timestamps according to the ISO8601 format. The frac-digits()
parameter specifies the number of digits stored. The digits storing the fractions are padded by zeros if the original timestamp of the message specifies only seconds. Fractions can always be stored for the time the message was received.
frac-digits()
option is set to a value higher than 6, AxoSyslog will truncate the fraction seconds in the timestamps after 6 digits.
ip-protocol()
Type: | number |
Default: | 4 |
Description: Determines the internet protocol version of the given driver (network()
or syslog()
). The possible values are 4
and 6
, corresponding to IPv4 and IPv6. The default value is ip-protocol(4)
.
Note that listening on a port using IPv6 automatically means that you are also listening on that port using IPv4. That is, if you want to have receive messages on an IP-address/port pair using both IPv4 and IPv6, create a source that uses the ip-protocol(6)
. You cannot have two sources with the same IP-address/port pair, but with different ip-protocol()
settings (it causes an Address already in use
error).
For example, the following source receives messages on TCP, using the network()
driver, on every available interface of the host on both IPv4 and IPv6.
source s_network_tcp { network( transport("tcp") ip("::") ip-protocol(6) port(601) ); };
ip-tos()
Type: | number |
Default: | 0 |
Description: Specifies the Type-of-Service value of outgoing packets.
ip-ttl()
Type: | number |
Default: | 0 |
Description: Specifies the Time-To-Live value of outgoing packets.
keep-alive()
Type: | yes or no |
Default: | yes |
Description: Specifies whether connections to destinations should be closed when syslog-ng
is reloaded. Note that this applies to the client (destination) side of the connections, server-side (source) connections are always reopened after receiving a HUP signal unless the keep-alive
option is enabled for the source.
localip()
Type: | string |
Default: | 0.0.0.0 |
Description: The IP address to bind to before connecting to target.
localport()
Type: | number |
Default: | 0 |
Description: The port number to bind to. Messages are sent from this port.
log-fifo-size()
Type: | number |
Default: | Use global setting. |
Description: The number of messages that the output queue can store.
mark-freq()
Accepted values: | number [seconds] |
Default: | 1200 |
Description: An alias for the obsolete mark()
option, retained for compatibility with version 1.6.x.
The number of seconds between two MARK
messages. MARK
messages are generated when there was no message traffic to inform the receiver that the connection is still alive. If set to zero (0
), no MARK
messages are sent. The mark-freq()
can be set for global option and/or every MARK
capable destination driver if mark-mode()
is periodical or dst-idle or host-idle. If mark-freq()
is not defined in the destination, then the mark-freq()
will be inherited from the global options. If the destination uses internal mark-mode()
, then the global mark-freq()
will be valid (does not matter what mark-freq()
set in the destination side).
mark-mode()
Accepted values: | internal | dst-idle | host-idle | periodical | none | global |
Default: |
|
Description: The mark-mode()
option can be set for the following destination drivers: file(), program(), unix-dgram(), unix-stream(), network(), pipe(), syslog() and in global option.
-
internal
: When internal mark mode is selected, internal source should be placed in the log path as this mode does not generate mark by itself at the destination. This mode only yields the mark messages from internal source. This is the mode as AxoSyslog 3.3 worked.MARK
will be generated by internal source if there was NO traffic on local sources:file()
,pipe()
,unix-stream()
,unix-dgram()
,program()
-
dst-idle
: SendsMARK
signal if there was NO traffic on destination drivers.MARK
signal from internal source will be dropped.MARK
signal can be sent by the following destination drivers:network()
,syslog()
,program()
,file()
,pipe()
,unix-stream()
,unix-dgram()
. -
host-idle
: SendsMARK
signal if there was NO local message on destination drivers. for example,MARK
is generated even if messages were received from tcp.MARK
signal from internal source will be dropped.MARK
signal can be sent by the following destination drivers:network()
,syslog()
,program()
,file()
,pipe()
,unix-stream()
,unix-dgram()
. -
periodical
: SendsMARK
signal perodically, regardless of traffic on destination driver.MARK
signal from internal source will be dropped.MARK
signal can be sent by the following destination drivers:network()
,syslog()
,program()
,file()
,pipe()
,unix-stream()
,unix-dgram()
. -
none
: Destination driver drops allMARK
messages. If an explicit mark-mode() is not given to the drivers wherenone
is the default value, thennone
will be used. -
global
: Destination driver uses the globalmark-mode()
setting. Note that setting the globalmark-mode()
to global causes a syntax error in AxoSyslog.
dst-idle
, host-idle
and periodical
, the MARK
message will not be written in the destination, if it is not open yet.
Available in AxoSyslog 3.4 and later.
port() or destport()
Type: | number |
Default: | 601 |
Description: The port number to connect to. Note that the default port numbers used by AxoSyslog do not comply with the latest RFC which was published after the release of AxoSyslog 3.0.2, therefore the default port numbers will change in the future releases.
server()
Type: | hostname or IP address |
Default: | 127.0.0.1 |
Description: The hostname or IP address of the AxoSyslog server.
so-broadcast()
Type: | yes or no |
Default: | no |
Description: This option controls the SO_BROADCAST
socket option required to make AxoSyslog send messages to a broadcast address. For details, see the socket(7)
manual page.
so-keepalive()
Type: | yes or no |
Default: | no |
Description: Enables keep-alive messages, keeping the socket open. This only effects TCP and UNIX-stream sockets. For details, see the socket(7)
manual page.
so-rcvbuf()
Type: | number |
Default: | 0 |
Description: Specifies the size of the socket receive buffer in bytes. For details, see the socket(7)
manual page.
so-sndbuf()
Type: | number |
Default: | 0 |
Description: Specifies the size of the socket send buffer in bytes. For details, see the socket(7)
manual page.
suppress()
Type: | seconds |
Default: | 0 (disabled) |
Description: If several identical log messages would be sent to the destination without any other messages between the identical messages (for example, an application repeated an error message ten times), AxoSyslog can suppress the repeated messages and send the message only once, followed by the Last message repeated n times.
message. The parameter of this option specifies the number of seconds AxoSyslog waits for identical messages.
tcp-keepalive-intvl()
Type: | number [seconds] |
Default: | 0 |
Description: Specifies the interval (number of seconds) between subsequential keepalive probes, regardless of the traffic exchanged in the connection. This option is equivalent to /proc/sys/net/ipv4/tcp_keepalive_intvl
. The default value is 0
, which means using the kernel default.
The tcp-keepalive-time()
, tcp-keepalive-probes()
, and tcp-keepalive-intvl()
options only work on platforms which support the TCP_KEEPCNT
, TCP_KEEPIDLE
,and TCP_KEEPINTVL
setsockopts. Currently, this is Linux.
A connection that has no traffic is closed after tcp-keepalive-time() + tcp-keepalive-intvl() * tcp-keepalive-probes()
seconds.
Available in AxoSyslog version 3.4 and later.
tcp-keepalive-probes()
Type: | number |
Default: | 0 |
Description: Specifies the number of unacknowledged probes to send before considering the connection dead. This option is equivalent to /proc/sys/net/ipv4/tcp_keepalive_probes
. The default value is 0
, which means using the kernel default.
The tcp-keepalive-time()
, tcp-keepalive-probes()
, and tcp-keepalive-intvl()
options only work on platforms which support the TCP_KEEPCNT
, TCP_KEEPIDLE
,and TCP_KEEPINTVL
setsockopts. Currently, this is Linux.
A connection that has no traffic is closed after tcp-keepalive-time() + tcp-keepalive-intvl() * tcp-keepalive-probes()
seconds.
Available in AxoSyslog version 3.4 and later.
tcp-keepalive-time()
Type: | number [seconds] |
Default: | 0 |
Description: Specifies the interval (in seconds) between the last data packet sent and the first keepalive probe. This option is equivalent to /proc/sys/net/ipv4/tcp_keepalive_time
. The default value is 0
, which means using the kernel default.
The tcp-keepalive-time()
, tcp-keepalive-probes()
, and tcp-keepalive-intvl()
options only work on platforms which support the TCP_KEEPCNT
, TCP_KEEPIDLE
,and TCP_KEEPINTVL
setsockopts. Currently, this is Linux.
A connection that has no traffic is closed after tcp-keepalive-time() + tcp-keepalive-intvl() * tcp-keepalive-probes()
seconds.
Available in AxoSyslog version 3.4 and later.
template()
Type: | string |
Default: | A format conforming to the default logfile format. |
Description: Specifies a template defining the logformat to be used in the destination. Macros are described in Macros of AxoSyslog. Please note that for network destinations it might not be appropriate to change the template as it changes the on-wire format of the syslog protocol which might not be tolerated by stock syslog receivers (like syslogd
or syslog-ng
itself). For network destinations make sure the receiver can cope with the custom format defined.
template-escape()
Type: | yes or no |
Default: | no |
Description: Turns on escaping for the '
, "
, and backspace characters in templated output files. This is useful for generating SQL statements and quoting string contents so that parts of the log message are not interpreted as commands to the SQL server.
Note: Starting with AxoSyslog version 4.5,
template-escape(yes)
escapes the top-level template function in case of nested template functions.
throttle()
Type: | number |
Default: | 0 |
Description: Sets the maximum number of messages sent to the destination per second. Use this output-rate-limiting functionality only when using disk-buffer as well to avoid the risk of losing messages. Specifying 0
or a lower value sets the output limit to unlimited.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: | unspecified |
Description: Convert timestamps to the timezone specified by this option. If this option is not set, then the original timezone information in the message is used. Converting the timezone changes the values of all date-related macros derived from the timestamp, for example, HOUR
. For the complete list of such macros, see Date-related macros.
The timezone can be specified by using the name, for example, time-zone("Europe/Budapest")
), or as the timezone offset in +/-HH:MM format, for example, +01:00
). On Linux and UNIX platforms, the valid timezone names are listed under the /usr/share/zoneinfo
directory.
tls()
Type: | tls options |
Default: | n/a |
Description: This option sets various options related to TLS encryption, for example, key/certificate files and trusted CA locations. TLS can be used only with tcp-based transport protocols. For details, see TLS options.
transport()
Type: | udp, tcp, or tls |
Default: | tcp |
Description: Specifies the protocol used to send messages to the destination server.
If you use the udp
transport, AxoSyslog automatically sends multicast packets if a multicast destination address is specified. The tcp
transport does not support multicasting.
ts-format()
Type: | rfc3164, bsd, rfc3339, iso |
Default: | rfc3164 |
Description: Override the global timestamp format (set in the global ts-format()
parameter) for the specific destination. For details, see ts-format().
network()
, or syslog()
) ignore this option. For protocol-like destinations, use a template locally in the destination, or use the proto-template option.