github.com/portworx/docker@v1.12.1/docs/admin/logging/fluentd.md (about) 1 <!--[metadata]> 2 +++ 3 aliases = ["/engine/reference/logging/fluentd/"] 4 title = "Fluentd logging driver" 5 description = "Describes how to use the fluentd logging driver." 6 keywords = ["Fluentd, docker, logging, driver"] 7 [menu.main] 8 parent = "smn_logging" 9 +++ 10 <![end-metadata]--> 11 12 # Fluentd logging driver 13 14 The `fluentd` logging driver sends container logs to the 15 [Fluentd](http://www.fluentd.org/) collector as structured log data. Then, users 16 can use any of the [various output plugins of 17 Fluentd](http://www.fluentd.org/plugins) to write these logs to various 18 destinations. 19 20 In addition to the log message itself, the `fluentd` log 21 driver sends the following metadata in the structured log message: 22 23 | Field | Description | 24 -------------------|-------------------------------------| 25 | `container_id` | The full 64-character container ID. | 26 | `container_name` | The container name at the time it was started. If you use `docker rename` to rename a container, the new name is not reflected in the journal entries. | 27 | `source` | `stdout` or `stderr` | 28 29 The `docker logs` command is not available for this logging driver. 30 31 ## Usage 32 33 Some options are supported by specifying `--log-opt` as many times as needed: 34 35 - `fluentd-address`: specify `host:port` to connect `localhost:24224` 36 - `tag`: specify tag for fluentd message, which interpret some markup, ex `{{.ID}}`, `{{.FullID}}` or `{{.Name}}` `docker.{{.ID}}` 37 38 39 Configure the default logging driver by passing the 40 `--log-driver` option to the Docker daemon: 41 42 docker daemon --log-driver=fluentd 43 44 To set the logging driver for a specific container, pass the 45 `--log-driver` option to `docker run`: 46 47 docker run --log-driver=fluentd ... 48 49 Before using this logging driver, launch a Fluentd daemon. The logging driver 50 connects to this daemon through `localhost:24224` by default. Use the 51 `fluentd-address` option to connect to a different address. 52 53 docker run --log-driver=fluentd --log-opt fluentd-address=myhost.local:24224 54 55 If container cannot connect to the Fluentd daemon, the container stops 56 immediately unless the `fluentd-async-connect` option is used. 57 58 ## Options 59 60 Users can use the `--log-opt NAME=VALUE` flag to specify additional Fluentd logging driver options. 61 62 ### fluentd-address 63 64 By default, the logging driver connects to `localhost:24224`. Supply the 65 `fluentd-address` option to connect to a different address. 66 67 docker run --log-driver=fluentd --log-opt fluentd-address=myhost.local:24224 68 69 ### tag 70 71 By default, Docker uses the first 12 characters of the container ID to tag log messages. 72 Refer to the [log tag option documentation](log_tags.md) for customizing 73 the log tag format. 74 75 76 ### labels and env 77 78 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. 79 80 ### fluentd-async-connect 81 82 Docker connects to Fluentd in the background. Messages are buffered until the connection is established. 83 84 ## Fluentd daemon management with Docker 85 86 About `Fluentd` itself, see [the project webpage](http://www.fluentd.org) 87 and [its documents](http://docs.fluentd.org/). 88 89 To use this logging driver, start the `fluentd` daemon on a host. We recommend 90 that you use [the Fluentd docker 91 image](https://hub.docker.com/r/fluent/fluentd/). This image is 92 especially useful if you want to aggregate multiple container logs on each 93 host then, later, transfer the logs to another Fluentd node to create an 94 aggregate store. 95 96 ### Testing container loggers 97 98 1. Write a configuration file (`test.conf`) to dump input logs: 99 100 <source> 101 @type forward 102 </source> 103 104 <match docker.**> 105 @type stdout 106 </match> 107 108 2. Launch Fluentd container with this configuration file: 109 110 $ docker run -it -p 24224:24224 -v /path/to/conf/test.conf:/fluentd/etc -e FLUENTD_CONF=test.conf fluent/fluentd:latest 111 112 3. Start one or more containers with the `fluentd` logging driver: 113 114 $ docker run --log-driver=fluentd your/application