Home Explore Blog Models CI



docker

3rd chunk of `content/manuals/engine/logging/drivers/fluentd.md`
e2ad5870fae7ab309b038cf46d0882b5d723876af8fc45780000000100000cfd
`fluentd-address` option to connect to a different address. `tcp`(default) and `unix` sockets are supported.

```console
$ docker run --log-driver=fluentd --log-opt fluentd-address=fluentdhost:24224
$ docker run --log-driver=fluentd --log-opt fluentd-address=tcp://fluentdhost:24224
$ docker run --log-driver=fluentd --log-opt fluentd-address=unix:///path/to/fluentd.sock
```

Two of the above specify the same address, because `tcp` is default.

### tag

By default, Docker uses the first 12 characters of the container ID to tag log messages.
Refer to the [log tag option documentation](log_tags.md) for customizing
the log tag format.

### labels, labels-regex, env, and env-regex

The `labels` and `env` options each take a comma-separated list of keys. If
there is collision between `label` and `env` keys, the value of the `env` takes
precedence. Both options add additional fields to the extra attributes of a
logging message.

The `env-regex` and `labels-regex` options are similar to and compatible with
respectively `env` and `labels`. Their values are regular expressions to match
logging-related environment variables and labels. It is used for advanced
[log tag options](log_tags.md).

### fluentd-async

Docker connects to Fluentd in the background. Messages are buffered until the
connection is established. Defaults to `false`.

### fluentd-async-reconnect-interval

When `fluentd-async` is enabled, the `fluentd-async-reconnect-interval` option
defines the interval, in milliseconds, at which the connection to
`fluentd-address` is re-established. This option is useful if the address
resolves to one or more IP addresses, for example a Consul service address.

### fluentd-buffer-limit

Sets the number of events buffered on the memory. Records will be stored in memory
up to this number. If the buffer is full, the call to record logs will fail.
The default is 1048576.
(https://github.com/fluent/fluent-logger-golang/tree/master#bufferlimit)

### fluentd-retry-wait

How long to wait between retries. Defaults to 1 second.

### fluentd-max-retries

The maximum number of retries. Defaults to `4294967295` (2\*\*32 - 1).

### fluentd-sub-second-precision

Generates event logs in nanosecond resolution. Defaults to `false`.

## Fluentd daemon management with Docker

About `Fluentd` itself, see [the project webpage](https://www.fluentd.org)
and [its documents](https://docs.fluentd.org).

To use this logging driver, start the `fluentd` daemon on a host. We recommend
that you use [the Fluentd docker
image](https://hub.docker.com/r/fluent/fluentd/). This image is
especially useful if you want to aggregate multiple container logs on each
host then, later, transfer the logs to another Fluentd node to create an
aggregate store.

### Test container loggers

1.  Write a configuration file (`test.conf`) to dump input logs:

    ```text
    <source>
      @type forward
    </source>

    <match *>
      @type stdout
    </match>
    ```

2.  Launch Fluentd container with this configuration file:

    ```console
    $ docker run -it -p 24224:24224 -v /path/to/conf/test.conf:/fluentd/etc/test.conf -e FLUENTD_CONF=test.conf fluent/fluentd:latest
    ```

3.  Start one or more containers with the `fluentd` logging driver:

    ```console
    $ docker run --log-driver=fluentd your/application
    ```

Title: Fluentd Logging Driver Configuration Options and Usage
Summary
This section provides a comprehensive guide to configuring the Fluentd logging driver in Docker. It covers various options, including `fluentd-address` for specifying the Fluentd daemon's address, `tag` for customizing log tags, and `labels`/`env` options for adding extra attributes to log messages. It also details advanced options like `fluentd-async` for asynchronous logging, `fluentd-async-reconnect-interval` for reconnection intervals, `fluentd-buffer-limit` for memory buffering, and retry-related options like `fluentd-retry-wait` and `fluentd-max-retries`. Additionally, it includes instructions on setting up a Fluentd daemon using a Docker image and testing the logging driver by writing a sample configuration file and launching containers with the `fluentd` logging driver.