The in_forward Input plugin listens to a TCP socket to receive the event stream. It also listens to a UDP socket to receive heartbeat messages. See also the protocol section for implementation details.
This plugin is mainly used to receive event logs from other Fluentd instances, the fluent-cat command, or Fluentd client libraries. This is by far the most efficient way to retrieve the records.
If you want to receive events from raw TCP payload, use in_tcp plugin instead.
It is included in Fluentd's core.
Example Configuration
Refer to the Configuration File article for the basic structure and syntax of the configuration file.
This section contains parameters related to authentication:
self_hostname
shared_key
user_auth
allow_anonymous_source
self_hostname
type
default
version
string
required parameter
0.14.5
The hostname.
shared_key
type
default
version
string
required parameter
0.14.5
The shared key for authentication.
user_auth
type
default
version
bool
false
0.14.5
If true, user-based authentication is used.
allow_anonymous_source
type
default
version
bool
true
0.14.5
Allows the anonymous source. <client> sections are required, if disabled.
<user> section
required
multi
version
false
true
0.14.5
This section contains user-based authentication:
username
password
This section can be used in <security>.
username
type
default
version
string
required parameter
0.14.5
The username for authentication.
password
type
default
version
string
required parameter
0.14.5
The password for authentication.
<client> section
required
multi
version
false
true
0.14.5
This section contains client IP/Network authentication and shared key per host:
host
network
shared_key
users
This section can be used in <security>
host
type
default
version
string
nil
0.14.5
The IP address or hostname of the client.
This is exclusive with network.
network
type
default
version
string
nil
0.14.5
The network address specification.
This is exclusive with host.
shared_key
type
default
version
string
nil
0.14.5
The shared key per client.
users
type
default
version
array
[]
0.14.5
The array of usernames.
Protocol
This plugin accepts both JSON or MessagePack messages and automatically detects which one is used. Internally, Fluentd uses MessagePack as it is more efficient than JSON.
The time value is an EventTime or a platform-specific integer and is based on the output of Ruby's Time.now.to_i function. On Linux, BSD, and Mac systems, this is the number of seconds since 1970.
Multiple messages may be sent on the same connection:
Since v0.14.12, Fluentd includes a built-in TLS support. Here we present a quick tutorial for setting up TLS encryption:
First, generate a self-signed certificate using the following command:
Move the generated certificate and private key to a safer place. For example:
Then, add the following settings to td-agent.conf and restart the service:
To test your encryption settings, execute the following command in your terminal. If the encryption is working properly, you should see a line containing {"foo":"bar"} in the log file:
If you can confirm TLS encryption has been set up correctly, please proceed to the configuration of the out_forward server.
How to Enable TLS Mutual Authentication
Since v1.1.1, Fluentd supports TLS mutual authentication (i.e. client certificate auth). If you want to use this feature, please set the client_cert_auth and ca_path options like this:
When this feature is enabled, Fluentd will check all the incoming requests for a client certificate signed by the trusted CA. Requests with an invalid client certificate will fail.
To check if mutual authentication is working properly, issue the following command:
If the connection gets established successfully, your setup is working fine.
Fluentd is equipped with a password-based authentication mechanism, which allows you to verify the identity of each client using a shared secret key.
To enable this feature, you need to add a <security> section to your configuration file like this:
Once the setup is complete, you have to configure your clients accordingly. For example, if you have an out_forward instance running on another server, configure it by following these instructions.
Multi-process Environment
If you use this plugin under the multi-process environment, the port will be shared.
With this configuration, the three (3) workers share the port 24224. No need for an additional port. Incoming data will be routed to the workers automatically.
FAQ
How to parse incoming events?
in_forward does not provide parsing mechanism unlike in_tail or in_tcp because in_forward is mainly for efficient log transfer. If you want to parse an incoming event, use parser filter in your pipeline.
$ openssl req -new -x509 -sha256 -days 1095 -newkey rsa:2048 \
-keyout fluentd.key -out fluentd.crt
# Note that during the generation, you will be asked for:
# - a password (to encrypt the private key), and
# - subject information (to be included in the certificate)