This is the multi-page printable view of this section. Click here to print.
source: Read, receive, and collect log messages
- 1: How sources work
- 2: Arr logs
- 3: Collect native macOS system logs
- 4: default-network-drivers: Receive and parse common syslog messages
- 5: internal: Collect internal messages
- 6: file: Collect messages from text files
- 7: wildcard-file: Collect messages from multiple text files
- 8: Hypr Audit Trail and Hypr App Audit Trail
- 9: Jellyfin logs
- 10: linux-audit: Collect messages from Linux audit logs
- 11: kubernetes: Collect and parse the Kubernetes CRI (Container Runtime Interface) format
- 12: mbox: Convert local email messages to log messages
- 12.1: mbox() source options
- 13: mqtt: receiving messages from an MQTT broker
- 13.1: Prerequisites to using the mqtt() source
- 13.2: Limitations to using the mqtt() source
- 13.3: Options of the mqtt() source
- 14: network: Collect messages using the RFC3164 protocol (network() driver)
- 14.1: network() source options
- 14.2: Proxy Protocol support
- 15: nodejs: Receive JSON messages from nodejs applications
- 15.1: nodejs() source options
- 16: osquery: Collect and parse osquery result logs
- 16.1: osquery() source options
- 17: Receive logs, metrics, and traces from OpenTelemetry
- 18: pacct: Collect process accounting logs on Linux
- 18.1: pacct() options
- 19: Pi-hole Faster Than Light logs
- 20: pipe: Collect messages from named pipes
- 20.1: pipe() source options
- 21: program: Receive messages from external applications
- 21.1: program() source options
- 22: python: writing server-style Python sources
- 23: python-fetcher: writing fetcher-style Python sources
- 24: qBittorrent logs
- 25: snmptrap: Read Net-SNMP traps
- 26: sun-streams: Collect messages on Sun Solaris
- 27: syslog: Collect messages using the IETF-syslog protocol
- 27.1: syslog() source options
- 28: syslog-ng-otlp(): Receive logs from another node using OpenTelemetry
- 29: system: Collect the system-specific log messages of a platform
- 29.1: system() source options
- 30: systemd-journal: Collect messages from the systemd-journal system log storage
- 31: systemd-syslog: Collect systemd messages using a socket
- 32: tcp, tcp6, udp, udp6: OBSOLETE - Collect messages from remote hosts using the BSD syslog protocol
- 33: unix-stream, unix-dgram: Collect messages from UNIX domain sockets
- 34: stdin: Collect messages from the standard input stream
- 34.1: stdin() source options
1 - How sources work
A source is where AxoSyslog receives log messages. Sources consist of one or more drivers, each defining where and how messages are received.
To define a source, add a source statement to the syslog-ng.conf
configuration file using the following syntax:
source <identifier> {
source-driver(params); source-driver(params); ...
};
Example: A simple source statement
The following source statement receives messages on the TCP port 1999
of the interface having the 10.1.2.3
IP address.
source s_demo_tcp {
network(ip(10.1.2.3) port(1999));
};
Example: A source statement using two source drivers
The following source statement receives messages on the 1999
TCP port and the 1999
UDP port of the interface having the 10.1.2.3
IP address.
source s_demo_two_drivers {
network(ip(10.1.2.3) port(1999));
network(ip(10.1.2.3) port(1999) transport("udp"));
};
Example: Setting default priority and facility
If the message received by the source does not have a proper syslog header, you can use the default-facility()
and default-priority()
options to set the facility and priority of the messages. Note that these values are applied only to messages that do not set these parameters in their header.
source headerless_messages { network(default-facility(syslog) default-priority(emerg)); };
Define a source only once. The same source can be used in several log paths. Duplicating sources causes AxoSyslog to open the source (TCP/IP port, file, and so on) more than once, which might cause problems. For example, include the /dev/log
file source only in one source statement, and use this statement in more than one log path if needed.
Sources and destinations are initialized only when they are used in a log statement. For example, AxoSyslog starts listening on a port or starts polling a file only if the source is used in a log statement. For details on creating log statements, see log: Filter and route log messages using log paths, flags, and filters.
To collect log messages on a specific platform, it is important to know how the native syslogd
communicates on that platform. The following table summarizes the operation methods of syslogd
on some of the tested platforms:
Communication methods used between the applications and syslogd
Platform | Method |
---|---|
Linux | A SOCK_DGRAM unix socket named /dev/log . Newer distributions that use systemd collect log messages into a journal file. |
BSD flavors | A SOCK_DGRAM unix socket named /var/run/log . |
Solaris (2.5 or below) | An SVR4 style STREAMS device named /dev/log . |
Solaris (2.6 or above) | In addition to the STREAMS device used in earlier versions, 2.6 uses a new multithreaded IPC method called door. By default the door used by syslogd is /etc/.syslog_door . |
HP-UX 11 or later | HP-UX uses a named pipe called /dev/log that is padded to 2048 bytes, for example, source s_hp-ux {pipe ("/dev/log" pad-size(2048)} . |
AIX 5.2 and 5.3 | A SOCK_STREAM or SOCK_DGRAM unix socket called /dev/log . |
Each possible communication mechanism has a corresponding source driver in syslog-ng
. For example, to open a unix socket with SOCK_DGRAM
style communication use the driver unix-dgram
. The same socket using the SOCK_STREAM
style — as used under Linux — is called unix-stream
.
Example: Source statement on a Linux based operating system
The following source statement collects the following log messages:
-
internal(): Messages generated by
syslog-ng
. -
network(transport(“udp”)): Messages arriving to the
514/UDP
port of any interface of the host. -
unix-dgram("/dev/log");: Messages arriving to the
/dev/log
socket.
source s_demo {
internal();
network(transport("udp"));
unix-dgram("/dev/log");
};
Sources list
The following table lists the source drivers available in syslog-ng
.
Source drivers available in syslog-ng
Name | Description |
---|---|
file() | Opens the specified file and reads messages. |
internal() | Messages generated internally in syslog-ng . |
kubernetes() | Collects container logs managed by the Kubelet. |
mbox() | Read email messages from local mbox files, and convert them to multiline log messages. |
network() | Receives messages from remote hosts using the BSD-syslog protocol over IPv4 and IPv6. Supports the TCP, UDP, and TLS network protocols. |
nodejs() | Receives JSON messages from nodejs applications. |
osquery() | Run osquery queries, and convert their results into log messages. |
pacct() | Reads messages from the process accounting logs on Linux. |
pipe() | Opens the specified named pipe and reads messages. |
program() | Opens the specified application and reads messages from its standard output. |
python() and python-fetcher() | Receive or fetch messages using a custom source written in Python. |
snmptrap() | Read and parse the SNMP traps of the Net-SNMP’s snmptrapd application. |
sun-stream(), sun-streams() | Opens the specified STREAMS device on Solaris systems and reads incoming messages. |
syslog() | Listens for incoming messages using the new IETF-standard syslog protocol. |
system() | Automatically detects which platform AxoSyslog is running on, and collects the native log messages of that platform. |
systemd-journal() | Collects messages directly from the journal of platforms that use systemd. |
systemd-syslog() | Collects messages from the journal using a socket on platforms that use systemd. |
unix-dgram() | Opens the specified unix socket in SOCK_DGRAM mode and listens for incoming messages. |
unix-stream() | Opens the specified unix socket in SOCK_STREAM mode and listens for incoming messages. |
stdin() | Collects messages from the standard input stream. |
wildcard-file() | Reads messages from multiple files and directories. |
2 - Arr logs
Starting with version 4.7.0, AxoSyslog can collect logs of the Lidarr, Prowlarr, Radarr, Readarr, and Sonarr (often referred to as “*Arr” or “*Arrs”) applications.
Use the new *arr()
sources to read various *arr logs:
lidarr()
prowlarr()
radarr()
readarr()
sonarr()
whisparr()
Example minimal config:
source s_radarr {
radarr(
dir("/path/to/my/radarr/log/dir")
);
};
The logging module is stored in the <prefix><module>
name-value pair, for example: .radarr.module
=> ImportListSyncService
.
You can modify the prefix with the prefix()
option.
This driver is actually a reusable configuration snippet. For details on using or writing such configuration snippets, see Reusing configuration blocks. You can find the source of this configuration snippet on GitHub.
3 - Collect native macOS system logs
Starting with version 4.6.0, AxoSyslog can collect logs on macOS using its native OSLog framework using the darwin-oslog()
and darwin-oslog-stream()
source drivers.
darwin-oslog()
: This source builds on the native OSLog framework, and replaces the earlier file-source based solution.darwin-oslog-stream()
: Provides a live log stream feed.
darwin-oslog()
This source is based on the native OSLog Framework to read logs from the local store of the unified logging system on darwin OSes. The AxoSyslog system()
source automatically uses this new source on darwin platforms if the darwinosl
plugin is available. This plugin is available only on macOS 10.15 Catalina and above, the first version that has the OSLog API.
Note that the persistent OSLog store usually keeps about 7 days of logs on disk.
The darwin-oslog()
source has the following options:
filter-predicate()
Type: | string |
Default: | (eventType == 'logEvent' || eventType == 'lossEvent' || eventType == 'stateEvent' || eventType == 'userActionEvent') && (logType != 'debug') |
Description: String for native macOS log message filtering using predicates. For example, the following predicate selects AirDrop logs: subsystem=="com.apple.sharing" and category=="AirDrop"
do-not-use-bookmark()
Type: | boolean |
Default: | no |
Description: By default, AxoSyslog continues to read the logs from the last remembered position after a restart. If this option is set to yes
, it will always start reading from the end or beginning of the available log list (depending on the setting of the go-reverse()
option).
fetch-delay()
Type: | integer |
Default: | 10000 |
Description: Controls the time AxoSyslog waits between reading and sending log messages. This is a fraction of a second, where wait_time = 1 second / n
, so n=1
means that only about 1 log is sent in each second, and n=1000000
means only 1 microsecond is the delay between read/write attempts. The maximal value of this parameter is 1000000
. Note that increasing the value of this parameter (thus lowering delay time) can increase log feed performance, but at the same time could increase system load.
fetch-retry-delay()
Type: | integer |
Default: | 1 |
Description: Controls how many seconds AxoSyslog waits before trying to check for new logs if there were no more logs to read the last time.
go-reverse()
Type: | boolean |
Default: | no |
Description: Set it to yes
to process the logs in a reverse order (from latest to oldest).
log-fetch-limit()
Type: | integer |
Default: | 0 (no limit) |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
max-bookmark-distance()
Type: | integer |
Default: | 0 (no limit) [seconds] |
Description: The maximum distance in seconds that a bookmark can point backwards. That is, if AxoSyslog was stopped for 10 minutes and max-bookmark-distance()
is set to 60
, then AxoSyslog will start reading the logs from 60 seconds before the startup, losing 9 minutes of logs.
read-old-records()
Type: | boolean |
Default: | no |
Description: If set to yes
, AxoSyslog starts reading logs from the oldest available log when it’s first started on a system, or if there are no bookmarks for some reason
darwin-oslog-stream()
This source is a wrapper around the OS command line log stream
command that provides a live log stream feed. Unlike the darwin-oslog()
source, the live stream can contain non-persistent log events as well. This might result in a large number of log events every second.
This source has only one option.
params()
Type: | string |
Default: | --type log --type trace --level info --level debug |
Description: A string that can contain all the possible params the macOS log
tool can accept. The source uses the “–style” internally (defaults to ndjson
), so use templates or rewrite rules to format the final output. Use the def-osl-stream-params
string to reference the default values when extending them with your own.
For a full reference, see the output of the log --help stream
and man log
commands.
4 - default-network-drivers: Receive and parse common syslog messages
The default-network-drivers()
source is a special source that uses multiple source drivers to receive and parse several different types of syslog messages from the network. Available in version 3.16 and later.
To use the default-network-drivers()
source, the scl.conf
file must be included in your AxoSyslog configuration:
@include "scl.conf"
Also, make sure that your SELinux, AppArmor, and firewall settings permit AxoSyslog to access the ports where you want to receive messages, and that no other application is using these ports. By default, the default-network-drivers()
source accepts messages on the following ports:
- 514, both TCP and UDP, for RFC3164 (BSD-syslog) formatted traffic
- 601 TCP, for RFC5424 (IETF-syslog) formatted traffic
- 6514 TCP, for TLS-encrypted traffic
In addition to receiving messages on different ports and in different formats, this source tries to parse the messages automatically. If successful, it sets the ${.app.name}
name-value pair to the name of the application that sent the log message. Currently it uses the following procedures.
Parsing RFC3164-formatted messages
For RFC3164-formatted messages (that is, messages received on the ports set in options udp-port()
and tcp-port()
which default to port 514), AxoSyslog attempts to use the following parsers. If a parser cannot parse the message, it passes the original message to the next parser.
-
Parse the incoming raw message as a message from a Cisco device.
-
Parse the incoming message as an RFC3164-formatted message.
-
If the incoming message was sent by a AxoSyslog client using the
syslog-ng()
destination, parse its fields as a AxoSyslog message.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 thedefault-network-drivers()
source on the receiver side. -
Otherwise, apply the application adapters if the message was sent from an application that already has a specific parser in AxoSyslog (for example, Splunk Common Information Model (CIM), iptables, or sudo).
-
Parsing RFC5424-formatted messages
For RFC5424-formatted messages (that is, messages received on the ports set in options rfc5424-tls-port()
and rfc5424-tcp-port()
, which default to port 601 and 6514), AxoSyslog parses the message according to RFC5424, then attempts apply the application adapters if the message was sent from an application that already has a specific parser in AxoSyslog (for example, Splunk Common Information Model (CIM), iptables, or sudo).
Example: Using the default-network-drivers() driver
The following example uses only the default settings.
source s_network {
default-network-drivers();
};
The following example can receive TLS-encrypted connections on the default port (port 6514).
source s_network {
default-network-drivers(
tls(
key-file("/path/to/ssl-private-key")
cert-file("/path/to/ssl-cert")
)
);
};
4.1 - default-network-drivers() source options
The systemd-journal()
driver has the following options.
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
.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
log-iw-size()
Type: | number |
Default: | 100 |
Description: The size of the initial window, this value is used during flow-control. Its value cannot be lower than 100, unless the dynamic-window-size()
option is enabled. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
log-msg-size()
Type: | number (bytes) |
Default: | Use the global log-msg-size() option, which defaults to 65536 (64 KiB). |
Description: Maximum length of an incoming message in bytes. This length includes the entire message (the data structure and individual fields). The maximal value that can be set is 268435456 bytes (256 MiB).
For messages using the IETF-syslog message format (RFC5424), the maximal size of the value of an SDATA field is 64 KiB.
log-msg-size()
does not need to be set higher than 10 MiB.
For details on how encoding affects the size of the message, see Message size and encoding.
You can use human-readable units when setting configuration options. For details, seeNotes about the configuration syntax.
Uses the value of the global option if not specified.
max-connections()
Type: | number |
Default: | 10 |
Description: Specifies the maximum number of simultaneous connections.
Note that the total number of connections the default-network-drivers()
source can use is 3*max-connections()
, because this value applies to the network(tcp)
, syslog(tcp)
, and syslog(tls)
connections individually.
rfc5424-tcp-port()
Type: | number |
Default: | 601 |
Description: The TCP port number where the default-network-drivers()
source receives RFC5424-formatted (IETF-syslog) messages.
rfc5424-tls-port()
Type: | number |
Default: | 6514 |
Description: The TCP port number where the default-network-drivers()
source receives RFC5424-formatted (IETF-syslog), TLS-encrypted messages.
To receive messages using a TLS-encrypted connection, you must set the tls(key-file() cert-file())
options of the default-network-drivers()
source. For example:
source s_network {
default-network-drivers(
tls(
key-file("/path/to/ssl-private-key")
cert-file("/path/to/ssl-cert")
)
);
};
tcp-port()
Type: | number |
Default: | 514 |
Description: The TCP port number where the default-network-drivers()
source receives RFC3164-formatted (BSD-syslog) messages.
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.
udp-port()
Type: | number |
Default: | 514 |
Description: The UDP port number where the default-network-drivers()
source receives RFC3164-formatted (BSD-syslog) messages.
5 - internal: Collect internal messages
All messages generated internally by AxoSyslog use this special source. To collect warnings, errors and notices from AxoSyslog itself, include this source in one of your source statements.
internal()
The AxoSyslog application will issue a warning upon startup if none of the defined log paths reference this driver.
Example: Using the internal() driver
source s_local { internal(); };
The AxoSyslog application sends the following message types from the internal() source:
-
fatal: Priority value: critical (2), Facility value: syslog (5)
-
error: Priority value: error (3), Facility value: syslog (5)
-
warning: Priority value: warning (4), Facility value: syslog (5)
-
notice: Priority value: notice (5), Facility value: syslog (5)
-
info: Priority value: info (6), Facility value: syslog (5)
5.1 - internal() source options
The internal()
driver has the following options:
host-override()
Type: | string |
Default: |
Description: Replaces the ${HOST} part of the message with the parameter string.
log-iw-size()
Type: | number |
Default: | 100 |
Description: The size of the initial window, this value is used during flow-control. Its value cannot be lower than 100, unless the dynamic-window-size()
option is enabled. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
normalize-hostnames()
Accepted values: | yes , no |
Default: | no |
Description: If enabled (normalize-hostnames(yes)
), AxoSyslog converts the hostnames to lowercase.
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
use-fqdn()
Type: | yes or no |
Default: | no |
Description: Add Fully Qualified Domain Name instead of short hostname. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
6 - file: Collect messages from text files
Collects log messages from plain-text files, for example, from the logfiles of an Apache webserver. If you want to use wildcards in the filename, use the wildcard-file()
source.
The AxoSyslog application notices if a file is renamed or replaced with a new file, so it can correctly follow the file even if logrotation is used. When AxoSyslog is restarted, it records the position of the last sent log message in the /opt/syslog-ng/var/syslog-ng.persist/var/lib/syslog-ng/syslog-ng.persist
file, and continues to send messages from this position after the restart.
The file driver has a single required parameter specifying the file to open. If you want to use wildcards in the filename, use the wildcard-file()
source. For the list of available optional parameters, see file() source options.
Declaration:
file("filename");
Example: Using the file() driver
source s_file {
file("/var/log/messages");
};
Example: Tailing files
The following source checks the access.log
file every second for new messages.
source s_tail {
file("/var/log/apache/access.log" follow-freq(1) flags(no-parse));
};
kern
facility. Use the default-facility()
and default-priority()
options in the source definition to assign a different facility if needed.
6.1 - Notes on reading kernel messages
Note the following points when reading kernel messages on various platforms.
-
The kernel usually sends log messages to a special file (
/dev/kmsg
on BSDs,/proc/kmsg
on Linux). Thefile()
driver reads log messages from such files. The AxoSyslog application can periodically check the file for new log messages if thefollow-freq()
option is set. -
On Linux, the
klogd
daemon can be used in addition to AxoSyslog to read kernel messages and forward them tosyslog-ng
.klogd
used to preprocess kernel messages to resolve symbols and so on, but as this is deprecated byksymoops
there is really no point in running bothklogd
and AxoSyslog in parallel. Also note that running two processes reading/proc/kmsg
at the same time might result in dead-locks. -
When using AxoSyslog to read messages from the
/proc/kmsg
file, AxoSyslog automatically disables thefollow-freq()
parameter to avoid blocking the file. -
To read the kernel messages on HP-UX platforms, use the following options in the source statement:
file("/dev/klog" program-override("kernel") flags(kernel) follow-freq(0));
6.2 - file() source options
The file()
driver has the following options:
check-hostname()
Type: | boolean (yes or no ) |
Default: | Use the global check-hostname() option, which defaults to no . |
Description:
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
Uses the value of the global option if not specified.
default-facility()
Type: | facility string |
Default: | kern |
Description: This parameter assigns a facility value to the messages received from the file source if the message does not specify one.
default-priority()
Type: | priority string |
Default: |
Description: This parameter assigns an emergency level to the messages received from the file source if the message does not specify one. For example, default-priority(warning)
.
encoding()
Type: | string |
Default: |
Description: Specifies the character set (encoding, for example, UTF-8
) of messages using the legacy BSD-syslog protocol. To list the available character sets on a host, execute the iconv -l
command. For details on how encoding affects the size of the message, see Message size and encoding.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
follow-freq()
Type: | number |
Default: | 1 |
Description: Indicates that the source should be checked periodically. This is useful for files which always indicate readability, even though no new lines were appended. If this value is higher than zero, AxoSyslog will not attempt to use poll()
on the file, but checks whether the file changed every time the follow-freq()
interval (in seconds) has elapsed. Floating-point numbers (for example, 1.5
) can be used as well.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
idle-timeout()
Accepted values: | number [seconds] |
Default: | 0 (disabled) |
Available in AxoSyslog 4.9 and later.
If set, AxoSyslog closes the client connection if no data is received for the specified amount of time (in seconds).
keep-timestamp()
Type: | yes or no |
Default: | yes |
Description: Specifies whether AxoSyslog should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
S_
macros, the keep-timestamp()
option must be enabled (this is the default behavior of AxoSyslog).
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
log-iw-size()
Type: | number |
Default: | 10000 |
Description: The size of the initial window, this value is used during flow control. Make sure that log-iw-size()
is larger than the value of log-fetch-limit()
.
log-msg-size()
Type: | number (bytes) |
Default: | Use the global log-msg-size() option, which defaults to 65536 (64 KiB). |
Description: Maximum length of an incoming message in bytes. This length includes the entire message (the data structure and individual fields). The maximal value that can be set is 268435456 bytes (256 MiB).
For messages using the IETF-syslog message format (RFC5424), the maximal size of the value of an SDATA field is 64 KiB.
log-msg-size()
does not need to be set higher than 10 MiB.
For details on how encoding affects the size of the message, see Message size and encoding.
You can use human-readable units when setting configuration options. For details, seeNotes about the configuration syntax.
Uses the value of the global option if not specified.
log-prefix() (DEPRECATED)
Type: | string |
Default: |
Description: A string added to the beginning of every log message. It can be used to add an arbitrary string to any log source, though it is most commonly used for adding kernel:
to the kernel messages on Linux.
program-override
instead.
multi-line-garbage()
Type: | regular expression |
Default: | empty string |
Description: Use the multi-line-garbage()
option when processing multi-line messages that contain unneeded parts between the messages. Specify a string or regular expression that matches the beginning of the unneeded message parts. If the multi-line-garbage()
option is set, AxoSyslog ignores the lines between the line matching the multi-line-garbage()
and the next line matching multi-line-prefix()
. See also the multi-line-prefix()
option.
When receiving multi-line messages from a source when the multi-line-garbage()
option is set, but no matching line is received between two lines that match multi-line-prefix()
, AxoSyslog will continue to process the incoming lines as a single message until a line matching multi-line-garbage()
is received.
To use the multi-line-garbage()
option, set the multi-line-mode()
option to prefix-garbage
.
multi-line-garbage()
option is set, AxoSyslog discards lines between the line matching the multi-line-garbage()
and the next line matching multi-line-prefix()
.
multi-line-mode()
Type: | indented , prefix-garbage , prefix-suffix , regexp , smart |
Default: | empty string |
Description: Use the multi-line-mode()
option when processing multi-line messages. The AxoSyslog application provides the following methods to process multi-line messages:
-
indented
: Theindented
mode can process messages where each line that belongs to the previous line is indented by whitespace, and the message continues until the first non-indented line. For example, the Linux kernel (starting with version 3.5) uses this format for/dev/log
, as well as several applications, like Apache Tomcat.source s_tomcat { file("/var/log/tomcat/xxx.log" multi-line-mode(indented)); };
-
prefix-garbage
: The prefix-garbage mode uses a string or regular expression (set inmulti-line-prefix()
) that matches the beginning of the log messages, ignores newline characters from the source until a line matches the regular expression again, and treats the lines between the matching lines as a single message. For details on usingmulti-line-mode(prefix-garbage)
, see themulti-line-prefix()
andmulti-line-garbage()
options. -
prefix-suffix
: Theprefix-suffix
mode uses a string or regular expression (set inmulti-line-prefix()
) that matches the beginning of the log messages, ignores newline characters from the source until a line matches the regular expression set inmulti-line-suffix()
, and treats the lines betweenmulti-line-prefix()
andmulti-line-suffix()
as a single message. Any other lines between the end of the message and the beginning of a new message (that is, a line that matches themulti-line-prefix()
expression) are discarded. For details on usingmulti-line-mode(prefix-suffix)
, see themulti-line-prefix()
andmulti-line-suffix()
options.The
prefix-suffix
mode is similar to theprefix-garbage
mode, but it appends the garbage part to the message instead of discarding it. -
smart
: Thesmart
mode recognizes multi-line data backtraces even if they span multiple lines in the input. The backtraces are converted to a single log message for easier analysis. Backtraces for the following programming languages are recognized : Python, Java, JavaScript, PHP, Go, Ruby, and Dart.smart
mode is available in AxoSyslog version 4.2 and newer.The regular expressions to recognize these programming languages are specified in an external file called
/usr/share/syslog-ng/smart-multi-line.fsm
(installation path depends on configure arguments), in a format that is described in that file.
To format multi-line messages to your individual needs, consider the following:
-
To make multi-line messages more readable when written to a file, use a template in the destination and instead of the
${MESSAGE}
macro, use the following:$(indent-multi-line ${MESSAGE})
. This expression inserts a tab after every newline character (except when a tab is already present), indenting every line of the message after the first. For example:destination d_file { file ("/var/log/messages" template("${ISODATE} ${HOST} $(indent-multi-line ${MESSAGE})\n") ); };
For details on using templates, see Templates and macros.
-
To actually convert the lines of multi-line messages to single line (by replacing the newline characters with whitespaces), use the
flags(no-multi-line)
option in the source.
multi-line-prefix()
Type: | regular expression starting with the ^ character |
Default: | empty string |
Description: Use the multi-line-prefix()
option to process multi-line messages, that is, log messages that contain newline characters (for example, Tomcat logs). Specify a string or regular expression that matches the beginning of the log messages (always start with the ^
character). Use as simple regular expressions as possible, because complex regular expressions can severely reduce the rate of processing multi-line messages. If the multi-line-prefix()
option is set, AxoSyslog ignores newline characters from the source until a line matches the regular expression again, and treats the lines between the matching lines as a single message. See also the multi-line-garbage()
option.
To format multi-line messages to your individual needs, consider the following:
-
To make multi-line messages more readable when written to a file, use a template in the destination and instead of the
${MESSAGE}
macro, use the following:$(indent-multi-line ${MESSAGE})
. This expression inserts a tab after every newline character (except when a tab is already present), indenting every line of the message after the first. For example:destination d_file { file ("/var/log/messages" template("${ISODATE} ${HOST} $(indent-multi-line ${MESSAGE})\n") ); };
For details on using templates, see Templates and macros.
-
To actually convert the lines of multi-line messages to single line (by replacing the newline characters with whitespaces), use the
flags(no-multi-line)
option in the source.
Example: Processing Tomcat logs
The log messages of the Apache Tomcat server are a typical example for multi-line log messages. The messages start with the date and time of the query in the YYYY.MM.DD HH:MM:SS
format, as you can see in the following example.
2010.06.09. 12:07:39 org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start:
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: java.net.BindException: Address already in use null:8080
at org.apache.catalina.connector.Connector.start(Connector.java:1138)
at org.apache.catalina.core.StandardService.start(StandardService.java:531)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
2010.06.09. 12:07:39 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1206 ms
2010.06.09. 12:45:08 org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
2010.06.09. 12:45:09 org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
To process these messages, specify a regular expression matching the timestamp of the messages in the multi-line-prefix()
option. Such an expression is the following:
source s_file{file("/var/log/tomcat6/catalina.2010-06-09.log" follow-freq(0) multi-line-mode(regexp) multi-line-prefix("[0-9]{4}\.[0-9]{2}\.[0-9]{2}\.") flags(no-parse));};
};
Note that flags(no-parse)
is needed to prevent AxoSyslog trying to interpret the date in the message.
multi-line-suffix()
Type: | regular expression |
Default: | empty string |
Description: Use the multi-line-suffix()
option when processing multi-line messages. Specify a string or regular expression that matches the end of the multi-line message.
To use the multi-line-suffix()
option, set the multi-line-mode()
option to prefix-suffix
. See also the multi-line-prefix()
option.
pad-size()
Type: | number |
Default: | 0 |
Description: Specifies input padding. Some operating systems (such as HP-UX) pad all messages to block boundary. This option can be used to specify the block size. The AxoSyslog application will pad reads from the associated device to the number of bytes set in pad-size()
. Mostly used on HP-UX where /dev/log
is a named pipe and every write is padded to 2048 bytes. If pad-size()
was given and the incoming message does not fit into pad-size()
, AxoSyslog will not read anymore from this pipe and displays the following error message:
Padding was set, and couldn't read enough bytes
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
7 - wildcard-file: Collect messages from multiple text files
The wildcard-file()
source collects log messages from multiple plain-text files from multiple directories. The wildcard-file()
source is available in AxoSyslog version 3.10 and later.
The AxoSyslog application notices if a file is renamed or replaced with a new file, so it can correctly follow the file even if logrotation is used. When AxoSyslog is restarted, it records the position of the last sent log message in the persist file, and continues to send messages from this position after the restart. The location of the persist file depends on how you installed AxoSyslog, typically it is /var/lib/syslog-ng/syslog-ng.persist
or /opt/syslog-ng/var/syslog-ng.persist
.
Declaration:
wildcard-file(
base-dir("<pathname>")
filename-pattern("<filename>")
);
Note the following important points:
- You can use the
*
and?
wildcard characters in the filename (thefilename-pattern()
option), but not in the path (thebase-dir()
option). -
If you use multiple
wildcard-file()
sources in your configuration, make sure that the files and folders that match the wildcards do not overlap. That is, every file and folder should belong to only one file source. Monitoring a file from multiple wildcard sources can lead to data loss. -
When using wildcards, AxoSyslog monitors every matching file (up to the limit set in the
max-files()
option), and can receive new log messages from any of the files. However, monitoring (polling) many files (that is, more than ten) has a significant overhead and may affect performance. On Linux this overhead is not so significant, because AxoSyslog uses the inotify feature of the kernel. Set themax-files()
option at least to the number of files you want to monitor. If the wildcard-file source matches more files than the value of themax-files()
option, it is random which files will AxoSyslog actually monitor. The default value ofmax-files()
is 100. - If the message does not have a proper syslog header, AxoSyslog treats messages received from files as sent by the
user
facility. Use thedefault-facility()
anddefault-priority()
options in the source definition to assign a different facility if needed. - For every message that AxoSyslog reads from the source files, the path and name of the file is available in the
${FILE_NAME}
macro.
Required parameters: base-dir()
, filename-pattern()
. For the list of available optional parameters, see wildcard-file() source options.
Example: Using the wildcard-file() driver
The following example monitors every file with the .log
extension in the /var/log
directory for log messages.
source s_files {
wildcard-file(
base-dir("/var/log")
filename-pattern("*.log")
recursive(no)
follow-freq(1)
);
};
7.1 - wildcard-file() source options
The wildcard-file()
driver has the following options:
base-dir()
Type: | path without filename |
Default: |
Description: The path to the directory that contains the log files to monitor, for example, base-dir("/var/log")
. To monitor also the subdirectories of the base directory, use the recursive(yes)
option. For details, see recursive().
If you use multiple wildcard-file()
sources in your configuration, make sure that the files and folders that match the wildcards do not overlap. That is, every file and folder should belong to only one file source. Monitoring a file from multiple wildcard sources can lead to data loss.
source s_files {
wildcard-file(
base-dir("/var/log")
filename-pattern("*.log")
recursive(no)
follow-freq(1)
);
};
check-hostname()
Type: | boolean (yes or no ) |
Default: | Use the global check-hostname() option, which defaults to no . |
Description:
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
Uses the value of the global option if not specified.
default-facility()
Type: | facility string |
Default: | kern |
Description: This parameter assigns a facility value to the messages received from the file source if the message does not specify one.
default-priority()
Type: | priority string |
Default: |
Description: This parameter assigns an emergency level to the messages received from the file source if the message does not specify one. For example, default-priority(warning)
.
encoding()
Type: | string |
Default: |
Description: Specifies the character set (encoding, for example, UTF-8
) of messages using the legacy BSD-syslog protocol. To list the available character sets on a host, execute the iconv -l
command. For details on how encoding affects the size of the message, see Message size and encoding.
filename-pattern()
Type: | filename without path |
Default: |
Description: The filename to read messages from, without the path. You can use the *
and ?
wildcard characters, without regular expression and character range support. You cannot use the *
and ?
literally in the pattern.
For example, filename-pattern("*.log")
matches the syslog.log
and auth.log
files, but does not match the access_log
file. The filename-pattern("*log")
pattern matches all three.
*
matches an arbitrary string, including an empty string?
matches an arbitrary character
If you use multiple wildcard-file()
sources in your configuration, make sure that the files and folders that match the wildcards do not overlap. That is, every file and folder should belong to only one file source. Monitoring a file from multiple wildcard sources can lead to data loss.
source s_files {
wildcard-file(
base-dir("/var/log")
filename-pattern("*.log")
recursive(no)
follow-freq(1)
);
};
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
follow-freq()
Type: | number |
Default: | 1 |
Description: Indicates that the source should be checked periodically. This is useful for files which always indicate readability, even though no new lines were appended. If this value is higher than zero, AxoSyslog will not attempt to use poll()
on the file, but checks whether the file changed every time the follow-freq()
interval (in seconds) has elapsed. Floating-point numbers (for example, 1.5
) can be used as well.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
idle-timeout()
Accepted values: | number [seconds] |
Default: | 0 (disabled) |
Available in AxoSyslog 4.9 and later.
If set, AxoSyslog closes the client connection if no data is received for the specified amount of time (in seconds).
keep-timestamp()
Type: | yes or no |
Default: | yes |
Description: Specifies whether AxoSyslog should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
S_
macros, the keep-timestamp()
option must be enabled (this is the default behavior of AxoSyslog).
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
log-iw-size()
Type: | number |
Default: | 10000 |
Description: The size of the initial window, this value is used during flow control. Make sure that log-iw-size()
is larger than the value of log-fetch-limit()
.
When using wildcards in the filenames, AxoSyslog attempts to read log-fetch-limit()
number of messages from each file. For optimal performance, make sure that log-iw-size()
is greater than log-fetch-limit()*max-files()
. Note that to avoid performance problems, if log-iw-size()/max-files()
is smaller than 100, AxoSyslog automatically sets log-iw-size()
to max-files()*100
.
Example: Initial window size of file sources
If log-fetch-limit()
is 100, and your wildcard file source has 200 files, then log-iw-size()
should be at least 20000.
log-msg-size()
Type: | number (bytes) |
Default: | Use the global log-msg-size() option, which defaults to 65536 (64 KiB). |
Description: Maximum length of an incoming message in bytes. This length includes the entire message (the data structure and individual fields). The maximal value that can be set is 268435456 bytes (256 MiB).
For messages using the IETF-syslog message format (RFC5424), the maximal size of the value of an SDATA field is 64 KiB.
log-msg-size()
does not need to be set higher than 10 MiB.
For details on how encoding affects the size of the message, see Message size and encoding.
You can use human-readable units when setting configuration options. For details, seeNotes about the configuration syntax.
Uses the value of the global option if not specified.
log-prefix() (DEPRECATED)
Type: | string |
Default: |
Description: A string added to the beginning of every log message. It can be used to add an arbitrary string to any log source, though it is most commonly used for adding kernel:
to the kernel messages on Linux.
program-override
instead.
max-files()
Type: | integer |
Default: | 100 |
Description: Limits the number of files that the wildcard-file source monitors.
When using wildcards, AxoSyslog monitors every matching file (up to the limit set in the max-files()
option), and can receive new log messages from any of the files. However, monitoring (polling) many files (that is, more than ten) has a significant overhead and may affect performance. On Linux this overhead is not so significant, because AxoSyslog uses the inotify feature of the kernel. Set the max-files()
option at least to the number of files you want to monitor. If the wildcard-file source matches more files than the value of the max-files()
option, it is random which files will AxoSyslog actually monitor. The default value of max-files()
is 100.
monitor-method()
Type: | `auto |
Default: | auto |
Description: If the platform supports inotify, AxoSyslog uses it automatically to detect changes to the source files. If inotify is not available, AxoSyslog polls the files as set in the follow-freq()
option. To force AxoSyslog poll the files even if inotify is available, set this option to poll
.
multi-line-garbage()
Type: | regular expression |
Default: | empty string |
Description: Use the multi-line-garbage()
option when processing multi-line messages that contain unneeded parts between the messages. Specify a string or regular expression that matches the beginning of the unneeded message parts. If the multi-line-garbage()
option is set, AxoSyslog ignores the lines between the line matching the multi-line-garbage()
and the next line matching multi-line-prefix()
. See also the multi-line-prefix()
option.
When receiving multi-line messages from a source when the multi-line-garbage()
option is set, but no matching line is received between two lines that match multi-line-prefix()
, AxoSyslog will continue to process the incoming lines as a single message until a line matching multi-line-garbage()
is received.
To use the multi-line-garbage()
option, set the multi-line-mode()
option to prefix-garbage
.
multi-line-garbage()
option is set, AxoSyslog discards lines between the line matching the multi-line-garbage()
and the next line matching multi-line-prefix()
.
multi-line-mode()
Type: | indented , prefix-garbage , prefix-suffix , regexp , smart |
Default: | empty string |
Description: Use the multi-line-mode()
option when processing multi-line messages. The AxoSyslog application provides the following methods to process multi-line messages:
-
indented
: Theindented
mode can process messages where each line that belongs to the previous line is indented by whitespace, and the message continues until the first non-indented line. For example, the Linux kernel (starting with version 3.5) uses this format for/dev/log
, as well as several applications, like Apache Tomcat.source s_tomcat { file("/var/log/tomcat/xxx.log" multi-line-mode(indented)); };
-
prefix-garbage
: The prefix-garbage mode uses a string or regular expression (set inmulti-line-prefix()
) that matches the beginning of the log messages, ignores newline characters from the source until a line matches the regular expression again, and treats the lines between the matching lines as a single message. For details on usingmulti-line-mode(prefix-garbage)
, see themulti-line-prefix()
andmulti-line-garbage()
options. -
prefix-suffix
: Theprefix-suffix
mode uses a string or regular expression (set inmulti-line-prefix()
) that matches the beginning of the log messages, ignores newline characters from the source until a line matches the regular expression set inmulti-line-suffix()
, and treats the lines betweenmulti-line-prefix()
andmulti-line-suffix()
as a single message. Any other lines between the end of the message and the beginning of a new message (that is, a line that matches themulti-line-prefix()
expression) are discarded. For details on usingmulti-line-mode(prefix-suffix)
, see themulti-line-prefix()
andmulti-line-suffix()
options.The
prefix-suffix
mode is similar to theprefix-garbage
mode, but it appends the garbage part to the message instead of discarding it. -
smart
: Thesmart
mode recognizes multi-line data backtraces even if they span multiple lines in the input. The backtraces are converted to a single log message for easier analysis. Backtraces for the following programming languages are recognized : Python, Java, JavaScript, PHP, Go, Ruby, and Dart.smart
mode is available in AxoSyslog version 4.2 and newer.The regular expressions to recognize these programming languages are specified in an external file called
/usr/share/syslog-ng/smart-multi-line.fsm
(installation path depends on configure arguments), in a format that is described in that file.
To format multi-line messages to your individual needs, consider the following:
-
To make multi-line messages more readable when written to a file, use a template in the destination and instead of the
${MESSAGE}
macro, use the following:$(indent-multi-line ${MESSAGE})
. This expression inserts a tab after every newline character (except when a tab is already present), indenting every line of the message after the first. For example:destination d_file { file ("/var/log/messages" template("${ISODATE} ${HOST} $(indent-multi-line ${MESSAGE})\n") ); };
For details on using templates, see Templates and macros.
-
To actually convert the lines of multi-line messages to single line (by replacing the newline characters with whitespaces), use the
flags(no-multi-line)
option in the source.
multi-line-prefix()
Type: | regular expression starting with the ^ character |
Default: | empty string |
Description: Use the multi-line-prefix()
option to process multi-line messages, that is, log messages that contain newline characters (for example, Tomcat logs). Specify a string or regular expression that matches the beginning of the log messages (always start with the ^
character). Use as simple regular expressions as possible, because complex regular expressions can severely reduce the rate of processing multi-line messages. If the multi-line-prefix()
option is set, AxoSyslog ignores newline characters from the source until a line matches the regular expression again, and treats the lines between the matching lines as a single message. See also the multi-line-garbage()
option.
To format multi-line messages to your individual needs, consider the following:
-
To make multi-line messages more readable when written to a file, use a template in the destination and instead of the
${MESSAGE}
macro, use the following:$(indent-multi-line ${MESSAGE})
. This expression inserts a tab after every newline character (except when a tab is already present), indenting every line of the message after the first. For example:destination d_file { file ("/var/log/messages" template("${ISODATE} ${HOST} $(indent-multi-line ${MESSAGE})\n") ); };
For details on using templates, see Templates and macros.
-
To actually convert the lines of multi-line messages to single line (by replacing the newline characters with whitespaces), use the
flags(no-multi-line)
option in the source.
Example: Processing Tomcat logs
The log messages of the Apache Tomcat server are a typical example for multi-line log messages. The messages start with the date and time of the query in the YYYY.MM.DD HH:MM:SS
format, as you can see in the following example.
2010.06.09. 12:07:39 org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start:
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: java.net.BindException: Address already in use null:8080
at org.apache.catalina.connector.Connector.start(Connector.java:1138)
at org.apache.catalina.core.StandardService.start(StandardService.java:531)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
2010.06.09. 12:07:39 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1206 ms
2010.06.09. 12:45:08 org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
2010.06.09. 12:45:09 org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
To process these messages, specify a regular expression matching the timestamp of the messages in the multi-line-prefix()
option. Such an expression is the following:
source s_file{file("/var/log/tomcat6/catalina.2010-06-09.log" follow-freq(0) multi-line-mode(regexp) multi-line-prefix("[0-9]{4}\.[0-9]{2}\.[0-9]{2}\.") flags(no-parse));};
};
Note that flags(no-parse)
is needed to prevent AxoSyslog trying to interpret the date in the message.
multi-line-suffix()
Type: | regular expression |
Default: | empty string |
Description: Use the multi-line-suffix()
option when processing multi-line messages. Specify a string or regular expression that matches the end of the multi-line message.
To use the multi-line-suffix()
option, set the multi-line-mode()
option to prefix-suffix
. See also the multi-line-prefix()
option.
pad-size()
Type: | number |
Default: | 0 |
Description: Specifies input padding. Some operating systems (such as HP-UX) pad all messages to block boundary. This option can be used to specify the block size. The AxoSyslog application will pad reads from the associated device to the number of bytes set in pad-size()
. Mostly used on HP-UX where /dev/log
is a named pipe and every write is padded to 2048 bytes. If pad-size()
was given and the incoming message does not fit into pad-size()
, AxoSyslog will not read anymore from this pipe and displays the following error message:
Padding was set, and couldn't read enough bytes
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
recursive()
Type: | yes or no |
Default: | no |
Description: When enabled, AxoSyslog monitors every subdirectory of the path set in the base-dir() option, and reads log messages from files with matching filenames. The recursive
option can be used together with wildcards in the filename.
If you use multiple wildcard-file()
sources in your configuration, make sure that the files and folders that match the wildcards do not overlap. That is, every file and folder should belong to only one file source. Monitoring a file from multiple wildcard sources can lead to data loss.
Example: Monitoring multiple directories
The following example reads files having the .log
extension from the /var/log/
directory and its subdirectories, including for example, the /var/log/apt/history.log
file.
source s_file_subdirectories {
wildcard-file(
base-dir("/var/log")
filename-pattern("*.log")
recursive(yes)
follow-freq(1)
log-fetch-limit(100)
);
};
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
8 - Hypr Audit Trail and Hypr App Audit Trail
Starting with version 4.2.0, AxoSyslog can fetch events from the Hypr REST API using the hypr-audit-trail()
and hypr-app-audit-trail()
source drivers.
hypr-audit-trail()
: is a source driver that pulls messages from the Hypr API, associated to any RP Application ID.hypr-app-audit-trail()
: is a source driver that pulls messages from the Hypr API, but only those associated to a specific RP Application ID.
Hypr Audit Trail
The hypr-audit-trail()
source queries the Hypr API for the list of potential applications at startup, then monitors the audit trail for each of the detected applications.
Note: Applications that are registered after
syslog-ng
is started are not recognized.
To start following those audit trails, you must restart syslog-ng
.
Example minimal configuration:
source s_hypr {
hypr-audit-trail(
url('https://<custom domain>.hypr.com')
bearer-token('<base64 encoded bearer token>')
);
};
A more detailed example:
source s_hypr {
hypr-audit-trail(
url('https://<custom domain>.hypr.com')
bearer-token('<base64 encoded bearer token>')
page-size(<number of results to return in a single page>)
initial-hours(<number of hours to search backward on initial fetch>)
application-skip-list('HYPRDefaultApplication', 'HYPRDefaultWorkstationApplication')
log-level('INFO')
flags(<optional flags passed to the source>)
ignore-persistence(<yes/no>)
);
};
Available options:
url()
: custom URL for Hypr API access ('https://<custom domain>.hypr.com'
)bearer-token()
: base64 encoded authentication token from Hyprpage-size()
: number of results to return in a single page (optional - defaults to100
)initial-hours()
: number of hours to search backward on initial fetch (optional - defaults to4
)application-skip-list()
: list of rpAppIds not to retrieve from Hypr (optional - defaults to'HYPRDefaultApplication', 'HYPRDefaultWorkstationApplication'
)log-level()
: logging level, possible values:"DEBUG"
,"INFO"
,"WARNING"
,"ERROR"
,"CRITICAL"
(optional - defaults to"INFO"
)flags()
: flags passed to the source, can be used for example to disable message parsing withflags(no-parse)
(optional - defaults to empty)ignore-persistence()
: ignores the saved value in the persist file, and starts querying from the current time (optional - defaults to no)
Hypr App Audit Trail
The hypr-app-audit-trail()
monitors the audit trail for one specific RP Application ID. This driver requires the rp-app-id()
parameter in order to operate.
Available options:
url()
: custom URL for Hypr API access ('https://<custom domain>.hypr.com'
)bearer-token()
: base64 encoded authentication token from Hyprrp-app-id()
: the RP Application ID for the application to monitorpage-size()
: number of results to return in a single page (optional - defaults to100
)initial-hours()
: number of hours to search backward on initial fetch (optional - defaults to4
)log-level()
: logging level, possible values:"DEBUG"
,"INFO"
,"WARNING"
,"ERROR"
,"CRITICAL"
(optional - defaults to"INFO"
)flags()
: flags passed to the source, can be used for example to disable message parsing withflags(no-parse)
(optional - defaults to empty)ignore-persistence()
: ignores the saved value in the persist file, and starts querying from the current time (optional - defaults tono
)
Acknowledgements
This documentation page is based on the README file of the hypr-audit-trail()
source, written by Dan Elder.
9 - Jellyfin logs
Starting with version 4.7.0, you can use the jellyfin()
source to read Jellyfin logs from its log file output.
Example minimal configuration:
source s_jellyfin {
jellyfin(
base-dir("/path/to/my/jellyfin/root/log/dir")
filename-pattern("log_*.log")
);
};
For more details about Jellyfin logging, see:
- https://jellyfin.org/docs/general/administration/configuration/#main-configuration
- https://jellyfin.org/docs/general/administration/configuration/#log-directory
As the jellyfin()
source is based on the wildcard-file()
source, you can use the wildcard-file()
source options.
This driver is actually a reusable configuration snippet. For details on using or writing such configuration snippets, see Reusing configuration blocks. You can find the source of this configuration snippet on GitHub.
10 - linux-audit: Collect messages from Linux audit logs
It reads and automatically parses the Linux audit logs. You can override the file name using the filename() parameter and the prefix for the created name-value pairs using the prefix() parameter. Any additional parameters are passed to the file source.
Declaration:
linux-audit(options);
Example: Using the linux-audit() driver
source s_auditd {
linux-audit(
prefix("test.")
hook-commands(
startup("auditctl -w /etc/ -p wa")
shutdown("auditctl -W /etc/ -p wa")
)
);
};
10.1 - linux-audit() source options
The file()
driver has the following options:
filename()
Type: | path |
Default: |
Description: The log file of linux-audit
. The AxoSyslog application reads the Linux audit logs from this file.
prefix()
Synopsis: | prefix() |
Default: | .auditd. |
Description: Insert a prefix before the name part of the parsed name-value pairs to help further processing. For example:
-
To insert the
my-parsed-data.
prefix, use theprefix(my-parsed-data.)
option. -
To refer to a particular data that has a prefix, use the prefix in the name of the macro, for example,
${my-parsed-data.name}
. -
If you forward the parsed messages using the IETF-syslog protocol, you can insert all the parsed data into the SDATA part of the message using the
prefix(.SDATA.my-parsed-data.)
option.
Names starting with a dot (for example, .example
) are reserved for use by AxoSyslog. Note that if you use an empty prefix (prefix("")
) or one starting with a dot, AxoSyslog might replace the original value of an existing macro (note that only soft macros can be overwritten, see Hard versus soft macros for details). To avoid such problems, use a prefix when naming the parsed values, for example, prefix(my-parsed-data.)
11 - kubernetes: Collect and parse the Kubernetes CRI (Container Runtime Interface) format
The kubernetes()
source collects container logs managed by the Kubelet. It reads plain-text and JSON-formatted container logs (as described in the Container Runtime Interface (CRI) design proposal), for example, from the /var/log/containers
or /var/log/pods
files, and enriches them with various metadata retrieved from the Kubernetes API.
The kubernetes()
source is available in AxoSyslog version 3.37 and later.
By default, it reads the /var/log/containers
folder and extracts:
- the log content, and
- Kubernetes metadata, for example, namespace, pod, and container information.
The Kubernetes-related metadata is available in name-value pairs with the .k8s.
prefix. The following table shows the retrieved metadata and their source:
syslog-ng name-value pair |
source |
---|---|
.k8s.namespace_name |
Container log file name. |
.k8s.pod_name |
Container log file name. |
.k8s.pod_uuid |
Container log file name or python kubernetes.client.CoreV1Api. |
.k8s.container_name |
Container log file name or python kubernetes.client.CoreV1Api. |
.k8s.container_id |
Container log file name. |
.k8s.container_image |
python kubernetes.client.CoreV1Api. |
.k8s.container_hash |
python kubernetes.client.CoreV1Api. |
.k8s.docker_id |
python kubernetes.client.CoreV1Api. |
.k8s.labels.* |
python kubernetes.client.CoreV1Api. |
.k8s.annotations.* |
python kubernetes.client.CoreV1Api. |
Declaration
kubernetes(
base-dir("<pathname>")
);
11.1 - kubernetes() source options
The kubernetes()
source has the following options:
base-dir()
Type: | path without filename |
Default: | /var/log/containers |
Description: The path to the directory that contains the log files, for example, base-dir("/var/log/pods")
.
cluster-name()
Type: | string |
Default: | k8s |
Description: The name of the Kubernetes cluster.
key-delimiter()
Type: | character |
Default: | . |
Description: The delimiter character to use when parsing flattened keys. Supports Only single characters.
prefix()
Synopsis: | prefix() |
Description: Insert a prefix before the name part of the parsed name-value pairs to help further processing. For example:
-
To insert the
my-parsed-data.
prefix, use theprefix(my-parsed-data.)
option. -
To refer to a particular data that has a prefix, use the prefix in the name of the macro, for example,
${my-parsed-data.name}
. -
If you forward the parsed messages using the IETF-syslog protocol, you can insert all the parsed data into the SDATA part of the message using the
prefix(.SDATA.my-parsed-data.)
option.
Names starting with a dot (for example, .example
) are reserved for use by AxoSyslog. If you use such a macro name as the name of a parsed value, it will attempt to replace the original value of the macro (note that only soft macros can be overwritten, see Hard versus soft macros for details). To avoid such problems, use a prefix when naming the parsed values, for example, prefix(my-parsed-data.)
The prefix()
option is optional and its default value is ".k8s."
.
12 - mbox: Convert local email messages to log messages
Using the mbox()
driver, AxoSyslog can read email messages from local mbox files, and convert them to multiline log messages.
This driver has only one required option, the filename of the mbox file. To use the mbox()
driver, the scl.conf
file must be included in your AxoSyslog configuration:
@include "scl.conf"
The mbox()
driver is actually a reusable configuration snippet configured to read log messages using the file()
driver. For details on using or writing such configuration snippets, see Reusing configuration blocks. You can find the source of the configuration snippet on GitHub.
Example: Using the mbox() driver
The following example reads the emails of the root user on the AxoSyslog host.
@include "scl.conf"
source root-mbox {
mbox("/var/spool/mail/root");
};
12.1 - mbox() source options
The mbox()
driver has the following option.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
13 - mqtt: receiving messages from an MQTT broker
From AxoSyslog version 3.35, you can use the mqtt()
source to fetch messages from MQTT brokers.
The mqtt()
source builds on the MQTT protocol, and uses its client and broker entities.
Declaration:
source s_mqtt{
mqtt(
address("tcp://<hostname>:<port-number>")
topic("<topic-name>")
);
};
Starting with AxoSyslog version 4.7, mqtt()
source automatically sets the ${MQTT_TOPIC}
name-value pair for the messages it receives. This is useful when the name of the topic contains MQTT wildcards ($
, +
, #
). For example:
log {
source { mqtt(topic("#")); };
destination { stdout(template("${MQTT_TOPIC} - ${MESSAGE}\n")); };
};
Example: Using the mqtt() source in your configuration
The following example illustrates an mqtt()
source configured to fetch messages from the MQTT broker running on localhost:4444
using the test/test topic
, and send them to the localhost:4445
address.
@version: current
@include "scl.conf"
source s_mqtt {
mqtt(
address("tcp://localhost:4444")
topic("test/test")
);
};
destination d_network {
network(
"localhost"
port(4445)
);
};
log {
source(s_mqtt);
destination(d_network);;
};
13.1 - Prerequisites to using the mqtt() source
Using the current implementation of the mqtt()
source has the following prerequisites:
-
Installing the
eclipse-paho-mqtt-c
library.Note The default package manager for some Linux operating systems contains theeclipse-paho-mqtt-c
library, but depending on your OS, you may have to install the library manually. For more information about how you can download and install theeclipse-paho-mqtt-c
library, see Eclipse Paho on the Eclipse Foundation website. -
Having a
broker
entity in a functional MQTT system.Note In your configuration, you will specify thebroker
entity of your MQTT system in theaddress()
option of yourmqtt()
source.
13.2 - Limitations to using the mqtt() source
Using the mqtt()
source of AxoSyslog has the following limitations:
- You can only use the
mqtt()
source with AxoSyslog version 3.35 or higher. - You cannot use the
mqtt()
source without installing the theeclipse-paho-mqtt-c
library. -
For more information about how you can download and install the
eclipse-paho-mqtt-c
library, see Eclipse Paho on the Eclipse Foundation website. - The current implementation of the
mqtt()
source supports versions 3.1 and 3.1.1 of the MQTT protocol
13.3 - Options of the mqtt() source
The mqtt()
source has the following options.
Required options: address()
, fallback-topic()
, and topic()
.
address()
Type: | string |
Default: | tcp://localhost:1883 |
Required: | yes |
Description: Specifies the hostname or IP address, and the port number of the MQTT broker to which AxoSyslog will send the log messages.
Syntax: <protocol type>://<host>:<port>
client-id()
Type: | string |
Default: | syslog-ng-source-{topic option} |
Required: | no |
Description: The client-id()
is used to identify the client to the MQTT server, which stores session data for each client. The session data can contains information regarding which message has been sent, received. It is not possible to set the client-id()
to an empty string. To always start a new session see the cleansession()
option.
cleansession()
Type: | yes or no |
Default: | no |
Description: This option instruments the MQTT broker to clean the session data when connecting. The session data contains information about which message was processed.
http-proxy()
Type: | URL |
Default: | N/A |
Description: Specifies HTTP/HTTPS proxy for WebSocket connections.
keep-alive()
Type: | positive integer number (in seconds) |
Default: | 60 |
Description: Specifies the number of seconds that AxoSyslog keeps the connection between the broker and clients open in case there is no message traffic. When keep-alive()
number of seconds pass, the connection is terminated, and you have to reconnect.
On the MQTT side, the keep alive function provides a workaround method to access connections that are still open.
password()
Type: | string |
Default: | N/A |
Description: The password used to authenticate on the MQTT broker.
persist-name()
Type: | string |
Default: | N/A |
Description: If you receive the following error message during AxoSyslog startup, set the persist-name()
option of the duplicate drivers:
Error checking the uniqueness of the persist names, please override it with persist-name option. Shutting down.
This error happens if you use identical drivers in multiple sources, for example, if you configure two file sources to read from the same file. In this case, set the persist-name()
of the drivers to a custom string, for example, persist-name("example-persist-name1")
.
qos()
Type: | number |
Default: | `0` |
Possible values: |
`0` - at most once (the fastest option) `1` - at least once (a much slower option than `0`) `2` - exactly once (the slowest option) |
Description: The Quality of Service (QoS) level in MQTT messaging is an agreement between sender and receiver on the guarantee of delivering a message.
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.
The following options are relevant for the mqtt()
tls()
block: ca-dir()
, ca-file()
, cert-file()
, cipher-suite()
, key-file()
, peer-verify()
, ssl-version()
, use-system-cert-store()
.
topic()
Type: | string or template |
Default: | N/A |
Description: Required option. Specifies the MQTT topic.
username()
Type: | string |
Default: | N/A |
Description: The username used to authenticate on the MQTT broker.
14 - network: Collect messages using the RFC3164 protocol (network() driver)
The network() source driver can receive syslog messages conforming to RFC3164 from the network using the TCP, TLS, and UDP networking protocols.
-
UDP is a simple datagram oriented protocol, which provides “best effort service” to transfer messages between hosts. It may lose messages, and no attempt is made to retransmit lost messages. The BSD-syslog protocol traditionally uses UDP.
Use UDP only if you have no other choice.
-
TCP provides connection-oriented service: the client and the server establish a connection, each message is acknowledged, and lost packets are resent. TCP can detect lost connections, and messages are lost, only if the TCP connection breaks. When a TCP connection is broken, messages that the client has sent but were not yet received on the server are lost.
-
The AxoSyslog application supports TLS (Transport Layer Security, also known as SSL) over TCP. For details, see Encrypting log messages with TLS.
Declaration:
network([options]);
By default, the network()
driver binds to 0.0.0.0
, meaning that it listens on every available IPV4 interface on the TCP/514 port. To limit accepted connections to only one interface, use the localip()
parameter. To listen on IPv6 addresses, use the ip-protocol(6)
option.
Example: Using the network() driver
Using only the default settings: listen on every available IPV4 interface on the TCP/514 port.
source s_network {
network();
};
UDP source listening on 192.168.1.1
(the default port for UDP is 514):
source s_network {
network(
ip("192.168.1.1")
transport("udp")
);
};
TCP source listening on the IPv6 localhost, port 2222:
source s_network6 {
network(
ip("::1")
transport("tcp")
port(2222)
ip-protocol(6)
);
};
A TCP source listening on a TLS-encrypted channel.
source s_network {
network(
transport("tls")
port(2222)
tls(peer-verify("required-trusted")
key-file("/opt/syslog-ng/etc/syslog-ng/syslog-ng.key")
cert-file("/opt/syslog-ng/etc/syslog-ng/syslog-ng.crt")
);
);
};
A TCP source listening for messages using the IETF-syslog message format. Note that for transferring IETF-syslog messages, generally you are recommended to use the syslog()
driver on both the client and the server, as it uses both the IETF-syslog message format and the protocol. For details, see syslog: Collect messages using the IETF-syslog protocol.
source s_tcp_syslog {
network(
ip("127.0.0.1")
flags(syslog-protocol)
);
};
For details on the options of the network()
source, see network() source options.
14.1 - network() source options
The network()
driver has the following options.
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
.
check-hostname()
Type: | boolean (yes or no ) |
Default: | Use the global check-hostname() option, which defaults to no . |
Description:
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
Uses the value of the global option if not specified.
dynamic-window-size()
Type: | number |
Default: | 0 |
Description: The size of the dynamic control window used during flow-control. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
ebpf()
Available in AxoSyslog version 4.2 and newer.
By default, the kernel chooses the receive socket for a specific UDP randomly based on the source IP/port of the sender. You can customize this algorithm using the Extended Berkeley Packet Filter (eBPF) plugin. The ebpf()
option changes the kernel’s SO_REUSEPORT algorithm so that all messages are randomly placed into one of the UDP sockets. The decision which UDP socket buffer a datagram is placed is made for every datagram, and not once for every stream. This means that messages are perfectly load-balanced across your set of UDP sockets. While this resolves the imbalance between the sockets and results in perfect load balancing, you will lose ordering between messages from the same sender, which is the price to pay for increased throughput.
source s_network {
network(
transport("udp")
so-reuseport(1) persist-name("udp1")
ebpf(reuseport(sockets(4)))
);
network(transport("udp") so-reuseport(1) persist-name("udp2"));
network(transport("udp") so-reuseport(1) persist-name("udp3"));
network(transport("udp") so-reuseport(1) persist-name("udp4"));
};
For a detailed introduction, see the Scaling syslog to 1M EPS with eBPF blog post.
encoding()
Type: | string |
Default: |
Description: Specifies the character set (encoding, for example, UTF-8
) of messages using the legacy BSD-syslog protocol. To list the available character sets on a host, execute the iconv -l
command. For details on how encoding affects the size of the message, see Message size and encoding.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
-
threaded: The
threaded
flag enables multithreading for the source. For details on multithreading, see Multithreading and scaling.Note Thesyslog
source uses multiple threads only if the source uses thetls
ortcp
transport protocols.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
host-override()
Type: | string |
Default: |
Description: Replaces the ${HOST} part of the message with the parameter string.
idle-timeout()
Accepted values: | number [seconds] |
Default: | 0 (disabled) |
Available in AxoSyslog 4.9 and later.
If set, AxoSyslog closes the client connection if no data is received for the specified amount of time (in seconds).
interface()
Type: | string |
Default: | None |
Description: Bind to the specified interface instead of an IP address. Available in 3.19 and later.
ip() or localip()
Type: | string |
Default: | 0.0.0.0 |
Description: The IP address to bind to. By default, AxoSyslog listens on every available interface. Note that this is not the address where messages are accepted from.
If you specify a multicast bind address and use the udp
transport, AxoSyslog automatically joins the necessary multicast group. TCP does not support multicasting.
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 sources should be closed when AxoSyslog is forced to reload its configuration (upon the receipt of a SIGHUP signal). Note that this applies to the server (source) side of the AxoSyslog connections, client-side (destination) connections are always reopened after receiving a HUP signal unless the keep-alive
option is enabled for the destination.
keep-hostname()
Type: | yes or no |
Default: | no |
Description: Enable or disable hostname rewriting.
-
If enabled (
keep-hostname(yes)
), AxoSyslog assumes that the incoming log message was sent by the host specified in theHOST
field of the message. -
If disabled (
keep-hostname(no)
), AxoSyslog rewrites theHOST
field of the message, either to the IP address (if theuse-dns()
parameter is set tono
), or to the hostname (if theuse-dns()
parameter is set toyes
and the IP address can be resolved to a hostname) of the host sending the message to AxoSyslog. For details on using name resolution in AxoSyslog, see Using name resolution in syslog-ng.
If the log message does not contain a hostname in its HOST
field, AxoSyslog automatically adds a hostname to the message.
-
For messages received from the network, this hostname is the address of the host that sent the message (this means the address of the last hop if the message was transferred via a relay).
-
For messages received from the local host, AxoSyslog adds the name of the host.
This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
keep-timestamp()
Type: | yes or no |
Default: | yes |
Description: Specifies whether AxoSyslog should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
S_
macros, the keep-timestamp()
option must be enabled (this is the default behavior of AxoSyslog).
listen-backlog()
Type: | integer |
Default: | 256 |
Description: Available only for stream based transports (unix-stream
, tcp
, tls
). In TCP, connections are treated incomplete until the three-way handshake is completed between the server and the client. Incomplete connection requests wait on the TCP port for the listener to accept the request. The listen-backlog()
option sets the maximum number of incomplete connection requests. For example:
source s_network {
network(
ip("192.168.1.1")
transport("tcp")
listen-backlog(2048)
);
};
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
log-iw-size()
Type: | number |
Default: | 100 |
Description: The size of the initial window, this value is used during flow-control. Its value cannot be lower than 100, unless the dynamic-window-size()
option is enabled. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
If the max-connections()
option is set, the log-iw-size()
will be divided by the number of connections, otherwise log-iw-size()
is divided by 10 (the default value of the max-connections()
option). The resulting number is the initial window size of each connection. For optimal performance when receiving messages from AxoSyslog clients, make sure that the window size is larger than the flush-lines()
option set in the destination of your clients.
Example: Initial window size of a connection
If log-iw-size(1000)
and max-connections(10)
, then each connection will have an initial window size of 100.
log-msg-size()
Type: | number (bytes) |
Default: | Use the global log-msg-size() option, which defaults to 65536 (64 KiB). |
Description: Maximum length of an incoming message in bytes. This length includes the entire message (the data structure and individual fields). The maximal value that can be set is 268435456 bytes (256 MiB).
For messages using the IETF-syslog message format (RFC5424), the maximal size of the value of an SDATA field is 64 KiB.
log-msg-size()
does not need to be set higher than 10 MiB.
For details on how encoding affects the size of the message, see Message size and encoding.
You can use human-readable units when setting configuration options. For details, seeNotes about the configuration syntax.
Uses the value of the global option if not specified.
max-connections()
Type: | number |
Default: | 10 |
Description: Specifies the maximum number of simultaneous connections.
pad-size()
Type: | number |
Default: | 0 |
Description: Specifies input padding. Some operating systems (such as HP-UX) pad all messages to block boundary. This option can be used to specify the block size. The AxoSyslog application will pad reads from the associated device to the number of bytes set in pad-size()
. Mostly used on HP-UX where /dev/log
is a named pipe and every write is padded to 2048 bytes. If pad-size()
was given and the incoming message does not fit into pad-size()
, AxoSyslog will not read anymore from this pipe and displays the following error message:
Padding was set, and couldn't read enough bytes
port() or localport()
Type: | number |
Default: | In case of TCP transport: 514 In case of UDP transport: 514 |
Description: The port number to bind to.
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
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.
When receiving messages using the UDP protocol, increase the size of the UDP receive buffer on the receiver host (that is, the AxoSyslog server or relay receiving the messages). Note that on certain platforms, for example, on Red Hat Enterprise Linux 5, even low message load (~200 messages per second) can result in message loss, unless the so-rcvbuf()
option of the source is increased. In this cases, you will need to increase the net.core.rmem_max
parameter of the host (for example, to 1024000
), but do not modify net.core.rmem_default
parameter.
As a general rule, increase the so-rcvbuf()
so that the buffer size in kilobytes is higher than the rate of incoming messages per second. For example, to receive 2000 messages per second, set the so-rcvbuf()
at least to 2 097 152
bytes.
so-reuseport()
Type: | yes or no |
Default: | no |
Description: Enables SO_REUSEPORT on systems that support it. When enabled, the kernel allows multiple UDP sockets to be bound to the same port, and the kernel load-balances incoming UDP datagrams to the sockets. The sockets are distributed based on the hash of (srcip, dstip, srcport, dstport), so the same listener should be receiving packets from the same endpoint. For example:
source {
network(transport("udp") so-reuseport(1) port(2000) persist-name("udp1"));
network(so-reuseport(1) port(2000) persist-name("udp2"));
network(so-reuseport(1) port(2000) persist-name("udp3"));
network(so-reuseport(1) port(2000) persist-name("udp4"));
};
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-sndbuf()
Type: | number |
Default: | 0 |
Description: Specifies the size of the socket send buffer in bytes. For details, see the socket(7)
manual page.
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
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.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
transport()
Type: | auto , proxied-tcp , proxied-tls , proxied-tls-passthrough , tcp , text-with-nuls , tls , udp |
Default: | tcp |
Description: Specifies the protocol used to receive messages from the source.
-
auto
: Available in version 4.10 and later. Automatically detects RFC6587-style octet-count based framing in TCP traffic. In future versions this functionality will be extended to cover and detect all TCP-based protocols. -
proxied-tcp
,proxied-tls
,proxied-tls-passthrough
: Refers to the HAProxy Proxy Protocol. For details, see Proxy Protocol support. -
text-with-nuls
: Allows embeddedNUL
characters in the message from a TCP source, that is, AxoSyslog will not delimiter the incoming messages onNUL
characters, only onnewline
characters (contrary totcp
transport, which splits the incoming log onnewline
characters andNUL
characters).Note The AxoSyslog application does not support embeddedNUL
characters everywhere, so it is recommended that you also useflags(no-multi-line)
that causesNUL
characters to be replaced by space.
When receiving messages using the UDP protocol, increase the size of the UDP receive buffer on the receiver host (that is, the AxoSyslog server or relay receiving the messages). Note that on certain platforms, for example, on Red Hat Enterprise Linux 5, even low message load (~200 messages per second) can result in message loss, unless the so-rcvbuf()
option of the source is increased. In this cases, you will need to increase the net.core.rmem_max
parameter of the host (for example, to 1024000
), but do not modify net.core.rmem_default
parameter.
As a general rule, increase the so-rcvbuf()
so that the buffer size in kilobytes is higher than the rate of incoming messages per second. For example, to receive 2000 messages per second, set the so-rcvbuf()
at least to 2 097 152
bytes.
trim-large-messages()
Type: | `yes |
Default: | Use the global trim-large-messages() option, which defaults to no . |
Description: Determines what AxoSyslog does with incoming log messages that are received using the IETF-syslog protocol using the syslog()
driver, and are longer than the value of log-msg-size()
. Other drivers ignore the trim-large-messages()
option.
-
If set to
no
, AxoSyslog drops the incoming log message. -
If set to
yes
, AxoSyslog trims the incoming log message to the size set inlog-msg-size()
, and adds thetrimmed
tag to the message. The rest of the message is dropped. You can use the tag to filter on such messages.filter f_trimmed { tags("trimmed"); };
If AxoSyslog trims a log message, it sends a debug-level log message to its
internal()
source.As a result of trimming, a parser could fail to parse the trimmed message. For example, a trimmed JSON or XML message will not be valid JSON or XML.
Available in AxoSyslog version 3.21 and later.
Uses the value of the global option if not specified.
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.
use-dns()
Type: | yes, no, persist_only |
Default: | yes |
Description: Enable or disable DNS usage. The persist_only
option attempts to resolve hostnames locally from file (for example, from /etc/hosts
). The AxoSyslog application blocks on DNS queries, so enabling DNS may lead to a Denial of Service attack. To prevent DoS, protect your AxoSyslog network endpoint with firewall rules, and make sure that all hosts which may get to AxoSyslog are resolvable. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
keep-hostname()
option is enabled (keep-hostname(yes)
) and the message contains a hostname.
use-fqdn()
Type: | yes or no |
Default: | no |
Description: Use this option to add a Fully Qualified Domain Name (FQDN) instead of a short hostname. You can specify this option either globally or per-source. The local setting of the source overrides the global option if available.
use-fqdn()
to yes
if you want to use the custom-domain()
global option.
keep-hostname()
option is enabled (keep-hostname(yes)
) and the message contains a hostname.
14.2 - Proxy Protocol support
If you connect load balancers to your AxoSyslog application, AxoSyslog identifies every connection that is connected to the load balancers identically by default, regardless of the source IP or the source protocol. Essentially, the load balancer masks the source IP unless you enable Proxy Protocol support for your proxy TLS transport()
to inject information about the original connection into the forwarded TCP session.
For further details about the working mechanism behind the Proxy Protocol support on AxoSyslog and the configuration details, see the following sections:
14.2.1 - The working mechanism behind the Proxy Protocol
This section describes how AxoSyslog supports the Proxy Protocol.
The working mechanism behind the Proxy Protocol
When using the Proxy Protocol during load balancing, AxoSyslog detects the information behind connections connected to the load balancer, then parses the injected information into the following macros:
Data | Macro in version 4.9 and earlier | Version 4.10 and later |
---|---|---|
Source IP of the proxy | PROXY_SRCIP |
SOURCEIP |
Source port of the proxy | PROXY_SRCPORT |
SOURCEPORT |
Destination IP of the proxy | PROXY_DSTIP |
DESTIP |
Destination port of the proxy | PROXY_DSTPORT |
DESTPORT |
Consider the following about macros and headers:
-
When the proxy protocol header is
PROXY UNKNOWN
, no additional macros are added. -
When AxoSyslog cannot parse a proxy protocol header, the connection is closed:
[2020-11-20T17:33:22.189458] PROXY protocol header received; line='PROXYdsfj' [2020-11-20T17:33:22.189475] Error parsing PROXY protocol header; [2020-11-20T17:33:22.189517] Syslog connection closed; fd='13', client='AF_INET(127.0.0.1:51665)', local='AF_INET(0.0.0.0:6666)' [2020-11-20T17:33:22.189546] Freeing PROXY protocol source driver; driver='0x7fffcba5bcf0' [2020-11-20T17:33:22.189600] Closing log transport fd; fd='13'
14.2.2 - Proxy Protocol: configuration and output examples
This section provides information about enabling Proxy Protocol support in your network()
source options, and an example configuration and output to illustrate how the Proxy Protocol method works in AxoSyslog.
For more information about the working mechanism of the Proxy Protocol, see The working mechanism behind the Proxy Protocol.
Enabling Proxy Protocol support for your network() source options
Unless you enable Proxy Protocol support for your network()
source, AxoSyslog identifies every connection that is connected to the load balancers identically by default, regardless of the source IP or the source protocol.
To enable Proxy Protocol for your network()
source, set the transport()
parameter of your network()
source to proxied-tcp
or proxied-tls-passthrough
, depending on your preference and configuration.
proxied-tls
can be used in complex MITM (man in the middle) configurations, where the proxy header is sent encrypted within the same TLS session as the proxied messages.
When you enable Proxy Protocol support for your network()
source, you can use the following configuration example with your AxoSyslog application.
Configuration
The following code sample illustrates how you can use the Proxy Protocol in your AxoSyslog configuration (using the transport()
parameter set to proxied-tls-passthrough
).
@version: 3.35
source s_tcp_pp {
network (
port(6666)
transport("proxied-tls-passthrough")
tls(
key-file("/certs/certs/server/server.rsa")
cert-file("/certs/certs/server/server.crt")
ca-dir("/certs/certs/CA")
peer-verify("required-trusted")
)
);
};
destination d_file {
file("/var/log/proxy-proto.log" template("$(format-json --scope nv-pairs)\n"));
};
log {
source(s_tcp_pp);
destination(d_file);
};
With this configuration, the Proxy Protocol method will perform injecting the information of the original connection into the forwarded TCP session, based on the working mechanism described in The working mechanism behind the Proxy Protocol.
The following example illustrates how the parsed macros will appear in the output.
Example: Output for the PROXY TCP4 192.168.1.1 10.10.0.1 1111 2222 input header
With the PROXY TCP4 192.168.1.1 10.10.0.1 1111 2222
input header, the output looks like this:
{"SOURCE":"s_tcp_pp","PROXIED_SRCPORT":"1111","PROXIED_SRCIP":"192.168.1.1","PROXIED_IP_VERSION":"4","PROXIED_DSTPORT":"2222","PROXIED_DSTIP":"10.10.0.1","PROGRAM":"TestMsg","MESSAGE":"","LEGACY_MSGHDR":"TestMsg","HOST_FROM":"localhost","HOST":"localhost"}
Note that the macros that AxoSyslog adds to the message appear in the output.
15 - nodejs: Receive JSON messages from nodejs applications
Using the nodejs()
driver, AxoSyslog can receive application logs directly from nodejs applications that use the widespread Winston logging API. The AxoSyslog application automatically adds the .nodejs.winston.
prefix to the name of the fields the extracted from the message.
To use the nodejs()
driver, the scl.conf
file must be included in your AxoSyslog configuration:
@include "scl.conf"
The nodejs()
driver is actually a reusable configuration snippet configured to receive log messages using the network()
driver, and process its JSON contents. For details on using or writing such configuration snippets, see Reusing configuration blocks. You can find the source of the nodejs configuration snippet on GitHub.
Example: Using the nodejs() driver
The following example uses the default settings of the driver, listening for messages on port 9003 of every IP address of the AxoSyslog host.
@include "scl.conf"
source apps { nodejs(); };
The following example listens only on IP address 192.168.1.1
, port 9999
.
@include "scl.conf"
source apps {
nodejs(
localip(192.168.1.1)
port(9999)
)
};
15.1 - nodejs() source options
The nodejs()
driver has the following options.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
ip() or localip()
Type: | string |
Default: | 0.0.0.0 |
Description: The IP address to bind to. By default, AxoSyslog listens on every available interface. Note that this is not the address where messages are accepted from.
If you specify a multicast bind address and use the udp
transport, AxoSyslog automatically joins the necessary multicast group. TCP does not support multicasting.
port() or localport()
Type: | number |
Default: | 9003 |
Description: The port number to bind to.
16 - osquery: Collect and parse osquery result logs
The osquery application allows you to ask questions about your machine using an SQL-like language. For example, you can query running processes, logged in users, installed packages and syslog messages as well. You can make queries on demand, and also schedule them to run regularly.
The osquery()
source of AxoSyslog allows you read the results of periodical osquery queries (from the /var/log/osquery/osqueryd.results.log
file) and automatically parse the messages. For example, you can:
- Create filters from the fields of the messages.
- Limit which fields to store, or create additional fields (combine multiple fields into one field, and so on).
- Send the messages to a central location, for example, to Elasticsearch, directly from AxoSyslog.
The AxoSyslog application automatically adds the .osquery.
prefix to the name of the fields the extracted from the message.
The osquery()
source is available in AxoSyslog version 3.10 and later.
Prerequisites:
-
To use the
osquery()
driver, thescl.conf
file must be included in your AxoSyslog configuration:@include "scl.conf"
-
AxoSyslog must be compiled with JSON-support enabled.
The osquery()
driver is actually a reusable configuration snippet configured to read the osquery log file using the file()
driver, and process its JSON contents. For details on using or writing such configuration snippets, see Reusing configuration blocks. You can find the source of this configuration snippet on GitHub.
Example: Using the osquery() driver with the default settings
The following AxoSyslog configuration sample uses the default settings of the driver, reading osquery result logs from the /var/log/osquery/osqueryd.results.log
file, and writes the log messages generated from the traps into a file.
@version: 3.10
@include "scl.conf"
source s_osquery {
osquery();
};
log {
source(s_osquery);
destination {
file("/var/log/example.log");
};
};
Filter for messages related to loading Linux kernel modules:
@version: 3.10
@include "scl.conf"
source s_osquery {
osquery();
};
log {
source(s_osquery);
filter f_modules {
"${.osquery.name}" eq "pack_incident-response_kernel_modules"
};
destination {
file("/var/log/example.log");
};
};
Example: Using the osquery() driver with custom configuration
The following AxoSyslog configuration sample reads osquery result logs from the /tmp/osquery_input.log
file, and writes the log messages generated from the traps into a file. Using the format-json
template, the outgoing message will be a well-formed JSON message.
Input message
{"name":"pack_osquery-monitoring_osquery_info","hostIdentifier":"testhost","calendarTime":"Fri Jul 21 10:04:41 2017 UTC","unixTime":"1500631481","decorations":{"host_uuid":"4C4C4544-004D-3610-8043-C2C04F4D3332","username":"myuser"},"columns":{"build_distro":"xenial","build_platform":"ubuntu","config_hash":"43cd1c6a7d0c283e21e026a53e619b2e582e94ee","config_valid":"1","counter":"4","extensions":"active","instance_id":"d0c3eb0d-f8e0-4bea-868b-18a2c61b438d","pid":"19764","resident_size":"26416000","start_time":"1500629552","system_time":"223","user_time":"476","uuid":"4C4C4544-004D-3610-8043-C2C04F4D3332","version":"2.5.0","watcher":"19762"},"action":"added"}
AxoSyslog configuration
@version: 3.10
@include "scl.conf"
source s_osquery {
osquery(
file(/tmp/osquery_input.log)
prefix(.osquery.)
);
};
destination d_file {
file(
"/tmp/output.txt"
template("$(format_json --key .osquery.*)\n")
);
};
log {
source(s_osquery);
destination(d_file);
flags(flow-control);
};
Outgoing message
Outgoing message; message='{"_osquery":{"unixTime":"1500631481","name":"pack_osquery-monitoring_osquery_info","hostIdentifier":"testhost","decorations":{"username":"myuser","host_uuid":"4C4C4544-004D-3610-8043-C2C04F4D3332"},"columns":{"watcher":"19762","version":"2.5.0","uuid":"4C4C4544-004D-3610-8043-C2C04F4D3332","user_time":"476","system_time":"223","start_time":"1500629552","resident_size":"26416000","pid":"19764","instance_id":"d0c3eb0d-f8e0-4bea-868b-18a2c61b438d","extensions":"active","counter":"4","config_valid":"1","config_hash":"43cd1c6a7d0c283e21e026a53e619b2e582e94ee","build_platform":"ubuntu","build_distro":"xenial"},"calendarTime":"Fri Jul 21 10:04:41 2017 UTC","action":"added"}}\x0a'
16.1 - osquery() source options
The osquery()
driver has the following options.
file()
Type: | path |
Default: | /var/log/osquery/osqueryd.results.log |
Description: The log file of osquery
that stores the results of periodic queries. The AxoSyslog application reads the messages from this file.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
prefix()
Synopsis: | prefix() |
Description: Insert a prefix before the name part of the parsed name-value pairs to help further processing. For example:
-
To insert the
my-parsed-data.
prefix, use theprefix(my-parsed-data.)
option. -
To refer to a particular data that has a prefix, use the prefix in the name of the macro, for example,
${my-parsed-data.name}
. -
If you forward the parsed messages using the IETF-syslog protocol, you can insert all the parsed data into the SDATA part of the message using the
prefix(.SDATA.my-parsed-data.)
option.
Names starting with a dot (for example, .example
) are reserved for use by AxoSyslog. If you use such a macro name as the name of a parsed value, it will attempt to replace the original value of the macro (note that only soft macros can be overwritten, see Hard versus soft macros for details). To avoid such problems, use a prefix when naming the parsed values, for example, prefix(my-parsed-data.)
Default value:
.osquery.
option.
17 - Receive logs, metrics, and traces from OpenTelemetry
Starting with version 4.3.0, AxoSyslog can receive logs, metrics, and traces from OpenTelemetry clients over the OpenTelemetry Protocol (OTLP/gRPC).
Example: Receiving OpenTelemetry data
The following example receives OpenTelemetry data and forwards it to an OpenTelemetry receiver. Note that by default, AxoSyslog doesn’t parse the fields of the incoming messages into name-value pairs, but are only available for forwarding using the opentelemetry()
destination. To parse the fields into name-value pairs, use the opentelemetry()
parser.
log otel_forward_mode_alts {
source {
opentelemetry(
port(4317)
auth(alts())
);
};
destination {
opentelemetry(
url("my-otel-server:12345")
auth(alts())
);
};
};
auth()
You can set authentication in the auth()
option of the driver. By default, authentication is disabled (auth(insecure())
).
The following authentication methods are available in the auth()
block:
adc()
Application Default Credentials (ADC). This authentication method is only available for destinations.
alts()
Application Layer Transport Security (ALTS) is a simple to use authentication, only available within Google’s infrastructure. It accepts the target-service-account()
option, where you can list service accounts to match against when authenticating the server.
source {
opentelemetry(
port(4317)
auth(alts())
);
};
destination {
loki(
port(12345)
auth(alts())
);
};
source {
syslog-ng-otlp(
port(4317)
auth(alts())
);
};
insecure()
This is the default method, authentication is disabled (auth(insecure())
).
tls()
tls()
accepts the key-file()
, cert-file()
, ca-file()
and peer-verify()
(possible values:
required-trusted
, required-untrusted
, optional-trusted
and optional-untrusted
) options.
destination {
opentelemetry(
url("your-otel-server:12346")
auth(
tls(
ca-file("/path/to/ca.pem")
key-file("/path/to/key.pem")
cert-file("/path/to/cert.pem")
)
)
);
};
destination {
loki(
url("your-loki-server:12346")
auth(
tls(
ca-file("/path/to/ca.pem")
key-file("/path/to/key.pem")
cert-file("/path/to/cert.pem")
)
)
);
};
destination {
syslog-ng-otlp(
url("your-otel-server:12346")
auth(
tls(
ca-file("/path/to/ca.pem")
key-file("/path/to/key.pem")
cert-file("/path/to/cert.pem")
)
)
);
};
Note:
tls(peer-verify())
is not available for theopentelemetry()
andloki()
destination.- The gRPC-based drivers (
opentelemetry()
andloki()
) have a differenttls()
block implementation from thenetwork()
orhttp()
drivers. Most features are the same.
channel-args()
Type: | arrow list |
Default: | - |
Description: The channel-args()
option is available in gRPC-based drivers. It accepts name-value pairs and sets channel arguments defined in the GRPC Core library documentation. For example:
channel-args(
"grpc.loadreporting" => 1
"grpc.minimal_stack" => 0
)
concurrent-requests()
Type: | integer |
Default: | 2 |
Description: Configures the maximal number of in-flight gRPC requests per worker. Setting this value in the range of 10s or 100s is recommended when there are a high number of clients sending simultaneously. Ideally, workers() * concurrent-requests()
should be greater than or equal to the number of clients, but this can increase the memory usage.
keep-hostname()
The opentelemetry()
source ignores this option and uses the address of the OTLP peer as the HOST.
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
port()
The port number to receive incoming connections. Default value: 4317
workers()
Type: | integer |
Default: | 1 |
Description: Specifies the number of worker threads (at least 1) that AxoSyslog uses to process the messages of the source. Increasing the number of worker threads can drastically improve the performance of the source.
18 - pacct: Collect process accounting logs on Linux
Starting with version 3.2, AxoSyslog can collect process accounting logs on Linux systems.Process accounting is the method of recording and summarizing commands executed on Linux, for example, the commands being run, the user who executed the command, CPU time used by the process, exit code, and so on. When process accounting (also called pacct) is enabled on a system, the kernel writes accounting records to the /var/log/account/pacct
file (might vary between different Linux distributions).
To use the pacct()
driver, the following conditions must be met:
-
The AxoSyslog application must be compiled with the
--enable-pacct
option. Execute thesyslog-ng -V
command to check if your binary supports process accounting. -
The
pacctformat
plugin must be loaded. By default, AxoSyslog automatically loads the available modules. -
The
scl.conf
file must be included in your AxoSyslog configuration:@include "scl.conf"
-
Process accounting must be running on the host. You can enable it with the
accton
command.
The pacct()
driver parses the fields of the accounting logs and transforms them into name-value pairs. The fields are defined in the manual page of the accounting log file (man acct
), AxoSyslog prepends every field with the .pacct.
prefix. For example, the ac_uid
field that contains the id of the user who started the process will be available under the $.pacct.ac_uid
name. These can be used as macros in templates, in filters to select specific messages, and so on.
To use the pacct()
driver, use the following syntax.
@version: 4.10.0
@include "scl.conf"
source s_pacct { pacct(); };
...
log { source(s_pacct); destination(...); };
The pacct()
driver is actually a reusable configuration snippet configured to handle Linux accounting logs. For details on using or writing such configuration snippets, see Reusing configuration blocks. You can find the source of the pacct configuration snippet on GitHub.
18.1 - pacct() options
The pacct()
driver has the following options:
file()
Type: | filename with path |
Default: | /var/log/account/pacct |
Description: The file where the process accounting logs are stored — AxoSyslog reads accounting messages from this file.
follow-freq()
Type: | number |
Default: | 1 |
Description: Indicates that the source should be checked periodically. This is useful for files which always indicate readability, even though no new lines were appended. If this value is higher than zero, AxoSyslog will not attempt to use poll()
on the file, but checks whether the file changed every time the follow-freq()
interval (in seconds) has elapsed. Floating-point numbers (for example, 1.5
) can be used as well.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
19 - Pi-hole Faster Than Light logs
Starting with version 4.6.0, AxoSyslog can collect logs of the Pi-hole FTL (Faster Than Light) application.
source s_pihole_ftl {
pihole-ftl();
};
By default, the source reads the /var/log/pihole/FTL.log
file. If the root directory of your Pi-hole installation is different, specify the directory where the FTL.log file is with the dir()
option. You can find the root log directory by selecting Tools > Pi-hole diagnosis in the Pi-hole application. Otherwise, the pihole-ftl()
source has the same parameters as the file()
source.
The pihole-ftl()
driver is actually a reusable configuration snippet. For details on using or writing such configuration snippets, see Reusing configuration blocks. You can find the source of this configuration snippet on GitHub.
20 - pipe: Collect messages from named pipes
The pipe driver opens a named pipe with the specified name and listens for messages. It is used as the native message delivery protocol on HP-UX.
The pipe driver has a single required parameter, specifying the filename of the pipe to open. For the list of available optional parameters, see pipe() source options.
Declaration:
pipe(filename);
mkfifo(1)
command.
Pipe is very similar to the file()
driver, but there are a few differences, for example, pipe()
opens its argument in read-write mode, therefore it is not recommended to be used on special files like /proc/kmsg
.
-
It is not recommended to use
pipe()
on anything else than real pipes. -
By default, AxoSyslog uses the
flags(no-hostname)
option for pipes, meaning that AxoSyslog assumes that the log messages received from the pipe do not contain the hostname field. If your messages do contain the hostname field, useflags(expect-hostname)
.
Example: Using the pipe() driver
source s_pipe {
pipe("/dev/pipe" pad-size(2048));
};
20.1 - pipe() source options
The pipe
driver has the following options:
check-hostname()
Type: | boolean (yes or no ) |
Default: | Use the global check-hostname() option, which defaults to no . |
Description:
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
Uses the value of the global option if not specified.
create-dirs()
Type: | yes or no |
Default: | no |
Description: Enable creating non-existing directories when creating files or socket files.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
follow-freq()
Type: | number |
Default: | 1 |
Description: Indicates that the source should be checked periodically. This is useful for files which always indicate readability, even though no new lines were appended. If this value is higher than zero, AxoSyslog will not attempt to use poll()
on the file, but checks whether the file changed every time the follow-freq()
interval (in seconds) has elapsed. Floating-point numbers (for example, 1.5
) can be used as well.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
idle-timeout()
Accepted values: | number [seconds] |
Default: | 0 (disabled) |
Available in AxoSyslog 4.9 and later.
If set, AxoSyslog closes the client connection if no data is received for the specified amount of time (in seconds).
keep-timestamp()
Type: | yes or no |
Default: | yes |
Description: Specifies whether AxoSyslog should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
S_
macros, the keep-timestamp()
option must be enabled (this is the default behavior of AxoSyslog).
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
log-iw-size()
Type: | number |
Default: | 100 |
Description: The size of the initial window, this value is used during flow-control. Its value cannot be lower than 100, unless the dynamic-window-size()
option is enabled. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
log-msg-size()
Type: | number (bytes) |
Default: | Use the global log-msg-size() option, which defaults to 65536 (64 KiB). |
Description: Maximum length of an incoming message in bytes. This length includes the entire message (the data structure and individual fields). The maximal value that can be set is 268435456 bytes (256 MiB).
For messages using the IETF-syslog message format (RFC5424), the maximal size of the value of an SDATA field is 64 KiB.
log-msg-size()
does not need to be set higher than 10 MiB.
For details on how encoding affects the size of the message, see Message size and encoding.
You can use human-readable units when setting configuration options. For details, seeNotes about the configuration syntax.
Uses the value of the global option if not specified.
log-prefix() (DEPRECATED)
Type: | string |
Default: |
Description: A string added to the beginning of every log message. It can be used to add an arbitrary string to any log source, though it is most commonly used for adding kernel:
to the kernel messages on Linux.
program-override
instead.
multi-line-garbage()
Type: | regular expression |
Default: | empty string |
Description: Use the multi-line-garbage()
option when processing multi-line messages that contain unneeded parts between the messages. Specify a string or regular expression that matches the beginning of the unneeded message parts. If the multi-line-garbage()
option is set, AxoSyslog ignores the lines between the line matching the multi-line-garbage()
and the next line matching multi-line-prefix()
. See also the multi-line-prefix()
option.
When receiving multi-line messages from a source when the multi-line-garbage()
option is set, but no matching line is received between two lines that match multi-line-prefix()
, AxoSyslog will continue to process the incoming lines as a single message until a line matching multi-line-garbage()
is received.
To use the multi-line-garbage()
option, set the multi-line-mode()
option to prefix-garbage
.
multi-line-garbage()
option is set, AxoSyslog discards lines between the line matching the multi-line-garbage()
and the next line matching multi-line-prefix()
.
multi-line-mode()
Type: | indented , prefix-garbage , prefix-suffix , regexp , smart |
Default: | empty string |
Description: Use the multi-line-mode()
option when processing multi-line messages. The AxoSyslog application provides the following methods to process multi-line messages:
-
indented
: Theindented
mode can process messages where each line that belongs to the previous line is indented by whitespace, and the message continues until the first non-indented line. For example, the Linux kernel (starting with version 3.5) uses this format for/dev/log
, as well as several applications, like Apache Tomcat.source s_tomcat { file("/var/log/tomcat/xxx.log" multi-line-mode(indented)); };
-
prefix-garbage
: The prefix-garbage mode uses a string or regular expression (set inmulti-line-prefix()
) that matches the beginning of the log messages, ignores newline characters from the source until a line matches the regular expression again, and treats the lines between the matching lines as a single message. For details on usingmulti-line-mode(prefix-garbage)
, see themulti-line-prefix()
andmulti-line-garbage()
options. -
prefix-suffix
: Theprefix-suffix
mode uses a string or regular expression (set inmulti-line-prefix()
) that matches the beginning of the log messages, ignores newline characters from the source until a line matches the regular expression set inmulti-line-suffix()
, and treats the lines betweenmulti-line-prefix()
andmulti-line-suffix()
as a single message. Any other lines between the end of the message and the beginning of a new message (that is, a line that matches themulti-line-prefix()
expression) are discarded. For details on usingmulti-line-mode(prefix-suffix)
, see themulti-line-prefix()
andmulti-line-suffix()
options.The
prefix-suffix
mode is similar to theprefix-garbage
mode, but it appends the garbage part to the message instead of discarding it. -
smart
: Thesmart
mode recognizes multi-line data backtraces even if they span multiple lines in the input. The backtraces are converted to a single log message for easier analysis. Backtraces for the following programming languages are recognized : Python, Java, JavaScript, PHP, Go, Ruby, and Dart.smart
mode is available in AxoSyslog version 4.2 and newer.The regular expressions to recognize these programming languages are specified in an external file called
/usr/share/syslog-ng/smart-multi-line.fsm
(installation path depends on configure arguments), in a format that is described in that file.
To format multi-line messages to your individual needs, consider the following:
-
To make multi-line messages more readable when written to a file, use a template in the destination and instead of the
${MESSAGE}
macro, use the following:$(indent-multi-line ${MESSAGE})
. This expression inserts a tab after every newline character (except when a tab is already present), indenting every line of the message after the first. For example:destination d_file { file ("/var/log/messages" template("${ISODATE} ${HOST} $(indent-multi-line ${MESSAGE})\n") ); };
For details on using templates, see Templates and macros.
-
To actually convert the lines of multi-line messages to single line (by replacing the newline characters with whitespaces), use the
flags(no-multi-line)
option in the source.
multi-line-prefix()
Type: | regular expression starting with the ^ character |
Default: | empty string |
Description: Use the multi-line-prefix()
option to process multi-line messages, that is, log messages that contain newline characters (for example, Tomcat logs). Specify a string or regular expression that matches the beginning of the log messages (always start with the ^
character). Use as simple regular expressions as possible, because complex regular expressions can severely reduce the rate of processing multi-line messages. If the multi-line-prefix()
option is set, AxoSyslog ignores newline characters from the source until a line matches the regular expression again, and treats the lines between the matching lines as a single message. See also the multi-line-garbage()
option.
To format multi-line messages to your individual needs, consider the following:
-
To make multi-line messages more readable when written to a file, use a template in the destination and instead of the
${MESSAGE}
macro, use the following:$(indent-multi-line ${MESSAGE})
. This expression inserts a tab after every newline character (except when a tab is already present), indenting every line of the message after the first. For example:destination d_file { file ("/var/log/messages" template("${ISODATE} ${HOST} $(indent-multi-line ${MESSAGE})\n") ); };
For details on using templates, see Templates and macros.
-
To actually convert the lines of multi-line messages to single line (by replacing the newline characters with whitespaces), use the
flags(no-multi-line)
option in the source.
Example: Processing Tomcat logs
The log messages of the Apache Tomcat server are a typical example for multi-line log messages. The messages start with the date and time of the query in the YYYY.MM.DD HH:MM:SS
format, as you can see in the following example.
2010.06.09. 12:07:39 org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start:
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: java.net.BindException: Address already in use null:8080
at org.apache.catalina.connector.Connector.start(Connector.java:1138)
at org.apache.catalina.core.StandardService.start(StandardService.java:531)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
2010.06.09. 12:07:39 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1206 ms
2010.06.09. 12:45:08 org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
2010.06.09. 12:45:09 org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
To process these messages, specify a regular expression matching the timestamp of the messages in the multi-line-prefix()
option. Such an expression is the following:
source s_file{file("/var/log/tomcat6/catalina.2010-06-09.log" follow-freq(0) multi-line-mode(regexp) multi-line-prefix("[0-9]{4}\.[0-9]{2}\.[0-9]{2}\.") flags(no-parse));};
};
Note that flags(no-parse)
is needed to prevent AxoSyslog trying to interpret the date in the message.
multi-line-suffix()
Type: | regular expression |
Default: | empty string |
Description: Use the multi-line-suffix()
option when processing multi-line messages. Specify a string or regular expression that matches the end of the multi-line message.
To use the multi-line-suffix()
option, set the multi-line-mode()
option to prefix-suffix
. See also the multi-line-prefix()
option.
optional()
Type: | yes or no |
Default: |
Description: Instruct AxoSyslog to ignore the error if a specific source cannot be initialized. No other attempts to initialize the source will be made until the configuration is reloaded. This option currently applies to the pipe()
, unix-dgram
, and unix-stream
drivers.
pad-size()
Type: | number |
Default: | 0 |
Description: Specifies input padding. Some operating systems (such as HP-UX) pad all messages to block boundary. This option can be used to specify the block size. The AxoSyslog application will pad reads from the associated device to the number of bytes set in pad-size()
. Mostly used on HP-UX where /dev/log
is a named pipe and every write is padded to 2048 bytes. If pad-size()
was given and the incoming message does not fit into pad-size()
, AxoSyslog will not read anymore from this pipe and displays the following error message:
Padding was set, and couldn't read enough bytes
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
21 - program: Receive messages from external applications
The program driver starts an external application and reads messages from the standard output (stdout) of the application. It is mainly useful to receive log messages from daemons that accept incoming messages and convert them to log messages.
The program driver has a single required parameter, specifying the name of the application to start.
Declaration:
program(filename);
Example: Using the program() driver
source s_program {
program("/etc/init.d/mydaemon");
};
21.1 - program() source options
The program
driver has the following options:
check-hostname()
Type: | boolean (yes or no ) |
Default: | Use the global check-hostname() option, which defaults to no . |
Description:
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
Uses the value of the global option if not specified.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
idle-timeout()
Accepted values: | number [seconds] |
Default: | 0 (disabled) |
Available in AxoSyslog 4.9 and later.
If set, AxoSyslog closes the client connection if no data is received for the specified amount of time (in seconds).
inherit-environment()
Type: | `yes |
Default: | yes |
Description: By default, when program()
starts an external application or script, it inherits the entire environment of the parent process (that is, AxoSyslog). Use inherit-environment(no)
to prevent this.
keep-timestamp()
Type: | yes or no |
Default: | yes |
Description: Specifies whether AxoSyslog should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
S_
macros, the keep-timestamp()
option must be enabled (this is the default behavior of AxoSyslog).
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
log-iw-size()
Type: | number |
Default: | 100 |
Description: The size of the initial window, this value is used during flow-control. Its value cannot be lower than 100, unless the dynamic-window-size()
option is enabled. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
log-msg-size()
Type: | number (bytes) |
Default: | Use the global log-msg-size() option, which defaults to 65536 (64 KiB). |
Description: Maximum length of an incoming message in bytes. This length includes the entire message (the data structure and individual fields). The maximal value that can be set is 268435456 bytes (256 MiB).
For messages using the IETF-syslog message format (RFC5424), the maximal size of the value of an SDATA field is 64 KiB.
log-msg-size()
does not need to be set higher than 10 MiB.
For details on how encoding affects the size of the message, see Message size and encoding.
You can use human-readable units when setting configuration options. For details, seeNotes about the configuration syntax.
Uses the value of the global option if not specified.
log-prefix() (DEPRECATED)
Type: | string |
Default: |
Description: A string added to the beginning of every log message. It can be used to add an arbitrary string to any log source, though it is most commonly used for adding kernel:
to the kernel messages on Linux.
program-override
instead.
optional()
Type: | yes or no |
Default: |
Description: Instruct AxoSyslog to ignore the error if a specific source cannot be initialized. No other attempts to initialize the source will be made until the configuration is reloaded. This option currently applies to the pipe()
, unix-dgram
, and unix-stream
drivers.
pad-size()
Type: | number |
Default: | 0 |
Description: Specifies input padding. Some operating systems (such as HP-UX) pad all messages to block boundary. This option can be used to specify the block size. The AxoSyslog application will pad reads from the associated device to the number of bytes set in pad-size()
. Mostly used on HP-UX where /dev/log
is a named pipe and every write is padded to 2048 bytes. If pad-size()
was given and the incoming message does not fit into pad-size()
, AxoSyslog will not read anymore from this pipe and displays the following error message:
Padding was set, and couldn't read enough bytes
program()
Type: | filename with path |
Default: |
Description: The name of the application to start and read messages from.
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
22 - python: writing server-style Python sources
The Python source allows you to write your own source in Python. You can import external Python modules to receive or fetch the messages. Since many services have a Python library, the Python source makes integrating AxoSyslog very easy and quick.
You can write two different type of sources in Python:
-
Server-style sources that receives messages. Write server-style sources if you want to use an event-loop based, nonblocking server framework in Python, or if you want to implement a custom loop.
-
Fetcher-style sources that actively fetch messages. In general, write fetcher-style sources (for example, when using simple blocking APIs), unless you explicitly need a server-style source.
This section describes server-style sources. For details on fetcher-style sources, see python-fetcher: writing fetcher-style Python sources.
The following points apply to using Python blocks in AxoSyslog in general:
-
Python parsers and template functions are available in AxoSyslog version 3.10 and later.
Python destinations and sources are available in AxoSyslog version 3.18 and later.
-
Supported Python versions: 2.7 and 3.4+ (if you are using pre-built binaries, check the dependencies of the package to find out which Python version it was compiled with).
-
The Python block must be a top-level block in the AxoSyslog configuration file.
-
If you store the Python code in a separate Python file and only include it in the AxoSyslog configuration file, make sure that the PYTHONPATH environment variable includes the path to the Python file, and export the PYTHON_PATH environment variable. For example, if you start AxoSyslog manually from a terminal and you store your Python files in the
/opt/syslog-ng/etc
directory, use the following command:export PYTHONPATH=/opt/syslog-ng/etc
.In production, when AxoSyslog starts on boot, you must configure your startup script to include the Python path. The exact method depends on your operating system. For recent Red Hat Enterprise Linux, Fedora, and CentOS distributions that use systemd, the
systemctl
command sources the/etc/sysconfig/syslog-ng
file before starting AxoSyslog. (On openSUSE and SLES,/etc/sysconfig/syslog
file.) Append the following line to the end of this file:PYTHONPATH="<path-to-your-python-file>"
, for example,PYTHONPATH="/opt/syslog-ng/etc"
. -
The Python object is initiated every time when AxoSyslog is started or reloaded.
Warning If you reload AxoSyslog, existing Python objects are destroyed, therefore the context and state information of Python blocks is lost. Log rotation and updating the configuration of AxoSyslog typically involves a reload. -
The Python block can contain multiple Python functions.
-
Using Python code in AxoSyslog can significantly decrease the performance of AxoSyslog, especially if the Python code is slow. In general, the features of AxoSyslog are implemented in C, and are faster than implementations of the same or similar features in Python.
-
Validate and lint the Python code before using it. The AxoSyslog application does not do any of this.
-
Python error messages are available in the
internal()
source of AxoSyslog. -
You can access the name-value pairs of AxoSyslog directly through a message object or a dictionary.
-
To help debugging and troubleshooting your Python code, you can send log messages to the
internal()
source of AxoSyslog. For details, see Logging from your Python code.
Starting with 3.26, AxoSyslog assigns a persist name to Python sources and destinations. The persist name is generated from the class name. If you want to use the same Python class multiple times in your AxoSyslog configuration, add a unique persist-name()
to each source or destination, otherwise AxoSyslog will not start. For example:
log {
source { python(class(PyNetworkSource) options("port" "8080") persist-name("<unique-string>); };
source { python(class(PyNetworkSource) options("port" "8081")); };
};
Alternatively, you can include the following line in the Python package: @staticmethod generate_persist_name
. For example:
from syslogng import LogSource
class PyNetworSource(LogSource):
@staticmethod
def generate_persist_name(options):
return options["port"]
def run(self):
pass
def request_exit(self):
pass
Declaration:
Python sources consist of two parts. The first is a AxoSyslog source object that you define in your AxoSyslog configuration and use in the log path. This object references a Python class, which is the second part of the Python source. The Python class receives or fetches the log messages, and can do virtually anything that you can code in Python. You can either embed the Python class into your AxoSyslog configuration file, or store it in an external Python file.
source <name_of_the_python_source>{
python(
class("<name_of_the_python_class_executed_by_the_source>")
options(
"option1" "value1",
"option2" "value2"
)
);
};
python {
from syslogng import LogSource
from syslogng import LogMessage
class <name_of_the_python_class_executed_by_the_source>(LogSource):
def init(self, options): # optional
print("init")
print(options)
self.exit = False
return True
def deinit(self): # optional
print("deinit")
def run(self): # mandatory
print("run")
while not self.exit:
# Must create a message
msg = LogMessage("this is a log message")
self.post_message(msg)
def request_exit(self): # mandatory
print("exit")
self.exit = True
};
Methods of the python() source
Server-style Python sources must be inherited from the syslogng.LogSource
class, and must implement at least the run
and request_exit
methods. Multiple inheritance is allowed, but only for pure Python super classes.
You can implement your own event loop, or integrate the event loop of an external framework or library, for example, KafkaConsumer, Flask, Twisted engine, and so on.
To post messages, call LogSource::post_message()
method in the run
method.
For the list of available optional parameters, see python() and python-fetcher() source options.
init(self, options) method (optional)
The AxoSyslog application initializes Python objects every time when it is started or reloaded. The init
method is executed as part of the initialization. You can perform any initialization steps that are necessary for your source to work.
When this method returns with False, AxoSyslog does not start. It can be used to check options and return False when they prevent the successful start of the source.
options
: This optional argument contains the contents of the options()
parameter of the AxoSyslog configuration object as a Python dictionary.
run(self) method (mandatory)
Use the run
method to implement an event loop, or start a server framework or library. Create LogMessage
instances in this method, and pass them to the log paths by calling LogSource::post_message()
.
Currently, run
stops permanently if an unhandled exception happens.
For details on parsing and posting messages, see Python LogMessage API.
request_exit(self) method (mandatory)
The AxoSyslog application calls this method when AxoSyslog is shut down or restarted. The request_exit
method must shut down the event loop or framework, so the run
method can return gracefully. If you use blocking operations within the run()
method, use request_exit()
to interrupt those operations and set an exit flag, otherwise AxoSyslog is not able to stop. Note that AxoSyslog calls the request_exit
method from a thread different from the source thread.
close_batch(self)
Closes the current source-side batch. Source-side batching helps AxoSyslog to effectively process a larger chunk of messages, instead of processing messages each message. For example, when feeding a destination queue and instead of taking a lock on the queue for every message (causing contention), we only take it once per batch.
The native drivers built into AxoSyslog typically close batches once every mainloop iteration, allowing a single iteration to process multiple messages. For instance, when receiving multiple messages in a single TCP datagram, all of those messages can be processed as a part of the same batch.
In Python-based log sources, a batch will automatically be closed after every message posted via post_message()
, except if self.auto_close_batches
is set to False
during initialization. In case self.auto_close_batches
is set to False
, the driver has to call close_batch()
explicitly, preferably at a natural boundary between incoming batches of messages. A good example is when we retrieve several messages via the same HTTP REST call, then the right time to close the batch would be after the last message in the response is posted.
The deinit(self) method (optional)
This method is executed when AxoSyslog is stopped or reloaded. This method does not return a value.
set_transport_name(self, name)
Set the transport name used to retrieve messages This function can be called to customize the ${TRANSPORT}
name-value pair.
22.1 - Python LogMessage API
The LogMessage API allows you to create LogMessage objects in Python sources, parse syslog messages, and set the various fields of the log message.
LogMessage() method: Create log message objects
You can use the LogMessage()
method to create a structured log message instance. For example:
from syslogng import LogMessage
msg = LogMessage() # Initialize an empty message with default values (recvd timestamp, rcptid, hostid, ...)
msg = LogMessage("string or bytes-like object") # Initialize a message and set its ${MESSAGE} field to the specified argument
You can also explicitly set the different values of the log message. For example:
msg["MESSAGE"] = "message"
msg["HOST"] = "hostname"
You can set certain special field (timestamp, priority) by using specific methods.
Note the following points when creating a log message:
-
When setting the hostname, AxoSyslog takes the following hostname-related options of the configuration into account:
chain-hostnames()
,keep-hostname()
,use-dns()
, anduse-fqdn()
. -
Python sources ignore the
log-msg-size()
option. -
The AxoSyslog application accepts only one message from every
LogSource::post_message()
orfetch()
call, batching is currently not supported. If your Python code accepts batches of messages, you must pass them to AxoSyslog one-by-one. Similarly, if you need to split messages in the source, you must do so in your Python code, and pass the messages separately. -
Do not reuse or store LogMessage objects after posting (calling
post_message()
) or returning the message fromfetch()
.
parse() method: Parse syslog messages
The parse()
method allows you to parse incoming messages as syslog messages. By default, the parse()
method attempts to parse the message as an IETF-syslog (RFC5424) log message. If that fails, it parses the log message as a BSD-syslog (RFC3164) log message. Note that AxoSyslog takes the parsing-related options of the configuration into account: flags()
, keep-hostname()
, recv-time-zone()
.
If keep-hostname()
is set to no
, AxoSyslog ignores the hostname set in the message, and uses the IP address of the AxoSyslog host as the hostname (to use the hostname instead of the IP address, set the use-dns()
or use-fqdn()
options in the Python source).
msg_ietf = LogMessage.parse('<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"] An application event log entry', self.parse_options)
msg_bsd = LogMessage.parse('<34>Oct 11 22:14:15 mymachine su: \'su root\' failed for lonvick on /dev/pts/8', self.parse_options)
set_pri() method
You can set the priority of the message with the set_pri()
method.
msg.set_pri(165)
set_timestamp() method
You can use the set_timestamp()
method to set the date and time of the log message.
timestamp = datetime.fromisoformat("2018-09-11T14:49:02.100+02:00")
msg.set_timestamp(timestamp) # datetime object, includes timezone information
In Python 2, timezone information cannot be attached to the datetime instance without using an external library. The AxoSyslog represents naive datetime objects in UTC.
In Python 3, naive and timezone-aware datetime objects are both supported.
22.2 - python() and python-fetcher() source options
The python()
and python-fetcher()
drivers have the following options.
class()
Type: | string |
Default: | N/A |
Description: The name of the Python class that implements the source, for example:
python(
class("MyPythonSource")
);
If you want to store the Python code in an external Python file, the class()
option must include the name of the Python file containing the class, without the path and the .py extension, for example:
python(
class("MyPythonfilename.MyPythonSource")
);
For details, see Python code in external files
fetch-no-data-delay()
Type: | integer [seconds] |
Default: | -1 (disabled) |
Description: If the fetch
method of a python-fetcher()
source returns with the LogFetcher.FETCH_NO_DATA
constant, the source waits fetch-no-data-delay()
seconds before calling the fetch
method again. If you want to call the fetch
method sooner, set the fetch-no-data-delay()
option to the number of seconds to wait before calling the fetch
method.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
For the python()
and python-fetcher()
sources you can also set the check-hostname
flag, which is equivalent with the check-hostname()
global option, but only applies to this source.
The flags and the hostname-related options (for example, use-dns
) set in the configuration file influence the behavior of the LogMessage.parse()
method of the Python source. They have no effect if you set the message or the hostname directly, without using LogMessage.parse()
.
keep-hostname()
Type: | yes or no |
Default: | no |
Description: Enable or disable hostname rewriting.
-
If enabled (
keep-hostname(yes)
), AxoSyslog assumes that the incoming log message was sent by the host specified in theHOST
field of the message. -
If disabled (
keep-hostname(no)
), AxoSyslog rewrites theHOST
field of the message, either to the IP address (if theuse-dns()
parameter is set tono
), or to the hostname (if theuse-dns()
parameter is set toyes
and the IP address can be resolved to a hostname) of the host sending the message to AxoSyslog. For details on using name resolution in AxoSyslog, see Using name resolution in syslog-ng.
If the log message does not contain a hostname in its HOST
field, AxoSyslog automatically adds a hostname to the message.
-
For messages received from the network, this hostname is the address of the host that sent the message (this means the address of the last hop if the message was transferred via a relay).
-
For messages received from the local host, AxoSyslog adds the name of the host.
This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
log-iw-size()
Type: | number |
Default: | 100 |
Description: The size of the initial window, this value is used during flow-control. Its value cannot be lower than 100, unless the dynamic-window-size()
option is enabled. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
loaders()
Type: | list of python modules |
Default: | empty list |
Description: The AxoSyslog application imports Python modules specified in this option, before importing the code of the Python class. This option has effect only when the Python class is provided in an external Python file. This option has no effect when the Python class is provided within the AxoSyslog configuration file (in a python{}
block). You can use the loaders()
option to modify the import mechanism that imports Python class. For example, that way you can use hy in your Python class.
python(class(usermodule.HyParser) loaders(hy))
options()
Type: | string |
Default: | N/A |
Description: This option allows you to pass custom values from the configuration file to the Python code. Enclose both the option names and their values in double-quotes. The Python code will receive these values during initialization as the options
dictionary. For example, you can use this to set the IP address of the server from the configuration file, so it is not hard-coded in the Python object.
python(
class("MyPythonClass")
options(
"host" "127.0.0.1"
"port" "1883"
"otheroption" "value")
);
For example, you can refer to the value of the host field in the Python code as options["host"]
. Note that the Python code receives the values as strings, so you might have to cast them to the type required, for example: int(options["port"])
From version 3.27, AxoSyslog supports the arrow syntax for declaring custom Java and Python options. You can alternatively declare them using a similar syntax:
options(
"host" => "localhost"
"port" => "1883"
"otheroption" => "value"
)
persist-name()
Type: | string |
Default: | N/A |
Description: If you receive the following error message during AxoSyslog startup, set the persist-name()
option of the duplicate drivers:
Error checking the uniqueness of the persist names, please override it with persist-name option. Shutting down.
This error happens if you use identical drivers in multiple sources, for example, if you configure two file sources to read from the same file. In this case, set the persist-name()
of the drivers to a custom string, for example, persist-name("example-persist-name1")
.
Starting with 3.26, AxoSyslog assigns a persist name to Python sources and destinations. The persist name is generated from the class name. If you want to use the same Python class multiple times in your AxoSyslog configuration, add a unique persist-name()
to each source or destination, otherwise AxoSyslog will not start. For example:
log {
source { python(class(PyNetworkSource) options("port" "8080") persist-name("<unique-string>); };
source { python(class(PyNetworkSource) options("port" "8081")); };
};
Alternatively, you can include the following line in the Python package: @staticmethod generate_persist_name
. For example:
from syslogng import LogSource
class PyNetworSource(LogSource):
@staticmethod
def generate_persist_name(options):
return options["port"]
def run(self):
pass
def request_exit(self):
pass
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
time-reopen()
Accepted values: | number [seconds] |
Default: | 1 |
Description: The time to wait in seconds before a dead connection is reestablished.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
23 - python-fetcher: writing fetcher-style Python sources
The Python source allows you to write your own source in Python. You can import external Python modules to receive or fetch the messages. Since many services have a Python library, the Python source makes integrating AxoSyslog very easy and quick.
You can write two different type of sources in Python:
-
Server-style sources that receives messages. Write server-style sources if you want to use an event-loop based, nonblocking server framework in Python, or if you want to implement a custom loop.
-
Fetcher-style sources that actively fetch messages. In general, write fetcher-style sources (for example, when using simple blocking APIs), unless you explicitly need a server-style source.
This section describes fetcher-style sources. For details on server-style sources, see python: writing server-style Python sources.
The following points apply to using Python blocks in AxoSyslog in general:
-
Python parsers and template functions are available in AxoSyslog version 3.10 and later.
Python destinations and sources are available in AxoSyslog version 3.18 and later.
-
Supported Python versions: 2.7 and 3.4+ (if you are using pre-built binaries, check the dependencies of the package to find out which Python version it was compiled with).
-
The Python block must be a top-level block in the AxoSyslog configuration file.
-
If you store the Python code in a separate Python file and only include it in the AxoSyslog configuration file, make sure that the PYTHONPATH environment variable includes the path to the Python file, and export the PYTHON_PATH environment variable. For example, if you start AxoSyslog manually from a terminal and you store your Python files in the
/opt/syslog-ng/etc
directory, use the following command:export PYTHONPATH=/opt/syslog-ng/etc
.In production, when AxoSyslog starts on boot, you must configure your startup script to include the Python path. The exact method depends on your operating system. For recent Red Hat Enterprise Linux, Fedora, and CentOS distributions that use systemd, the
systemctl
command sources the/etc/sysconfig/syslog-ng
file before starting AxoSyslog. (On openSUSE and SLES,/etc/sysconfig/syslog
file.) Append the following line to the end of this file:PYTHONPATH="<path-to-your-python-file>"
, for example,PYTHONPATH="/opt/syslog-ng/etc"
. -
The Python object is initiated every time when AxoSyslog is started or reloaded.
Warning If you reload AxoSyslog, existing Python objects are destroyed, therefore the context and state information of Python blocks is lost. Log rotation and updating the configuration of AxoSyslog typically involves a reload. -
The Python block can contain multiple Python functions.
-
Using Python code in AxoSyslog can significantly decrease the performance of AxoSyslog, especially if the Python code is slow. In general, the features of AxoSyslog are implemented in C, and are faster than implementations of the same or similar features in Python.
-
Validate and lint the Python code before using it. The AxoSyslog application does not do any of this.
-
Python error messages are available in the
internal()
source of AxoSyslog. -
You can access the name-value pairs of AxoSyslog directly through a message object or a dictionary.
-
To help debugging and troubleshooting your Python code, you can send log messages to the
internal()
source of AxoSyslog. For details, see Logging from your Python code.
Declaration:
Python sources consist of two parts. The first is a AxoSyslog source object that you define in your AxoSyslog configuration and use in the log path. This object references a Python class, which is the second part of the Python source. The Python class receives or fetches the log messages, and can do virtually anything that you can code in Python. You can either embed the Python class into your AxoSyslog configuration file, or store it in an external Python file.
source <name_of_the_python_source>{
python-fetcher(
class("<name_of_the_python_class_executed_by_the_source>")
);
};
python {
from syslogng import LogFetcher
from syslogng import LogMessage
class <name_of_the_python_class_executed_by_the_source>(LogFetcher):
def init(self, options): # optional
print("init")
print(options)
return True
def deinit(self): # optional
print("deinit")
def open(self): # optional
print("open")
return True
def fetch(self): # mandatory
print("fetch")
# return LogFetcher.FETCH_ERROR,
# return LogFetcher.FETCH_NOT_CONNECTED,
# return LogFetcher.FETCH_TRY_AGAIN,
# return LogFetcher.FETCH_NO_DATA,
return LogFetcher.FETCH_SUCCESS, msg
def request_exit(self):
print("request_exit")
# If your fetching method is blocking, do something to break it
# For example, if it reads a socket: socket.shutdown()
def close(self): # optional
print("close")
};
Methods of the python-fetcher() source
Fetcher-style Python sources must be inherited from the syslogng.LogFetcher
class, and must implement at least the fetch
method. Multiple inheritance is allowed, but only for pure Python super classes.
For fetcher-style Python sources, AxoSyslog handles the event loop and the scheduling automatically. You can use simple blocking server/client libraries to receive or fetch logs.
You can retrieve messages using the fetch()
method.
init(self, options) method (optional)
The AxoSyslog application initializes Python objects every time when it is started or reloaded. The init
method is executed as part of the initialization. You can perform any initialization steps that are necessary for your source to work.
When this method returns with False, AxoSyslog does not start. It can be used to check options and return False when they prevent the successful start of the source.
options
: This optional argument contains the contents of the options()
parameter of the AxoSyslog configuration object as a Python dictionary.
open(self) method (optional)
The open(self)
method opens the resources required for the source, for example, it initiates a connection to the target service. It is called after init()
when AxoSyslog is started or reloaded. If fetch()
returns with an error, AxoSyslog calls the close()
and open()
methods before trying to fetch a new message.
If open()
fails, it should return the False value. In this case, AxoSyslog retries it every time-reopen()
seconds. By default, this is 1 second for Python sources and destinations, the value of time-reopen()
is not inherited from the global option. For details, see Error handling in the python() destination.
fetch(self) method (mandatory)
Use the fetch
method to fetch messages and pass them to the log paths.
For details on parsing messages, see Python LogMessage API.
The fetch
method must return one of the following values:
-
LogFetcher.FETCH_ERROR
: Fetching new messages failed, AxoSyslog calls theclose
andopen
methods. -
LogFetcher.FETCH_NO_DATA
: There was not any data available. The source waits before calling the fetch method again. The wait time is equal totime-reopen()
by default, but you can override it by setting thefetch-no-data-delay()
option in the source. -
LogFetcher.FETCH_NOT_CONNECTED
: Could not access the source, AxoSyslog calls theopen
method. -
LogFetcher.FETCH_SUCCESS, msg
: Post the message returned as the second argument. -
LogFetcher.FETCH_TRY_AGAIN
: The fetcher could not provide a message this time, but will make the source call the fetch method as soon as possible.
request_exit(self) method (optional)
If you use blocking operations within the fetch()
method, use request_exit()
to interrupt those operations (for example, to shut down a socket), otherwise AxoSyslog is not able to stop. Note that AxoSyslog calls the request_exit
method from a thread different from the source thread.
close(self) method (optional)
Close the connection to the target service. Usually it is called right before deinit()
when stopping or reloading AxoSyslog. It is also called when fecth()
fails.
close_batch(self)
Closes the current source-side batch. Source-side batching helps AxoSyslog to effectively process a larger chunk of messages, instead of processing messages each message. For example, when feeding a destination queue and instead of taking a lock on the queue for every message (causing contention), we only take it once per batch.
The native drivers built into AxoSyslog typically close batches once every mainloop iteration, allowing a single iteration to process multiple messages. For instance, when receiving multiple messages in a single TCP datagram, all of those messages can be processed as a part of the same batch.
In Python-based log sources, a batch will automatically be closed after every message posted via post_message()
, except if self.auto_close_batches
is set to False
during initialization. In case self.auto_close_batches
is set to False
, the driver has to call close_batch()
explicitly, preferably at a natural boundary between incoming batches of messages. A good example is when we retrieve several messages via the same HTTP REST call, then the right time to close the batch would be after the last message in the response is posted.
The deinit(self) method (optional)
This method is executed when AxoSyslog is stopped or reloaded. This method does not return a value.
For the list of available optional parameters, see python() and python-fetcher() source options.
24 - qBittorrent logs
Starting with version 4.6.0, AxoSyslog can collect logs of the qBittorrent application.
source s_qbittorrent {
qbittorrent(
dir("/path/to/qbittorrent-root-log-dir")
);
};
To configure the source, you only have to specify the root log directory of qBittorrent in the dir()
parameter. You can find the root log directory by selecting Tools > Preferences > Behavior > Log file > Save path in the qBittorrent application. Otherwise, the qbittorrent()
source has the same parameters as the file()
source.
The qbittorrent()
driver is actually a reusable configuration snippet. For details on using or writing such configuration snippets, see Reusing configuration blocks. You can find the source of this configuration snippet on GitHub.
25 - snmptrap: Read Net-SNMP traps
Using the snmptrap()
source, you can read and parse the SNMP traps of the Net-SNMP’s snmptrapd
application. AxoSyslog can read these traps from a log file, and extract their content into name-value pairs, making it easy to forward them as a structured log message (for example, in JSON format). The AxoSyslog application automatically adds the .snmp.
prefix to the name of the fields the extracted from the message.
The snmptrap()
source is available in AxoSyslog version 3.10 and later.
Limitations:
-
The
snmptrap()
source has only the options listed in snmptrap() source options. Other options commonly available in other source drivers are not supported. -
In addition to traps, the log of
snmptrapd
may contain other messages (for example, daemon start/stop information, debug logs) as well. Currently AxoSyslog discards these messages. -
The AxoSyslog application cannot resolve OIDs, you have to configure
snmptrapd
to do so. Note that because of a bug, ifsnmptrapd
does not escape String values in the VarBindList if it can resolve an OID to a symbolic name. As a result, AxoSyslog cannot process traps that contain the=
in the value of the string. To overcome this problem, disable resolving OIDs insnmptrapd
. For details, see the documentation ofsnmptrapd
. -
The colon (
:
) character is commonly used in SNMP traps. However, this character cannot be used in the name of AxoSyslog macros (name-value pairs). Therefore, the AxoSyslog application automatically replaces all consecutive:
characters with a single underscore (_
) character. For example, you can reference the value of theNET-SNMP-EXAMPLES-MIB::netSnmpExampleString
key using the${NET-SNMP-EXAMPLES-MIB_netSnmpExampleString}
macro.Note that this affects only name-value pairs (macros). The generated message always contains the original name of the key.
Prerequisites:
-
Configure
snmptrapd
to log into a file. -
If you use SMIv1 traps, include the following format string in the configuration file of
snmptrapd
:format1 %.4y-%.2m-%.2l %.2h:%.2j:%.2k %B [%b]: %N\n\t%W Trap (%q) Uptime: %#T\n%v\n
-
If you use SMIv2 traps, use the default format. The
snmptrap()
source of AxoSyslog expects this default format:format2 %.4y-%.2m-%.2l %.2h:%.2j:%.2k %B [%b]:\n%v\n
-
Beacause of an
snmptrapd
bug, if you specify the filename in the configuration file withlogOption
, you must also specify another output as a command line argument (-Lf, -Ls). Otherwise,snmptrapd
will not apply the the trap format.
To use the snmptrap()
driver, the scl.conf
file must be included in your AxoSyslog configuration:
@include "scl.conf"
Example: Using the snmptrap() driver
A sample snmptrapd
configuration:
authCommunity log,execute,net public
format1 %.4y-%.2m-%.2l %.2h:%.2j:%.2k %B [%b]: %N\n\t%W Trap (%q) Uptime: %#T\n%v\n
outputOption s
Starting snmptrapd
: snmptrapd -A -Lf /var/log/snmptrapd.log
Sending a sample V2 trap message: snmptrap -v2c -c public 127.0.0.1 666 NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification netSnmpExampleHeartbeatRate i 60 netSnmpExampleString s "string"
. From this trap, AxoSyslog receives the following input:
2017-05-23 15:29:40 localhost [UDP: [127.0.0.1]:59993->[127.0.0.1]:162]:
SNMPv2-SMI::mib-2.1.3.0 = Timeticks: (666) 0:00:06.66 SNMPv2-SMI::snmpModules.1.1.4.1.0 = OID: NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatRate = INTEGER: 60 NET-SNMP-EXAMPLES-MIB::netSnmpExampleString = STRING: string
The following AxoSyslog configuration sample uses the default settings of the driver, reading SNMP traps from the /var/log/snmptrapd.log
file, and writes the log messages generated from the traps into a file.
@include "scl.conf"
log {
source {
snmptrap(filename("/var/log/snmptrapd.log"));
};
destination {
file("/var/log/example.log");
};
};
From the trap, AxoSyslog writes the following into the log file:
May 23 15:29:40 myhostname snmptrapd: hostname='localhost', transport_info='UDP: [127.0.0.1]:59993->[127.0.0.1]:162', SNMPv2-SMI::mib-2.1.3.0='(666) 0:00:06.66', SNMPv2-SMI::snmpModules.1.1.4.1.0='NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification', NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatRate='60', NET-SNMP-EXAMPLES-MIB::netSnmpExampleString='string'
Using the same input trap, the following configuration example formats the SNMP traps as JSON messages.
@include "scl.conf"
log {
source {
snmptrap(
filename("/var/log/snmptrapd.log")
set-message-macro(no)
);
};
destination {
file("/var/log/example.log" template("$(format-json --scope dot-nv-pairs)\n"));
};
};
The previous trap formatted as JSON:
{
"_snmp":{
"transport_info":"UDP: [127.0.0.1]:59993->[127.0.0.1]:162",
"hostname":"localhost",
"SNMPv2-SMI_snmpModules":{
"1":{
"1":{
"4":{
"1":{
"0":"NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification"
}
}
}
}
},
"SNMPv2-SMI_mib-2":{
"1":{
"3":{
"0":"(666) 0:00:06.66"
}
}
},
"NET-SNMP-EXAMPLES-MIB_netSnmpExampleString":"string",
"NET-SNMP-EXAMPLES-MIB_netSnmpExampleHeartbeatRate":"60"
}
}
25.1 - snmptrap() source options
The snmptrap()
driver has the following options. Only the filename()
option is required, the others are optional.
filename()
Type: | path |
Default: |
Description: The log file of snmptrapd
. The AxoSyslog application reads the traps from this file.
In addition to traps, the log of snmptrapd
may contain other messages (for example, daemon start/stop information, debug logs) as well. Currently AxoSyslog discards these messages.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
persist-name()
Type: | string |
Default: | N/A |
Description: If you receive the following error message during AxoSyslog startup, set the persist-name()
option of the duplicate drivers:
Error checking the uniqueness of the persist names, please override it with persist-name option. Shutting down.
This error happens if you use identical drivers in multiple sources, for example, if you configure two file sources to read from the same file. In this case, set the persist-name()
of the drivers to a custom string, for example, persist-name("example-persist-name1")
.
prefix()
Synopsis: | prefix() |
Description: Insert a prefix before the name part of the parsed name-value pairs to help further processing. For example:
-
To insert the
my-parsed-data.
prefix, use theprefix(my-parsed-data.)
option. -
To refer to a particular data that has a prefix, use the prefix in the name of the macro, for example,
${my-parsed-data.name}
. -
If you forward the parsed messages using the IETF-syslog protocol, you can insert all the parsed data into the SDATA part of the message using the
prefix(.SDATA.my-parsed-data.)
option.
Names starting with a dot (for example, .example
) are reserved for use by AxoSyslog. If you use such a macro name as the name of a parsed value, it will attempt to replace the original value of the macro (note that only soft macros can be overwritten, see Hard versus soft macros for details). To avoid such problems, use a prefix when naming the parsed values, for example, prefix(my-parsed-data.)
Default value: .snmp.
option.
set-message-macro()
Type: | `yes |
Default: | yes |
Description: The snmptrap()
source automatically parses the traps into name-value pairs, so you can handle the content of the trap as a structured message. Consequently, you might not even need the ${MESSAGE}
part of the log message. If set-message-macro()
is set to no
, AxoSyslog leaves the ${MESSAGE}
part empty. If set-message-macro()
is set to yes
, AxoSyslog generates a regular log message from the trap.
26 - sun-streams: Collect messages on Sun Solaris
Solaris uses its STREAMS
framework to send messages to the syslogd
process. Solaris 2.5.1 and above uses an IPC called door in addition to STREAMS
, to confirm the delivery of a message. The AxoSyslog application supports the IPC mechanism via the door()
option (see below).
sun-streams()
driver must be enabled when the syslog-ng
application is compiled (see ./configure --help
).
The sun-streams()
driver has a single required argument specifying the STREAMS
device to open, and the door()
option. For the list of available optional parameters, see sun-streams() source options.
system()
driver automatically extracts the msgid from the message (if available), and stores it in the .solaris.msgid
macro. To extract the msgid from the message without using the system()
driver, use the extract-solaris-msgid()
parser. You can find the exact source of this parser in the AxoSyslog GitHub repository.
Declaration:
sun-streams(<name_of_the_streams_device> door(<filename_of_the_door>));
Example: Using the sun-streams() driver
source s_stream {
sun-streams("/dev/log" door("/etc/.syslog_door"));
};
26.1 - sun-streams() source options
The sun-streams()
driver has the following options.
door()
Type: | string |
Default: | none |
Description: Specifies the filename of a door to open, needed on Solaris above 2.5.1.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
follow-freq()
Type: | number |
Default: | 1 |
Description: Indicates that the source should be checked periodically. This is useful for files which always indicate readability, even though no new lines were appended. If this value is higher than zero, AxoSyslog will not attempt to use poll()
on the file, but checks whether the file changed every time the follow-freq()
interval (in seconds) has elapsed. Floating-point numbers (for example, 1.5
) can be used as well.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
keep-timestamp()
Type: | yes or no |
Default: | yes |
Description: Specifies whether AxoSyslog should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
S_
macros, the keep-timestamp()
option must be enabled (this is the default behavior of AxoSyslog).
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
log-iw-size()
Type: | number |
Default: | 100 |
Description: The size of the initial window, this value is used during flow-control. Its value cannot be lower than 100, unless the dynamic-window-size()
option is enabled. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
log-msg-size()
Type: | number (bytes) |
Default: | Use the global log-msg-size() option, which defaults to 65536 (64 KiB). |
Description: Maximum length of an incoming message in bytes. This length includes the entire message (the data structure and individual fields). The maximal value that can be set is 268435456 bytes (256 MiB).
For messages using the IETF-syslog message format (RFC5424), the maximal size of the value of an SDATA field is 64 KiB.
log-msg-size()
does not need to be set higher than 10 MiB.
For details on how encoding affects the size of the message, see Message size and encoding.
You can use human-readable units when setting configuration options. For details, seeNotes about the configuration syntax.
Uses the value of the global option if not specified.
log-prefix() (DEPRECATED)
Type: | string |
Default: |
Description: A string added to the beginning of every log message. It can be used to add an arbitrary string to any log source, though it is most commonly used for adding kernel:
to the kernel messages on Linux.
program-override
instead.
optional()
Type: | yes or no |
Default: |
Description: Instruct AxoSyslog to ignore the error if a specific source cannot be initialized. No other attempts to initialize the source will be made until the configuration is reloaded. This option currently applies to the pipe()
, unix-dgram
, and unix-stream
drivers.
pad-size()
Type: | number |
Default: | 0 |
Description: Specifies input padding. Some operating systems (such as HP-UX) pad all messages to block boundary. This option can be used to specify the block size. The AxoSyslog application will pad reads from the associated device to the number of bytes set in pad-size()
. Mostly used on HP-UX where /dev/log
is a named pipe and every write is padded to 2048 bytes. If pad-size()
was given and the incoming message does not fit into pad-size()
, AxoSyslog will not read anymore from this pipe and displays the following error message:
Padding was set, and couldn't read enough bytes
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
27 - syslog: Collect messages using the IETF-syslog protocol
The syslog()
driver can receive messages from the network using the standard IETF-syslog protocol (as described in RFC5424-26). UDP, TCP, and TLS-encrypted TCP can all be used to transport the messages.
The syslog()
driver can also receive BSD-syslog-formatted messages (described in RFC 3164, see BSD-syslog or legacy-syslog messages) if they are sent using the IETF-syslog protocol.
In AxoSyslog versions 3.1 and earlier, the syslog()
driver could handle only messages in the IETF-syslog (RFC 5424-26) format.
Starting with version 4.10, AxoSyslog can automatically detect RFC6587-style octet-count based framing. For details, see the transport option.
For the list of available optional parameters, see syslog() source options.
Declaration:
syslog(ip() port() transport() options());
Example: Using the syslog() driver
TCP source listening on the localhost on port 1999.
source s_syslog { syslog(ip(127.0.0.1) port(1999) transport("tcp")); };
UDP source with defaults.
source s_udp { syslog( transport("udp")); };
Encrypted source where the client is also authenticated. For details on the encryption settings, see TLS options.
source s_syslog_tls{ syslog(
ip(10.100.20.40)
transport("tls")
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/server_privatekey.pem')
cert-file('/opt/syslog-ng/etc/syslog-ng/keys/server_certificate.pem')
)
);
};
When receiving messages using the UDP protocol, increase the size of the UDP receive buffer on the receiver host (that is, the AxoSyslog server or relay receiving the messages). Note that on certain platforms, for example, on Red Hat Enterprise Linux 5, even low message load (~200 messages per second) can result in message loss, unless the so-rcvbuf()
option of the source is increased. In this cases, you will need to increase the net.core.rmem_max
parameter of the host (for example, to 1024000
), but do not modify net.core.rmem_default
parameter.
As a general rule, increase the so-rcvbuf()
so that the buffer size in kilobytes is higher than the rate of incoming messages per second. For example, to receive 2000 messages per second, set the so-rcvbuf()
at least to 2 097 152
bytes.
27.1 - syslog() source options
The syslog()
driver has the following options.
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
.
check-hostname()
Type: | boolean (yes or no ) |
Default: | Use the global check-hostname() option, which defaults to no . |
Description:
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
Uses the value of the global option if not specified.
dynamic-window-size()
Type: | number |
Default: | 0 |
Description: The size of the dynamic control window used during flow-control. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
ebpf()
Available in AxoSyslog version 4.2 and newer.
By default, the kernel chooses the receive socket for a specific UDP randomly based on the source IP/port of the sender. You can customize this algorithm using the Extended Berkeley Packet Filter (eBPF) plugin. The ebpf()
option changes the kernel’s SO_REUSEPORT algorithm so that all messages are randomly placed into one of the UDP sockets. The decision which UDP socket buffer a datagram is placed is made for every datagram, and not once for every stream. This means that messages are perfectly load-balanced across your set of UDP sockets. While this resolves the imbalance between the sockets and results in perfect load balancing, you will lose ordering between messages from the same sender, which is the price to pay for increased throughput.
source s_network {
network(
transport("udp")
so-reuseport(1) persist-name("udp1")
ebpf(reuseport(sockets(4)))
);
network(transport("udp") so-reuseport(1) persist-name("udp2"));
network(transport("udp") so-reuseport(1) persist-name("udp3"));
network(transport("udp") so-reuseport(1) persist-name("udp4"));
};
For a detailed introduction, see the Scaling syslog to 1M EPS with eBPF blog post.
encoding()
Type: | string |
Default: |
Description: Specifies the character set (encoding, for example, UTF-8
) of messages using the legacy BSD-syslog protocol. To list the available character sets on a host, execute the iconv -l
command. For details on how encoding affects the size of the message, see Message size and encoding.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
-
threaded: The
threaded
flag enables multithreading for the source. For details on multithreading, see Multithreading and scaling.Note Thesyslog
source uses multiple threads only if the source uses thetls
ortcp
transport protocols.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
host-override()
Type: | string |
Default: |
Description: Replaces the ${HOST} part of the message with the parameter string.
idle-timeout()
Accepted values: | number [seconds] |
Default: | 0 (disabled) |
Available in AxoSyslog 4.9 and later.
If set, AxoSyslog closes the client connection if no data is received for the specified amount of time (in seconds).
interface()
Type: | string |
Default: | None |
Description: Bind to the specified interface instead of an IP address. Available in 3.19 and later.
ip() or localip()
Type: | string |
Default: | 0.0.0.0 |
Description: The IP address to bind to. By default, AxoSyslog listens on every available interface. Note that this is not the address where messages are accepted from.
If you specify a multicast bind address and use the udp
transport, AxoSyslog automatically joins the necessary multicast group. TCP does not support multicasting.
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 sources should be closed when AxoSyslog is forced to reload its configuration (upon the receipt of a SIGHUP signal). Note that this applies to the server (source) side of the AxoSyslog connections, client-side (destination) connections are always reopened after receiving a HUP signal unless the keep-alive
option is enabled for the destination.
keep-hostname()
Type: | yes or no |
Default: | no |
Description: Enable or disable hostname rewriting.
-
If enabled (
keep-hostname(yes)
), AxoSyslog assumes that the incoming log message was sent by the host specified in theHOST
field of the message. -
If disabled (
keep-hostname(no)
), AxoSyslog rewrites theHOST
field of the message, either to the IP address (if theuse-dns()
parameter is set tono
), or to the hostname (if theuse-dns()
parameter is set toyes
and the IP address can be resolved to a hostname) of the host sending the message to AxoSyslog. For details on using name resolution in AxoSyslog, see Using name resolution in syslog-ng.
If the log message does not contain a hostname in its HOST
field, AxoSyslog automatically adds a hostname to the message.
-
For messages received from the network, this hostname is the address of the host that sent the message (this means the address of the last hop if the message was transferred via a relay).
-
For messages received from the local host, AxoSyslog adds the name of the host.
This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
keep-timestamp()
Type: | yes or no |
Default: | yes |
Description: Specifies whether AxoSyslog should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
S_
macros, the keep-timestamp()
option must be enabled (this is the default behavior of AxoSyslog).
listen-backlog()
Type: | integer |
Default: | 256 |
Description: Available only for stream based transports (unix-stream
, tcp
, tls
). In TCP, connections are treated incomplete until the three-way handshake is completed between the server and the client. Incomplete connection requests wait on the TCP port for the listener to accept the request. The listen-backlog()
option sets the maximum number of incomplete connection requests. For example:
source s_network {
network(
ip("192.168.1.1")
transport("tcp")
listen-backlog(2048)
);
};
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
log-iw-size()
Type: | number |
Default: | 100 |
Description: The size of the initial window, this value is used during flow-control. Its value cannot be lower than 100, unless the dynamic-window-size()
option is enabled. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
If the max-connections()
option is set, the log-iw-size()
will be divided by the number of connections, otherwise log-iw-size()
is divided by 10 (the default value of the max-connections()
option). The resulting number is the initial window size of each connection. For optimal performance when receiving messages from AxoSyslog clients, make sure that the window size is larger than the flush-lines()
option set in the destination of your clients.
Example: Initial window size of a connection
If log-iw-size(1000)
and max-connections(10)
, then each connection will have an initial window size of 100.
log-msg-size()
Type: | number (bytes) |
Default: | Use the global log-msg-size() option, which defaults to 65536 (64 KiB). |
Description: Maximum length of an incoming message in bytes. This length includes the entire message (the data structure and individual fields). The maximal value that can be set is 268435456 bytes (256 MiB).
For messages using the IETF-syslog message format (RFC5424), the maximal size of the value of an SDATA field is 64 KiB.
log-msg-size()
does not need to be set higher than 10 MiB.
For details on how encoding affects the size of the message, see Message size and encoding.
You can use human-readable units when setting configuration options. For details, seeNotes about the configuration syntax.
Uses the value of the global option if not specified.
max-connections()
Type: | number |
Default: | 10 |
Description: Specifies the maximum number of simultaneous connections.
pad-size()
Type: | number |
Default: | 0 |
Description: Specifies input padding. Some operating systems (such as HP-UX) pad all messages to block boundary. This option can be used to specify the block size. The AxoSyslog application will pad reads from the associated device to the number of bytes set in pad-size()
. Mostly used on HP-UX where /dev/log
is a named pipe and every write is padded to 2048 bytes. If pad-size()
was given and the incoming message does not fit into pad-size()
, AxoSyslog will not read anymore from this pipe and displays the following error message:
Padding was set, and couldn't read enough bytes
port() or localport()
Type: | number |
Default: | In case of TCP transport: 514 In case of UDP transport: 514 |
Description: The port number to bind to.
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
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.
When receiving messages using the UDP protocol, increase the size of the UDP receive buffer on the receiver host (that is, the AxoSyslog server or relay receiving the messages). Note that on certain platforms, for example, on Red Hat Enterprise Linux 5, even low message load (~200 messages per second) can result in message loss, unless the so-rcvbuf()
option of the source is increased. In this cases, you will need to increase the net.core.rmem_max
parameter of the host (for example, to 1024000
), but do not modify net.core.rmem_default
parameter.
As a general rule, increase the so-rcvbuf()
so that the buffer size in kilobytes is higher than the rate of incoming messages per second. For example, to receive 2000 messages per second, set the so-rcvbuf()
at least to 2 097 152
bytes.
so-reuseport()
Type: | yes or no |
Default: | no |
Description: Enables SO_REUSEPORT on systems that support it. When enabled, the kernel allows multiple UDP sockets to be bound to the same port, and the kernel load-balances incoming UDP datagrams to the sockets. The sockets are distributed based on the hash of (srcip, dstip, srcport, dstport), so the same listener should be receiving packets from the same endpoint. For example:
source {
network(transport("udp") so-reuseport(1) port(2000) persist-name("udp1"));
network(so-reuseport(1) port(2000) persist-name("udp2"));
network(so-reuseport(1) port(2000) persist-name("udp3"));
network(so-reuseport(1) port(2000) persist-name("udp4"));
};
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-sndbuf()
Type: | number |
Default: | 0 |
Description: Specifies the size of the socket send buffer in bytes. For details, see the socket(7)
manual page.
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
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.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
transport()
Type: | auto , proxied-tcp , proxied-tls , proxied-tls-passthrough , tcp , text-with-nuls , tls , udp |
Default: | tcp |
Description: Specifies the protocol used to receive messages from the source.
-
auto
: Available in version 4.10 and later. Automatically detects RFC6587-style octet-count based framing in TCP traffic. In future versions this functionality will be extended to cover and detect all TCP-based protocols. -
proxied-tcp
,proxied-tls
,proxied-tls-passthrough
: Refers to the HAProxy Proxy Protocol. For details, see Proxy Protocol support. -
text-with-nuls
: Allows embeddedNUL
characters in the message from a TCP source, that is, AxoSyslog will not delimiter the incoming messages onNUL
characters, only onnewline
characters (contrary totcp
transport, which splits the incoming log onnewline
characters andNUL
characters).Note The AxoSyslog application does not support embeddedNUL
characters everywhere, so it is recommended that you also useflags(no-multi-line)
that causesNUL
characters to be replaced by space.
When receiving messages using the UDP protocol, increase the size of the UDP receive buffer on the receiver host (that is, the AxoSyslog server or relay receiving the messages). Note that on certain platforms, for example, on Red Hat Enterprise Linux 5, even low message load (~200 messages per second) can result in message loss, unless the so-rcvbuf()
option of the source is increased. In this cases, you will need to increase the net.core.rmem_max
parameter of the host (for example, to 1024000
), but do not modify net.core.rmem_default
parameter.
As a general rule, increase the so-rcvbuf()
so that the buffer size in kilobytes is higher than the rate of incoming messages per second. For example, to receive 2000 messages per second, set the so-rcvbuf()
at least to 2 097 152
bytes.
trim-large-messages()
Type: | `yes |
Default: | Use the global trim-large-messages() option, which defaults to no . |
Description: Determines what AxoSyslog does with incoming log messages that are received using the IETF-syslog protocol using the syslog()
driver, and are longer than the value of log-msg-size()
. Other drivers ignore the trim-large-messages()
option.
-
If set to
no
, AxoSyslog drops the incoming log message. -
If set to
yes
, AxoSyslog trims the incoming log message to the size set inlog-msg-size()
, and adds thetrimmed
tag to the message. The rest of the message is dropped. You can use the tag to filter on such messages.filter f_trimmed { tags("trimmed"); };
If AxoSyslog trims a log message, it sends a debug-level log message to its
internal()
source.As a result of trimming, a parser could fail to parse the trimmed message. For example, a trimmed JSON or XML message will not be valid JSON or XML.
Available in AxoSyslog version 3.21 and later.
Uses the value of the global option if not specified.
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.
use-dns()
Type: | yes, no, persist_only |
Default: | yes |
Description: Enable or disable DNS usage. The persist_only
option attempts to resolve hostnames locally from file (for example, from /etc/hosts
). The AxoSyslog application blocks on DNS queries, so enabling DNS may lead to a Denial of Service attack. To prevent DoS, protect your AxoSyslog network endpoint with firewall rules, and make sure that all hosts which may get to AxoSyslog are resolvable. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
keep-hostname()
option is enabled (keep-hostname(yes)
) and the message contains a hostname.
use-fqdn()
Type: | yes or no |
Default: | no |
Description: Use this option to add a Fully Qualified Domain Name (FQDN) instead of a short hostname. You can specify this option either globally or per-source. The local setting of the source overrides the global option if available.
use-fqdn()
to yes
if you want to use the custom-domain()
global option.
keep-hostname()
option is enabled (keep-hostname(yes)
) and the message contains a hostname.
28 - syslog-ng-otlp(): Receive logs from another node using OpenTelemetry
Available in AxoSyslog version 4.4 and later.
The syslog-ng-otlp()
source and destination allows you to transfer the internal representation of log messages between AxoSyslog instances using the OpenTelemetry protocol. Unlike the traditional syslog-ng() drivers that rely on simple TCP connections, syslog-ng-otlp()
leverages the OpenTelemetry protocol for efficient and reliable log message transmission.
The key benefits of the syslog-ng-otlp()
drivers are:
- scalability (via the
workers()
option), - built-in application layer acknowledgement,
- support for Google service authentication (ADC or ALTS), and
- improved load balancing capabilities.
To use it, configure a syslog-ng-otlp()
destination on the sender node, and a syslog-ng-otlp()
source on the receiver node, like this:
destination d_syslog_ng_otlp {
syslog-ng-otlp(url("your-receiver-syslog-ng-instance:4317"));
};
source s_syslog_ng_otlp {
syslog-ng-otlp(port(4317));
};
Options
The syslog-ng-otlp()
source has the following options.
auth()
You can set authentication in the auth()
option of the driver. By default, authentication is disabled (auth(insecure())
).
The following authentication methods are available in the auth()
block:
adc()
Application Default Credentials (ADC). This authentication method is only available for destinations.
alts()
Application Layer Transport Security (ALTS) is a simple to use authentication, only available within Google’s infrastructure. It accepts the target-service-account()
option, where you can list service accounts to match against when authenticating the server.
source {
opentelemetry(
port(4317)
auth(alts())
);
};
destination {
loki(
port(12345)
auth(alts())
);
};
source {
syslog-ng-otlp(
port(4317)
auth(alts())
);
};
insecure()
This is the default method, authentication is disabled (auth(insecure())
).
tls()
tls()
accepts the key-file()
, cert-file()
, ca-file()
and peer-verify()
(possible values:
required-trusted
, required-untrusted
, optional-trusted
and optional-untrusted
) options.
destination {
opentelemetry(
url("your-otel-server:12346")
auth(
tls(
ca-file("/path/to/ca.pem")
key-file("/path/to/key.pem")
cert-file("/path/to/cert.pem")
)
)
);
};
destination {
loki(
url("your-loki-server:12346")
auth(
tls(
ca-file("/path/to/ca.pem")
key-file("/path/to/key.pem")
cert-file("/path/to/cert.pem")
)
)
);
};
destination {
syslog-ng-otlp(
url("your-otel-server:12346")
auth(
tls(
ca-file("/path/to/ca.pem")
key-file("/path/to/key.pem")
cert-file("/path/to/cert.pem")
)
)
);
};
Note:
tls(peer-verify())
is not available for theopentelemetry()
andloki()
destination.- The gRPC-based drivers (
opentelemetry()
andloki()
) have a differenttls()
block implementation from thenetwork()
orhttp()
drivers. Most features are the same.
chain-hostnames()
Accepted values: | yes , no |
Default: | no |
Description: Enable or disable the chained hostname format. For details, see the chain-hostnames() global option.
channel-args()
Type: | arrow list |
Default: | - |
Description: The channel-args()
option is available in gRPC-based drivers. It accepts name-value pairs and sets channel arguments defined in the GRPC Core library documentation. For example:
channel-args(
"grpc.loadreporting" => 1
"grpc.minimal_stack" => 0
)
concurrent-requests()
Type: | integer |
Default: | 2 |
Description: Configures the maximal number of in-flight gRPC requests per worker. Setting this value in the range of 10s or 100s is recommended when there are a high number of clients sending simultaneously. Ideally, workers() * concurrent-requests()
should be greater than or equal to the number of clients, but this can increase the memory usage.
default-facility()
Type: | facility string |
Default: | kern |
Description: This parameter assigns a facility value to the messages received from the file source if the message does not specify one.
default-level()
Type: | string |
Default: | notice |
Description: The default level value if the PRIORITY entry does not exist.
default-priority()
Type: | priority string |
Default: |
Description: This parameter assigns an emergency level to the messages received from the file source if the message does not specify one. For example, default-priority(warning)
.
dns-cache()
Accepted values: | yes , no |
Default: | no |
Description: Enable or disable DNS cache usage.
ebpf()
Available in AxoSyslog version 4.2 and newer.
By default, the kernel chooses the receive socket for a specific UDP randomly based on the source IP/port of the sender. You can customize this algorithm using the Extended Berkeley Packet Filter (eBPF) plugin. The ebpf()
option changes the kernel’s SO_REUSEPORT algorithm so that all messages are randomly placed into one of the UDP sockets. The decision which UDP socket buffer a datagram is placed is made for every datagram, and not once for every stream. This means that messages are perfectly load-balanced across your set of UDP sockets. While this resolves the imbalance between the sockets and results in perfect load balancing, you will lose ordering between messages from the same sender, which is the price to pay for increased throughput.
source s_network {
network(
transport("udp")
so-reuseport(1) persist-name("udp1")
ebpf(reuseport(sockets(4)))
);
network(transport("udp") so-reuseport(1) persist-name("udp2"));
network(transport("udp") so-reuseport(1) persist-name("udp3"));
network(transport("udp") so-reuseport(1) persist-name("udp4"));
};
For a detailed introduction, see the Scaling syslog to 1M EPS with eBPF blog post.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
host-override()
Type: | string |
Default: |
Description: Replaces the ${HOST} part of the message with the parameter string.
keep-hostname()
The syslog-ng-otlp()
source ignores this option and uses the hostname from the message as the ${HOST}
.
keep-timestamp()
Type: | yes or no |
Default: | yes |
Description: Specifies whether AxoSyslog should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
S_
macros, the keep-timestamp()
option must be enabled (this is the default behavior of AxoSyslog).
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
log-iw-size()
Type: | number |
Default: | 10000 |
Description: The size of the initial window, this value is used during flow control. Make sure that log-iw-size()
is larger than the value of log-fetch-limit()
.
log-prefix() (DEPRECATED)
Type: | string |
Default: |
Description: A string added to the beginning of every log message. It can be used to add an arbitrary string to any log source, though it is most commonly used for adding kernel:
to the kernel messages on Linux.
program-override
instead.
normalize-hostnames()
Accepted values: | yes , no |
Default: | no |
Description: If enabled (normalize-hostnames(yes)
), AxoSyslog converts the hostnames to lowercase.
keep-hostname()
option is enabled, and the message contains a hostname.
persist-name()
Type: | string |
Default: | N/A |
Description: If you receive the following error message during AxoSyslog startup, set the persist-name()
option of the duplicate drivers:
Error checking the uniqueness of the persist names, please override it with persist-name option. Shutting down.
This error happens if you use identical drivers in multiple sources, for example, if you configure two file sources to read from the same file. In this case, set the persist-name()
of the drivers to a custom string, for example, persist-name("example-persist-name1")
.
port()
Type: | integer |
Default: |
Description: The port number to bind to.
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
time-reopen()
Accepted values: | number [seconds] |
Default: | 60 |
Description: The time to wait in seconds before a dead connection is reestablished.
use-dns()
Type: | yes, no, persist_only |
Default: | yes |
Description: Enable or disable DNS usage. The persist_only
option attempts to resolve hostnames locally from file (for example, from /etc/hosts
). The AxoSyslog application blocks on DNS queries, so enabling DNS may lead to a Denial of Service attack. To prevent DoS, protect your AxoSyslog network endpoint with firewall rules, and make sure that all hosts which may get to AxoSyslog are resolvable. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
keep-hostname()
option is enabled (keep-hostname(yes)
) and the message contains a hostname.
use-fqdn()
Type: | yes or no |
Default: | no |
Description: Use this option to add a Fully Qualified Domain Name (FQDN) instead of a short hostname. You can specify this option either globally or per-source. The local setting of the source overrides the global option if available.
use-fqdn()
to yes
if you want to use the custom-domain()
global option.
keep-hostname()
option is enabled (keep-hostname(yes)
) and the message contains a hostname.
workers()
Type: | integer |
Default: | 1 |
Description: Specifies the number of worker threads (at least 1) that AxoSyslog uses to process the messages of the source. Increasing the number of worker threads can drastically improve the performance of the source.
29 - system: Collect the system-specific log messages of a platform
Starting with version 3.2, AxoSyslog can automatically collect the system-specific log messages of the host on a number of platforms using the system()
driver. If the system()
driver is included in the AxoSyslog configuration file, AxoSyslog automatically adds the following sources to the AxoSyslog configuration.
system()
source, but this was problematic in certain situations, for example, when the host used a strict AppArmor profile. Therefore, the system()
source is now generated internally in AxoSyslog.
The system()
driver is also used in the default configuration file of AxoSyslog. For details on the default configuration file, see Example: The default configuration file of [%=General.OSE%]. Starting with AxoSyslog version 3.6, you can use the system-expand
command-line utility (which is a shell script, located in the modules/system-source/
directory) to display the configuration that the system()
source will use.
Starting with version 3.6, AxoSyslog parses messages complying with the Splunk Common Information Model (CIM) and marked with @cim
as JSON messages (for example, the ulogd from the netfilter project can emit such messages). That way, you can forward such messages without losing any information to CIM-aware applications (for example, Splunk).
Platform | Message source |
---|---|
AIX |
unix-dgram("/dev/log");
|
FreeBSD |
unix-dgram("/var/run/log");
unix-dgram("/var/run/logpriv" perm(0600));
file("/dev/klog" follow-freq(0) program-override("kernel") flags(no-parse));
For FreeBSD versions earlier than 9.1, |
GNU/kFreeBSD |
unix-dgram("/var/run/log");
file("/dev/klog" follow-freq(0) program-override("kernel"));
|
HP-UX |
pipe("/dev/log" pad-size(2048));
|
Linux |
Note that on Linux, the If the host is running under systemd, AxoSyslog reads both syslog and kernel messages directly from the systemd journal file using the If the kernel of the host is version 3.5 or newer, and If AxoSyslog is running in a jail or a Linux Container (LXC), it will not read from the
|
macOS |
file("/var/log/system.log" follow-freq(1));
Note
Starting with version 3.7, the AxoSyslog
system() driver automatically extracts the msgid from the message (if available), and stores it in the .solaris.msgid macro. To extract the msgid from the message without using the system() driver, use the extract-solaris-msgid() parser. You can find the exact source of this parser in the AxoSyslog GitHub repository.
|
NetBSD |
unix-dgram("/var/run/log");
Note
Starting with version 3.7, the AxoSyslog
system() driver automatically extracts the msgid from the message (if available), and stores it in the .solaris.msgid macro. To extract the msgid from the message without using the system() driver, use the extract-solaris-msgid() parser. You can find the exact source of this parser in the AxoSyslog GitHub repository.
|
Solaris 8 |
sun-streams("/dev/log");
Note
Starting with version 3.7, the AxoSyslog
system() driver automatically extracts the msgid from the message (if available), and stores it in the .solaris.msgid macro. To extract the msgid from the message without using the system() driver, use the extract-solaris-msgid() parser. You can find the exact source of this parser in the AxoSyslog GitHub repository.
|
Solaris 9 |
sun-streams("/dev/log" door("/etc/.syslog_door"));
Note
Starting with version 3.7, the AxoSyslog
system() driver automatically extracts the msgid from the message (if available), and stores it in the .solaris.msgid macro. To extract the msgid from the message without using the system() driver, use the extract-solaris-msgid() parser. You can find the exact source of this parser in the AxoSyslog GitHub repository.
|
Solaris 10 |
sun-streams("/dev/log" door("/var/run/syslog_door"));
Note
Starting with version 3.7, the AxoSyslog
system() driver automatically extracts the msgid from the message (if available), and stores it in the .solaris.msgid macro. To extract the msgid from the message without using the system() driver, use the extract-solaris-msgid() parser. You can find the exact source of this parser in the AxoSyslog GitHub repository.
|
29.1 - system() source options
The system()
driver has the following options:
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
30 - systemd-journal: Collect messages from the systemd-journal system log storage
The systemd-journal()
source is used on various Linux distributions, such as RHEL (from RHEL7) and CentOS. The systemd-journal()
source driver can read the structured name-value format of the journald system service, making it easier to reach the custom fields in the message. By default, AxoSyslog adds the .journald.
prefix to the name of every parsed value. For a list and description of name-value pairs that journald provides, see the documentation of journald for your platform (for example, man systemd.journal-fields
).
The systemd-journal()
source driver is designed to read only local messages through the systemd-journal API. It is not possible to set the location of the journal files, or the directories.
log-msg-size()
option is not applicable for this source. Use the max-field-size()
option instead.
This source will not handle the following cases:
- Corrupted journal file
- Incorrect journal configuration
- Any other journald-related bugs
systemd-journal()
instead of unix-dgram("/dev/log")
and file("/proc/kmsg")
. If you are using unix-dgram("/dev/log")
or unix-stream("/dev/log")
in your configuration as a source, AxoSyslog will revert to using systemd-journal()
instead.
systemd-journal()
source can be configured in the configuration file. If there is more than one systemd-journal()
source configured, AxoSyslog will not start.
Declaration:
systemd-journal(options);
If you want to use multiple systemd-journal()
sources in your configuration, the sources must use unique systemd namespaces. For details, see the namespace()
option.
Example: Send all fields through syslog protocol
To send all fields through the syslog protocol, enter the prefix in the following format: “.SDATA.<name>
”.
@version: 4.10.0
source s_journald {
systemd-journal(prefix(".SDATA.journald."));
};
destination d_network {
syslog("server.host");
};
log {
source(s_journald);
destination(d_network);
};
Example: Filter for a specific field
@version: 4.10.0
source s_journald {
systemd-journal(prefix(".SDATA.journald."));
};
filter f_uid {"${.SDATA.journald._UID}" eq "1000"};
destination d_network {
syslog("server.host");
};
log {
source(s_journald);
filter(f_uid);
destination(d_network);
};
Example: Send all fields in value-pairs
@version: 4.10.0
source s_local {
systemd-journal(prefix("journald."));
};
destination d_network {
network("server.host" template("$(format_json --scope rfc5424 --key journald.*)\n"));
};
log {
source(s_local);
destination(d_network);
};
The journal contains credential information about the process that sent the log message. The AxoSyslog application makes this information available in the following macros:
Journald fields as macros
Journald field | AxoSyslog predefined macro |
---|---|
MESSAGE | $MESSAGE |
_HOSTNAME | $HOST |
_PID | $PID |
_COMM or SYSLOG_IDENTIFIER | $PROGRAM If both _COMM and SYSLOG_IDENTIFIER exists, AxoSyslog uses SYSLOG_IDENTIFIER |
SYSLOG_FACILITY | $FACILITY_NUM |
PRIORITY | $LEVEL_NUM |
30.1 - systemd-journal() source options
The systemd-journal()
driver has the following options:
default-facility()
Type: | facility string |
Default: | local0 |
Description: The default facility value if the SYSLOG_FACILITY entry does not exist.
default-level()
Type: | string |
Default: | notice |
Description: The default level value if the PRIORITY entry does not exist.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
host-override()
Type: | string |
Default: |
Description: Replaces the ${HOST} part of the message with the parameter string.
keep-hostname()
Type: | yes or no |
Default: | no |
Description: Enable or disable hostname rewriting.
-
If enabled (
keep-hostname(yes)
), AxoSyslog will retain the hostname information read from the systemd journal messages. -
If disabled (
keep-hostname(no)
), AxoSyslog will use the hostname that has been set up for the operating system instance that AxoSyslog is running on. To query or set this value, use thehostnamectl
command.
This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
match-boot()
Type: | yes , no |
Default: | no |
Available in AxoSyslog 4.1 and later.
Description: If set to yes, AxoSyslog fetches only journal messages that relate to the current boot, and to ignores messages generated in previous boots.
matches()
Type: | arrow list |
Default: |
Available in AxoSyslog 4.1 and later.
Description: Specifies one or more filters to apply on the journal fields, similarly how you can use journalctl
. For example:
matches(
"_COMM" => "systemd"
)
max-field-size()
Type: | number (characters) |
Default: | 65536 |
Description: The maximum length of a field’s value.
namespace()
Type: | string |
Default: | “*” |
Description: The namespace()
option works exactly the same way as the respective option of the Journalctl command line tool.
The following modes of operation are available:
- If you do not specify the
namespace()
option in your configuration, or if you specify an empty string, thesystemd-journal()
source reads and displays log data from all namespaces. - If you specify the
namespace()
option asnamespace("*")
, thesystemd-journal()
source reads and displays log data from all namespaces, interleaved. - If
namespace(<specific-namespace>)
is specified, thesystemd-journal()
source only reads and displays log data from the specified namespace. - If the namespace identifier is prefixed with
"+"
when you specify yournamespace()
option, thesystemd-journal()
source only reads and displays log data from the specified namespace and the default namespace, interleaved.
Starting with AxoSyslog 4.4, you can use multiple systemd-journal()
sources in your configuration. In this case, each source must use unique systemd namespaces.
Syntax: namespace(string)
Example: configuration examples for using the namespace() option
The following configuration example uses the default value for the namespace()
option:
source s_journal
{
systemd-journal(namespace("*"));
};
The following configuration example uses a prefixed namespace identifier in the namespace()
option:
source s_journal
{
systemd-journal(namespace("+foobar"));
};
namespace()
option from version 3.29. For further information about namespaces on the Systemd side, see Journal Namespaces.
prefix()
Type: | string |
Default: | .journald. |
Description: If this option is set, every non-built-in mapped names get a prefix (for example: ".SDATA.journald."
). By default, AxoSyslog adds the .journald.
prefix to every value.
read-old-records()
Type: | `yes |
Default: | yes |
Description: If set to yes
, AxoSyslog will start reading the records from the beginning of the journal, if the journal has not been read yet. If set to no
, AxoSyslog will read only the new records. If the source has a state in the persist file, this option will have no effect.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
use-fqdn()
Type: | yes or no |
Default: | no |
Description: Use this option to add a Fully Qualified Domain Name (FQDN) instead of a short hostname. You can specify this option either globally or per-source. The local setting of the source overrides the global option if available.
use-fqdn()
to yes
if you want to use the custom-domain()
global option.
keep-hostname()
option is enabled (keep-hostname(yes)
) and the message contains a hostname.
31 - systemd-syslog: Collect systemd messages using a socket
On platforms running systemd, the systemd-syslog()
driver reads the log messages of systemd using the /run/systemd/journal/syslog
socket. Note the following points about this driver:
-
If possible, use the more reliable systemd-journal() driver instead.
-
The socket activation of systemd is buggy, causing some log messages to get lost during system startup.
-
If AxoSyslog is running in a jail or a Linux Container (LXC), it will not read from the
/dev/kmsg
or/proc/kmsg
files.
Declaration:
systemd-syslog();
Example: Using the systemd-syslog() driver
@version: 4.10.0
source s_systemdd {
systemd-syslog();
};
destination d_network {
syslog("server.host");
};
log {
source(s_systemdd);
destination(d_network);
};
31.1 - systemd-syslog() source options
The systemd-syslog()
driver has the following options:
check-hostname()
Type: | boolean (yes or no ) |
Default: | Use the global check-hostname() option, which defaults to no . |
Description:
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
Uses the value of the global option if not specified.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
idle-timeout()
Accepted values: | number [seconds] |
Default: | 0 (disabled) |
Available in AxoSyslog 4.9 and later.
If set, AxoSyslog closes the client connection if no data is received for the specified amount of time (in seconds).
32 - tcp, tcp6, udp, udp6: OBSOLETE - Collect messages from remote hosts using the BSD syslog protocol
tcp()
, tcp6()
, udp()
, and udp6()
drivers are obsolete. Use the network()
source and the network()
destination instead. For details, see network: Collect messages using the RFC3164 protocol (network() driver) and network: Send messages to a remote log server using the RFC3164 protocol (network() driver), respectively.
The tcp()
, tcp6()
, udp()
, udp6()
drivers can receive syslog messages conforming to RFC3164 from the network using the TCP and UDP networking protocols. The tcp6()
and udp6()
drivers use the IPv6 network protocol, while tcp()
and udp()
use IPv4.
To convert your existing tcp()
, tcp6()
, udp()
, udp6()
source drivers to use the network()
driver, see Change an old source driver to the network() driver.
32.1 - tcp(), tcp6(), udp() and udp6() source options: OBSOLETE
tcp()
, tcp6()
, udp()
, and udp6()
drivers are obsolete. Use the network()
source and the network()
destination instead. For details, see network: Collect messages using the RFC3164 protocol (network() driver) and network: Send messages to a remote log server using the RFC3164 protocol (network() driver), respectively.
To convert your existing tcp()
, tcp6()
, udp()
, udp6()
source drivers to use the network()
driver, see Change an old source driver to the network() driver.
32.1.1 - Change an old source driver to the network() driver
To replace your existing tcp()
, tcp6()
, udp()
, udp6()
sources with a network()
source, complete the following steps.
-
Replace the driver with
network
. For example, replaceudp(
withnetwork(
-
Set the transport protocol.
-
If you used TLS-encryption, add the
transport("tls")
option, then continue with the next step. -
If you used the
tcp
ortcp6
driver, add thetransport("tcp")
option. -
If you used the
udp
orudp
driver, add thetransport("udp")
option.
-
-
If you use IPv6 (that is, the
udp6
ortcp6
driver), add theip-protocol(6)
option. -
If you did not specify the port used in the old driver, check network() source options and verify that your clients send the messages to the default port of the transport protocol you use. Otherwise, set the appropriate port number in your source using the
port()
option. -
All other options are identical. Test your configuration with the
syslog-ng --syntax-only
command.The following configuration shows a simple
tcp
source.source s_old_tcp { tcp( ip(127.0.0.1) port(1999) tls( peer-verify("required-trusted") key-file("/opt/syslog-ng/etc/syslog-ng/syslog-ng.key") cert-file('/opt/syslog-ng/etc/syslog-ng/syslog-ng.crt') ) ); };
When replaced with the
network()
driver, it looks like this.source s_new_network_tcp { network( transport("tls") ip(127.0.0.1) port(1999) tls( peer-verify("required-trusted") key-file("/opt/syslog-ng/etc/syslog-ng/syslog-ng.key") cert-file('/opt/syslog-ng/etc/syslog-ng/syslog-ng.crt') ) ); };
33 - unix-stream, unix-dgram: Collect messages from UNIX domain sockets
The unix-stream()
and unix-dgram()
drivers open an AF_UNIX
socket and start listening on it for messages. The unix-stream()
driver is primarily used on Linux and uses SOCK_STREAM
semantics (connection oriented, no messages are lost), while unix-dgram()
is used on BSDs and uses SOCK_DGRAM
semantics: this may result in lost local messages if the system is overloaded.
To avoid denial of service attacks when using connection-oriented protocols, the number of simultaneously accepted connections should be limited. This can be achieved using the max-connections()
parameter. The default value of this parameter is quite strict, you might have to increase it on a busy system.
Both unix-stream and unix-dgram have a single required argument that specifies the filename of the socket to create. For the list of available optional parameters, see unix-stream() and unix-dgram() source options
Declaration:
unix-stream(filename [options]);
unix-dgram(filename [options]);
syslogd
on Linux originally used SOCK_STREAM
sockets, but some distributions switched to SOCK_DGRAM
around 1999 to fix a possible DoS problem. On Linux you can choose to use whichever driver you like as syslog clients automatically detect the socket type being used.
Example: Using the unix-stream() and unix-dgram() drivers
source s_stream {
unix-stream("/dev/log" max-connections(10));
};
source s_dgram {
unix-dgram("/var/run/log");
};
33.1 - UNIX credentials and other metadata
Starting with AxoSyslog 3.6, the unix-stream()
and unix-dgram()
sources automatically extract the available UNIX credentials and other metainformation from the received log messages. The AxoSyslog application can extract the following information on Linux and FreeBSD platforms (examples show the value of the macro for the su - myuser
command). Similar information is available for the systemd-journal source.
Macro | Description |
---|---|
${.unix.cmdline} |
The name (without the path) and command-line options of the executable belonging to the PID that sent the message. For example, su - myuser |
${.unix.exe} |
The path of the executable belonging to the PID that sent the message. For example, /usr/bin/su |
${.unix.gid} |
The group ID (GID) corresponding to the UID of the application that sent the log message. Note that this is the ID number of the group, not its human-readable name. For example, 0 |
${.unix.pid} |
The process ID (PID) of the application that sent the log message. For example, Note that on every UNIX platforms, if the `system()` source uses sockets, it will overwrite the PID macro with the value of `${.unix.pid}`, if it is available. |
${.unix.uid} |
The user ID (UID) of the application that sent the log message. Note that this is the ID number of the user, not its human-readable name. For example, 0 |
33.2 - unix-stream() and unix-dgram() source options
These two drivers behave similarly: they open an AF_UNIX
socket and start listening on it for messages. The following options can be specified for these drivers:
check-hostname()
Type: | boolean (yes or no ) |
Default: | Use the global check-hostname() option, which defaults to no . |
Description:
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
Uses the value of the global option if not specified.
create-dirs()
Type: | yes or no |
Default: | no |
Description: Enable creating non-existing directories when creating files or socket files.
encoding()
Type: | string |
Default: |
Description: Specifies the character set (encoding, for example, UTF-8
) of messages using the legacy BSD-syslog protocol. To list the available character sets on a host, execute the iconv -l
command. For details on how encoding affects the size of the message, see Message size and encoding.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
group()
Type: | string |
Default: | root |
Description: Set the gid of the socket.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
host-override()
Type: | string |
Default: |
Description: Replaces the ${HOST} part of the message with the parameter string.
idle-timeout()
Accepted values: | number [seconds] |
Default: | 0 (disabled) |
Available in AxoSyslog 4.9 and later.
If set, AxoSyslog closes the client connection if no data is received for the specified amount of time (in seconds).
keep-alive()
Type: | yes or no |
Default: | yes |
Description: Selects whether to keep connections open when syslog-ng
is restarted, cannot be used with unix-dgram()
.
keep-timestamp()
Type: | yes or no |
Default: | yes |
Description: Specifies whether AxoSyslog should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
S_
macros, the keep-timestamp()
option must be enabled (this is the default behavior of AxoSyslog).
listen-backlog()
Type: | integer |
Default: | 256 |
Description: Available only for stream based transports (unix-stream
, tcp
, tls
). In TCP, connections are treated incomplete until the three-way handshake is completed between the server and the client. Incomplete connection requests wait on the TCP port for the listener to accept the request. The listen-backlog()
option sets the maximum number of incomplete connection requests. For example:
source s_network {
network(
ip("192.168.1.1")
transport("tcp")
listen-backlog(2048)
);
};
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
log-iw-size()
Type: | number |
Default: | 100 |
Description: The size of the initial window, this value is used during flow-control. Its value cannot be lower than 100, unless the dynamic-window-size()
option is enabled. For details on flow-control, see Managing incoming and outgoing messages with flow-control.
log-msg-size()
Type: | number (bytes) |
Default: | Use the global log-msg-size() option, which defaults to 65536 (64 KiB). |
Description: Maximum length of an incoming message in bytes. This length includes the entire message (the data structure and individual fields). The maximal value that can be set is 268435456 bytes (256 MiB).
For messages using the IETF-syslog message format (RFC5424), the maximal size of the value of an SDATA field is 64 KiB.
log-msg-size()
does not need to be set higher than 10 MiB.
For details on how encoding affects the size of the message, see Message size and encoding.
You can use human-readable units when setting configuration options. For details, seeNotes about the configuration syntax.
Uses the value of the global option if not specified.
log-prefix() (DEPRECATED)
Type: | string |
Default: |
Description: A string added to the beginning of every log message. It can be used to add an arbitrary string to any log source, though it is most commonly used for adding kernel:
to the kernel messages on Linux.
program-override
instead.
max-connections()
Type: | number (simultaneous connections) |
Default: | 256 |
Description: Limits the number of simultaneously open connections. Cannot be used with unix-dgram()
.
optional()
Type: | yes or no |
Default: |
Description: Instruct AxoSyslog to ignore the error if a specific source cannot be initialized. No other attempts to initialize the source will be made until the configuration is reloaded. This option currently applies to the pipe()
, unix-dgram
, and unix-stream
drivers.
owner()
Type: | string |
Default: | root |
Description: Set the uid of the socket.
pad-size()
Type: | number |
Default: | 0 |
Description: Specifies input padding. Some operating systems (such as HP-UX) pad all messages to block boundary. This option can be used to specify the block size. The AxoSyslog application will pad reads from the associated device to the number of bytes set in pad-size()
. Mostly used on HP-UX where /dev/log
is a named pipe and every write is padded to 2048 bytes. If pad-size()
was given and the incoming message does not fit into pad-size()
, AxoSyslog will not read anymore from this pipe and displays the following error message:
Padding was set, and couldn't read enough bytes
perm()
Type: | number (octal notation) |
Default: | 0666 |
Description: Set the permission mask. For octal numbers prefix the number with ‘0’, for example: use 0755 for rwxr-xr-x.
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
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.
When receiving messages using the UDP protocol, increase the size of the UDP receive buffer on the receiver host (that is, the AxoSyslog server or relay receiving the messages). Note that on certain platforms, for example, on Red Hat Enterprise Linux 5, even low message load (~200 messages per second) can result in message loss, unless the so-rcvbuf()
option of the source is increased. In this cases, you will need to increase the net.core.rmem_max
parameter of the host (for example, to 1024000
), but do not modify net.core.rmem_default
parameter.
As a general rule, increase the so-rcvbuf()
so that the buffer size in kilobytes is higher than the rate of incoming messages per second. For example, to receive 2000 messages per second, set the so-rcvbuf()
at least to 2 097 152
bytes.
so-reuseport()
Type: | yes or no |
Default: | no |
Description: Enables SO_REUSEPORT on systems that support it. When enabled, the kernel allows multiple UDP sockets to be bound to the same port, and the kernel load-balances incoming UDP datagrams to the sockets. The sockets are distributed based on the hash of (srcip, dstip, srcport, dstport), so the same listener should be receiving packets from the same endpoint. For example:
source {
network(transport("udp") so-reuseport(1) port(2000) persist-name("udp1"));
network(so-reuseport(1) port(2000) persist-name("udp2"));
network(so-reuseport(1) port(2000) persist-name("udp3"));
network(so-reuseport(1) port(2000) persist-name("udp4"));
};
Enables keep-alive messages, keeping the socket open. This only effects TCP and UNIX-stream sockets. For details, see the socket(7)
manual page.
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.
34 - stdin: Collect messages from the standard input stream
The stdin()
driver collects messages from the standard input stream. When the standard input stream is closed, AxoSyslog stops and stdin()
inherits all options from the file()
source, including multi-line options, or flags(no-parse)
.
The stdin()
driver causes AxoSyslog to exit once it hits end-of-file (EOF).
Declaration:
stdin();
Example: Using the stdin() driver
@version: 4.10.0
log {
source { stdin(); };
destination { file("/dev/stdout"); };
};
The following code snippet is an example of how the stdin()
driver is used to collect a test message:
$ echo "this is a test message" | ./syslog-ng -Fe --no-caps
[2017-11-14T13:47:16.757938] syslog-ng starting up; version='3.12.1'
[2017-11-14T13:47:16.758195] syslog-ng shutting down; version='3.12.1'
Nov 14 13:47:16 testserver this is a test message
34.1 - stdin() source options
The stdin()
driver has the following options:
check-hostname()
Type: | boolean (yes or no ) |
Default: | Use the global check-hostname() option, which defaults to no . |
Description:
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
Uses the value of the global option if not specified.
default-facility()
Type: | facility string |
Default: | kern |
Description: This parameter assigns a facility value to the messages received from the file source if the message does not specify one.
default-priority()
Type: | priority string |
Default: |
Description: This parameter assigns an emergency level to the messages received from the file source if the message does not specify one. For example, default-priority(warning)
.
encoding()
Type: | string |
Default: |
Description: Specifies the character set (encoding, for example, UTF-8
) of messages using the legacy BSD-syslog protocol. To list the available character sets on a host, execute the iconv -l
command. For details on how encoding affects the size of the message, see Message size and encoding.
flags()
Type: | assume-utf8 , check-hostname , check-program , dont-store-legacy-msghdr , empty-lines , expect-hostname , kernel , no-hostname , no-multi-line , no-parse , sanitize-utf8 , store-legacy-msghdr , store-raw-message , syslog-protocol , validate-utf8 |
Default: | empty set |
Description: Specifies the log parsing options of the source. For example:
source { network(flags(check-hostname, check-program)); };
assume-utf8
The assume-utf8
flag assumes that the incoming messages are UTF-8 encoded, but does not verify the encoding. If you explicitly want to validate the UTF-8 encoding of the incoming message, use the validate-utf8
flag.
check-hostname
When receiving messages, AxoSyslog can check whether the hostname contains valid characters.
Valid characters are:
- alphanumeric characters (A-Z, a-z, 0-9)
- the dash (
-
) and underscore (_
) characters - the dot (
.
) and the colon (:
) characters - the
@
and slash (/
)
If the hostname contains invalid characters, AxoSyslog sets the syslog.invalid_hostname
tag for the message, and doesn’t parse the ${HOST}
field from the message.
check-program
Available in version 4.10 and later.
If the check-program
flag is enabled, AxoSyslog validates the ${PROGRAM}
field for RFC3164-formatted messages. Valid program names meet the following criteria:
- Contain only these characters:
[a-zA-Z0-9-_/().]
- Include at least one alphabetical character.
If the program name fails validation, it is considered to be part of the log message.
dont-store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message. This is useful if the original format of a non-syslog-compliant message must be retained (AxoSyslog automatically corrects minor header errors, for example, adds a whitespace before msg
in the following message: Jan 22 10:06:11 host program:msg
). If you do not want to store the original header of the message, enable the dont-store-legacy-msghdr
flag.
empty-lines
Use the empty-lines
flag to keep the empty lines of the messages. By default, AxoSyslog removes empty lines automatically.
exit-on-eof
If this flag is set on a source, AxoSyslog stops when an EOF (end of file) is received. Available in version 4.9 and later.
expect-hostname
If the expect-hostname
flag is enabled, AxoSyslog will assume that the log message contains a hostname and parse the message accordingly. This is the default behavior for TCP sources. Note that pipe sources use the no-hostname
flag by default.
guess-timezone
Attempt to guess the timezone of the message if this information is not available in the message. Works when the incoming message stream is close to real time, and the timezone information is missing from the timestamp.
kernel
The kernel
flag makes the source default to the LOG_KERN | LOG_NOTICE
priority if not specified otherwise.
no-header
The no-header
flag triggers AxoSyslog to parse only the PRI
field of incoming messages, and put the rest of the message contents into $MSG
.
Its functionality is similar to that of the no-parse
flag, except the no-header
flag does not skip the PRI
field.
no-header
flag signals AxoSyslog that the syslog
header is not present (or does not adhere to the conventions / RFCs), so the entire message (except from the PRI
field) is put into $MSG
.
The following example illustrates using the no-header
flag with the syslog-parser()
parser:
parser p_syslog {
syslog-parser(
flags(no-header)
);
};
no-hostname
Enable the no-hostname
flag if the log message does not include the hostname of the sender host. That way AxoSyslog assumes that the first part of the message header is ${PROGRAM} instead of ${HOST}. For example:
source s_dell {
network(
port(2000)
flags(no-hostname)
);
};
no-multi-line
The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line. Note that this happens only if the underlying transport method actually supports multi-line messages. Currently the file()
and pipe()
drivers support multi-line messages.
no-parse
By default, AxoSyslog parses incoming messages as syslog messages. The no-parse
flag completely disables syslog message parsing and processes the complete line as the message part of a syslog message. The AxoSyslog application will generate a new syslog header (timestamp, host, and so on) automatically and put the entire incoming message into the MESSAGE part of the syslog message (available using the ${MESSAGE}
macro). This flag is useful for parsing messages not complying to the syslog format.
If you are using the flags(no-parse)
option, then syslog message parsing is completely disabled, and the entire incoming message is treated as the ${MESSAGE} part of a syslog message. In this case, AxoSyslog generates a new syslog header (timestamp, host, and so on) automatically. Note that even though flags(no-parse)
disables message parsing, some flags can still be used, for example, the no-multi-line
flag.
sanitize-utf8
When using the sanitize-utf8
flag, AxoSyslog converts non-UTF-8 input to an escaped form, which is valid UTF-8.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
store-legacy-msghdr
By default, AxoSyslog stores the original incoming header of the log message, so this flag is active. To disable it, use the dont-store-legacy-msghdr
flag.
store-raw-message
Save the original message as received from the client in the ${RAWMSG}
macro. You can forward this raw message in its original form to another AxoSyslog node using the syslog-ng()
destination, or to a SIEM system, ensuring that the SIEM can process it. Available only in 3.16 and later.
syslog-protocol
The syslog-protocol
flag specifies that incoming messages are expected to be formatted according to the new IETF syslog protocol standard (RFC5424), but without the frame header. Note that this flag is not needed for the syslog
driver, which handles only messages that have a frame header.
validate-utf8
The validate-utf8
flag enables encoding-verification for messages.
Prior to version 4.6, this flag worked only when parsing RFC3164 messages. Starting with version 4.6, it works also for RFC5424 and raw messages.
For RFC5424-formatted messages, if the BOM character is missing, but the message is otherwise UTF-8 compliant, AxoSyslog automatically adds the BOM character to the message.
The byte order mark (BOM) is a Unicode character used to signal the byte-order of the message text.
follow-freq()
Type: | number |
Default: | 1 |
Description: Indicates that the source should be checked periodically. This is useful for files which always indicate readability, even though no new lines were appended. If this value is higher than zero, AxoSyslog will not attempt to use poll()
on the file, but checks whether the file changed every time the follow-freq()
interval (in seconds) has elapsed. Floating-point numbers (for example, 1.5
) can be used as well.
hook-commands()
Description: This option makes it possible to execute external programs when the relevant driver is initialized or torn down. The hook-commands()
can be used with all source and destination drivers with the exception of the usertty()
and internal()
drivers.
Using hook-commands()
when AxoSyslog starts or stops
To execute an external program when AxoSyslog starts or stops, use the following options:
startup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog starts.
shutdown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines the external program that is executed as AxoSyslog stops.
Using the hook-commands() when AxoSyslog reloads
To execute an external program when the AxoSyslog configuration is initiated or torn down, for example, on startup/shutdown or during a AxoSyslog reload, use the following options:
setup()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is initiated, for example, on startup or during a AxoSyslog reload.
teardown()
Type: | string |
---|---|
Default: | N/A |
Description: Defines an external program that is executed when the AxoSyslog configuration is stopped or torn down, for example, on shutdown or during a AxoSyslog reload.
Example: Using hook-commands() with a network source
In the following example, the hook-commands()
is used with the network()
driver and it opens an iptables port automatically as AxoSyslog is started/stopped.
The assumption in this example is that the LOGCHAIN
chain is part of a larger ruleset that routes traffic to it. Whenever the AxoSyslog created rule is there, packets can flow, otherwise the port is closed.
source {
network(transport(udp)
hook-commands(
startup("iptables -I LOGCHAIN 1 -p udp --dport 514 -j ACCEPT")
shutdown("iptables -D LOGCHAIN 1")
)
);
};
idle-timeout()
Accepted values: | number [seconds] |
Default: | 0 (disabled) |
Available in AxoSyslog 4.9 and later.
If set, AxoSyslog closes the client connection if no data is received for the specified amount of time (in seconds).
keep-timestamp()
Type: | yes or no |
Default: | yes |
Description: Specifies whether AxoSyslog should accept the timestamp received from the sending application or client. If disabled, the time of reception will be used instead. This option can be specified globally, and per-source as well. The local setting of the source overrides the global option if available.
S_
macros, the keep-timestamp()
option must be enabled (this is the default behavior of AxoSyslog).
log-fetch-limit()
Type: | number |
Default: | 100 |
Description: The maximum number of messages fetched from a source during a single poll loop. The destination queues might fill up before flow-control could stop reading if log-fetch-limit()
is too high.
log-iw-size()
Type: | number |
Default: | 10000 |
Description: The size of the initial window, this value is used during flow control. Make sure that log-iw-size()
is larger than the value of log-fetch-limit()
.
log-msg-size()
Type: | number (bytes) |
Default: | Use the global log-msg-size() option, which defaults to 65536 (64 KiB). |
Description: Maximum length of an incoming message in bytes. This length includes the entire message (the data structure and individual fields). The maximal value that can be set is 268435456 bytes (256 MiB).
For messages using the IETF-syslog message format (RFC5424), the maximal size of the value of an SDATA field is 64 KiB.
log-msg-size()
does not need to be set higher than 10 MiB.
For details on how encoding affects the size of the message, see Message size and encoding.
You can use human-readable units when setting configuration options. For details, seeNotes about the configuration syntax.
Uses the value of the global option if not specified.
log-prefix() (DEPRECATED)
Type: | string |
Default: |
Description: A string added to the beginning of every log message. It can be used to add an arbitrary string to any log source, though it is most commonly used for adding kernel:
to the kernel messages on Linux.
program-override
instead.
multi-line-garbage()
Type: | regular expression |
Default: | empty string |
Description: Use the multi-line-garbage()
option when processing multi-line messages that contain unneeded parts between the messages. Specify a string or regular expression that matches the beginning of the unneeded message parts. If the multi-line-garbage()
option is set, AxoSyslog ignores the lines between the line matching the multi-line-garbage()
and the next line matching multi-line-prefix()
. See also the multi-line-prefix()
option.
When receiving multi-line messages from a source when the multi-line-garbage()
option is set, but no matching line is received between two lines that match multi-line-prefix()
, AxoSyslog will continue to process the incoming lines as a single message until a line matching multi-line-garbage()
is received.
To use the multi-line-garbage()
option, set the multi-line-mode()
option to prefix-garbage
.
multi-line-garbage()
option is set, AxoSyslog discards lines between the line matching the multi-line-garbage()
and the next line matching multi-line-prefix()
.
multi-line-mode()
Type: | indented , prefix-garbage , prefix-suffix , regexp , smart |
Default: | empty string |
Description: Use the multi-line-mode()
option when processing multi-line messages. The AxoSyslog application provides the following methods to process multi-line messages:
-
indented
: Theindented
mode can process messages where each line that belongs to the previous line is indented by whitespace, and the message continues until the first non-indented line. For example, the Linux kernel (starting with version 3.5) uses this format for/dev/log
, as well as several applications, like Apache Tomcat.source s_tomcat { file("/var/log/tomcat/xxx.log" multi-line-mode(indented)); };
-
prefix-garbage
: The prefix-garbage mode uses a string or regular expression (set inmulti-line-prefix()
) that matches the beginning of the log messages, ignores newline characters from the source until a line matches the regular expression again, and treats the lines between the matching lines as a single message. For details on usingmulti-line-mode(prefix-garbage)
, see themulti-line-prefix()
andmulti-line-garbage()
options. -
prefix-suffix
: Theprefix-suffix
mode uses a string or regular expression (set inmulti-line-prefix()
) that matches the beginning of the log messages, ignores newline characters from the source until a line matches the regular expression set inmulti-line-suffix()
, and treats the lines betweenmulti-line-prefix()
andmulti-line-suffix()
as a single message. Any other lines between the end of the message and the beginning of a new message (that is, a line that matches themulti-line-prefix()
expression) are discarded. For details on usingmulti-line-mode(prefix-suffix)
, see themulti-line-prefix()
andmulti-line-suffix()
options.The
prefix-suffix
mode is similar to theprefix-garbage
mode, but it appends the garbage part to the message instead of discarding it. -
smart
: Thesmart
mode recognizes multi-line data backtraces even if they span multiple lines in the input. The backtraces are converted to a single log message for easier analysis. Backtraces for the following programming languages are recognized : Python, Java, JavaScript, PHP, Go, Ruby, and Dart.smart
mode is available in AxoSyslog version 4.2 and newer.The regular expressions to recognize these programming languages are specified in an external file called
/usr/share/syslog-ng/smart-multi-line.fsm
(installation path depends on configure arguments), in a format that is described in that file.
To format multi-line messages to your individual needs, consider the following:
-
To make multi-line messages more readable when written to a file, use a template in the destination and instead of the
${MESSAGE}
macro, use the following:$(indent-multi-line ${MESSAGE})
. This expression inserts a tab after every newline character (except when a tab is already present), indenting every line of the message after the first. For example:destination d_file { file ("/var/log/messages" template("${ISODATE} ${HOST} $(indent-multi-line ${MESSAGE})\n") ); };
For details on using templates, see Templates and macros.
-
To actually convert the lines of multi-line messages to single line (by replacing the newline characters with whitespaces), use the
flags(no-multi-line)
option in the source.
multi-line-prefix()
Type: | regular expression starting with the ^ character |
Default: | empty string |
Description: Use the multi-line-prefix()
option to process multi-line messages, that is, log messages that contain newline characters (for example, Tomcat logs). Specify a string or regular expression that matches the beginning of the log messages (always start with the ^
character). Use as simple regular expressions as possible, because complex regular expressions can severely reduce the rate of processing multi-line messages. If the multi-line-prefix()
option is set, AxoSyslog ignores newline characters from the source until a line matches the regular expression again, and treats the lines between the matching lines as a single message. See also the multi-line-garbage()
option.
To format multi-line messages to your individual needs, consider the following:
-
To make multi-line messages more readable when written to a file, use a template in the destination and instead of the
${MESSAGE}
macro, use the following:$(indent-multi-line ${MESSAGE})
. This expression inserts a tab after every newline character (except when a tab is already present), indenting every line of the message after the first. For example:destination d_file { file ("/var/log/messages" template("${ISODATE} ${HOST} $(indent-multi-line ${MESSAGE})\n") ); };
For details on using templates, see Templates and macros.
-
To actually convert the lines of multi-line messages to single line (by replacing the newline characters with whitespaces), use the
flags(no-multi-line)
option in the source.
Example: Processing Tomcat logs
The log messages of the Apache Tomcat server are a typical example for multi-line log messages. The messages start with the date and time of the query in the YYYY.MM.DD HH:MM:SS
format, as you can see in the following example.
2010.06.09. 12:07:39 org.apache.catalina.startup.Catalina start
SEVERE: Catalina.start:
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: java.net.BindException: Address already in use null:8080
at org.apache.catalina.connector.Connector.start(Connector.java:1138)
at org.apache.catalina.core.StandardService.start(StandardService.java:531)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.commons.daemon.support.DaemonLoader.start(DaemonLoader.java:177)
2010.06.09. 12:07:39 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1206 ms
2010.06.09. 12:45:08 org.apache.coyote.http11.Http11Protocol pause
INFO: Pausing Coyote HTTP/1.1 on http-8080
2010.06.09. 12:45:09 org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina
To process these messages, specify a regular expression matching the timestamp of the messages in the multi-line-prefix()
option. Such an expression is the following:
source s_file{file("/var/log/tomcat6/catalina.2010-06-09.log" follow-freq(0) multi-line-mode(regexp) multi-line-prefix("[0-9]{4}\.[0-9]{2}\.[0-9]{2}\.") flags(no-parse));};
};
Note that flags(no-parse)
is needed to prevent AxoSyslog trying to interpret the date in the message.
multi-line-suffix()
Type: | regular expression |
Default: | empty string |
Description: Use the multi-line-suffix()
option when processing multi-line messages. Specify a string or regular expression that matches the end of the multi-line message.
To use the multi-line-suffix()
option, set the multi-line-mode()
option to prefix-suffix
. See also the multi-line-prefix()
option.
pad-size()
Type: | number |
Default: | 0 |
Description: Specifies input padding. Some operating systems (such as HP-UX) pad all messages to block boundary. This option can be used to specify the block size. The AxoSyslog application will pad reads from the associated device to the number of bytes set in pad-size()
. Mostly used on HP-UX where /dev/log
is a named pipe and every write is padded to 2048 bytes. If pad-size()
was given and the incoming message does not fit into pad-size()
, AxoSyslog will not read anymore from this pipe and displays the following error message:
Padding was set, and couldn't read enough bytes
program-override()
Type: | string |
Default: |
Description: Replaces the ${PROGRAM} part of the message with the parameter string. For example, to mark every message coming from the kernel, include the program-override("kernel")
option in the source containing /proc/kmsg
.
tags()
Type: | string |
Default: |
Description: Label the messages received from the source with custom tags. Tags must be unique, and enclosed between double quotes. When adding multiple tags, separate them with comma, for example, tags("dmz", "router")
. This option is available only in version 3.1 and later.
time-zone()
Type: | name of the timezone, or the timezone offset |
Default: |
Description: The default timezone for messages read from the source. Applies only if no timezone is specified within the message itself.
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.