TCP (om_tcp)
This module initiates a TCP connection to a remote host and transfers log messages. Or, when using the ListenAddr directive, this module accepts client connections and multiplexes data to all connected clients. The TCP transfer protocol provides more reliable log transmission than UDP. If security is a concern, consider using the om_ssl module instead.
| To examine the supported platforms, see the list of installation packages. |
Configuration
The om_tcp module accepts the following directives in addition to the common module directives. The Host or ListenAddr directive is required.
Required directives
One of the following mutually exclusive directives is required for the module to start.
The module connects to this IP address or hostname. If using a hostname, the module resolves the hostname to an IP address on each new connection. You can define the port number by appending it to the IP address or hostname using a colon as a separator ( IPv6 addresses must be enclosed in square brackets ( You can define this directive multiple times to connect to multiple hosts or ports in failover mode. Specify IPv4 and IPv6 addresses separately as needed. If you use a DNS name, you should keep the addresses or CNAMEs below 16 to avoid issues caused by DNS response size limits.
|
|||
Set this directive to the IP address or DNS hostname on which the module accepts connections.
The default is Append the port number to the address using a colon separator ( You can specify this directive multiple times to accept connections on multiple addresses or ports within a single module instance. Set IPv4 and IPv6 addresses as separate entries. If you use a DNS name, keep the number of addresses or CNAMEs below 16 to avoid errors caused by DNS response size limits. |
Listen-mode directives
The following directives are available when using the ListenAddr directive.
Set this directive to restrict incoming connections to specific IP addresses or networks.
You can specify this directive multiple times to allow multiple IPs or networks.
If The following IP address formats may be used:
|
|
Set this directive to deny incoming connections from specific IP addresses or networks.
You can specify this directive multiple times to deny multiple IPs or networks.
If The following IP address formats may be used:
|
|
Set this directive to limit the number of concurrent active connections for a listening TCP socket.
The default is
|
|
Set this directive to close TCP connections that have been idle for longer than the specified number of seconds. The minimum value is 15 seconds. If this directive is not set, the module keeps idle TCP connections open indefinitely. |
|
Set this directive to The default is This directive is only supported on Windows. |
|
Set this directive to The default is |
|
Set this directive to The default is This directive is not supported on Windows. |
Optional directives
This optional directive specifies the local port number of the connection. If this is not specified, a random high port number will be used, which is not always ideal in firewalled network environments. This directive only applies if Host is used instead of ListenAddr.
|
|||
See the OutputType directive in the list of common module directives. The default is LineBased_LF. |
|||
If set to |
|||
This optional directive sets the reconnect interval in seconds. If it is set, the module attempts to reconnect in every defined second. If it is not set, the reconnect interval will start at 1 second and double with every attempt. In the latter case, when the system decides that the reconnection is successful, the reconnect interval is immediately reset to 1 sec.
|
|||
This optional directive defines the behavior when the connection with the remote host is lost.
When set to |
|||
This boolean directive is used to turn off the network optimization performed by Nagle’s algorithm. Nagle’s algorithm is a network optimization tweak that tries to reduce the number of small packets sent out to the network, by merging them into bigger frames, and by not sending them to the other side of the session before receiving the ACK. If this directive is unset, the TCP_NODELAY socket option will not be set. |
|||
Use this directive to log a warning when the module cannot send data to the destination, allowing you to monitor pipeline backpressure.
When set to |
| TCP connections are kept alive by keep-alive packets. This feature is enabled by default and cannot be disabled. |
Examples
With this configuration, NXLog Agent will read log messages from a socket and forward them via TCP.
<Input uds>
Module im_uds
UDS /dev/log
</Input>
<Output tcp>
Module om_tcp
Host 192.168.1.1:1514
</Output>
<Route uds_to_tcp>
Path uds => tcp
</Route>
This configuration sends logs via TCP in a failover configuration (multiple Hosts defined).
<Output tcp>
Module om_tcp
Host 192.168.1.2:1514
Host 192.168.1.3:1234
Host example.com:1234
</Output>