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.
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 ( Enclose IPv6 addresses in square brackets ( 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.
|
|||
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
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. This directive only applies when the module uses Host instead of ListenAddr.
|
|||
See the OutputType directive in the list of common module directives. The default is LineBased_LF. |
|||
If set to |
|||
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.
|
|||
Set this directive to |
|||
Set this directive to |
|||
Set this directive to
The default is |
| 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>