UDP (om_udp)

This module sends log messages as UDP datagrams to the address and port specified. UDP is the transport protocol of the legacy BSD Syslog standard as described in RFC 3164, so this module can be particularly useful to send messages to devices or Syslog daemons that do not support other protocols.

Configuration

The om_udp module accepts the following directives in addition to the common module directives. The Host directive is required.

Required directives

The following directive is required for the module to start.

Host

Set this directive to the IP address or hostname of the remote host to connect to. If you specify a hostname, the module resolves it to an IP address on each new connection.

The module uses port 514 by default. To connect to a different port, add the port number after the IP address or hostname, separated by a colon (host:port).

Enclose IPv6 addresses in square brackets ([addr]:port). For example, [2001:0db8:85a3:0:0:8a2e:0370:7334]:514.

You can set this directive more than once to allow failover between different hosts or ports. List IPv4 and IPv6 addresses separately if needed. If you use a DNS name, make sure it resolves to fewer than 16 addresses or CNAMEs to prevent problems with DNS response size limits.

If you configure more than one Host directive, or a DNS lookup returns multiple addresses, the module connects to the first reachable address and stays connected until it stops or the connection drops. It does not detect DNS changes on its own.

If a connection attempt fails, the module tries the next address in the current Host directive, then moves to the next Host directive, if any. Once it checks all Host directives, it starts over from the first and keeps trying until it connects.

Because of the nature of the UDP protocol and how ICMP messages are handled by various network devices, the failover functionality in this module is considered a "best effort". Detecting hosts going offline is not supported. Detecting the receiving service being stopped - while the host stays up is supported.

Optional directives

LocalPort

Set this directive to the local port number to use for the connection, for example to satisfy a firewall rule that expects traffic from a known port. If you do not set this directive, the module uses a random high port number, which a firewall may block.

Attempts to bind to LocalPort may fail because of the required TIME-WAIT delay in closing connections. When this happens, the module writes Address already in use to the NXLog Agent log file. If it persists, it can degrade network performance.

OutputType

See the OutputType directive in the list of common module directives. If this directive is not specified, the default is Dgram.

Reconnect

Set this directive to the number of seconds to wait between reconnection attempts. If you do not set this directive, the module starts with a 1 second interval and doubles it after each failed attempt, resetting to 1 second once it reconnects successfully.

Setting this directive on multiple systems can cause them to send reconnection requests to the same destination at the same time, potentially overloading it. This can also cause NXLog Agent to consume unusually high system resources or become unresponsive.

ReconnectOnData

Set this directive to TRUE to have the module reconnect to the remote host only when it has data to send, instead of keeping the connection open at all times. The default is FALSE; the module always keeps a connection open with the remote host.

SockBufSize

This optional directive sets the socket buffer size (SO_SNDBUF) to the value specified. If this is not set, the operating system default is used.

TcpSendStallDetect

Set this directive to TRUE to monitor for pipeline backpressure by logging a warning whenever the module cannot send data to the destination. The module writes the following message to the NXLog Agent log file:

TCP send buffer full for <instance_name> - write blocked

The default is FALSE; the module does not check for send stalls.

Procedures

The following procedures are exported by om_udp.

reconnect();

Force a reconnection. This can be used from a Schedule block to periodically reconnect to the server.

The reconnect() procedure must be used with caution. If configured, it can attempt to reconnect after every event sent, potentially overloading the destination system.

Examples

Example 1. Sending syslog over UDP

This configuration reads log messages from a socket and forwards them via UDP.

nxlog.conf
<Input uds>
    Module  im_uds
    UDS     /dev/log
</Input>

<Output udp>
    Module  om_udp
    Host    192.168.1.1:1514
</Output>

<Route uds_to_udp>
    Path    uds => udp
</Route>
Example 2. Sending logs over UDP with failover

This configuration sends logs via UDP in a failover configuration (multiple Hosts defined).

nxlog.conf
<Output udp>
    Module  om_udp
    Host    192.168.1.2:1514
    Host    192.168.1.3:1514
    Host    example.com:1234
</Output>