github.com/robertojrojas/docker@v1.9.1/docs/reference/logging/fluentd.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Fluentd logging driver" 4 description = "Describes how to use the fluentd logging driver." 5 keywords = ["Fluentd, docker, logging, driver"] 6 [menu.main] 7 parent = "smn_logging" 8 weight=2 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. 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 81 ## Fluentd daemon management with Docker 82 83 About `Fluentd` itself, see [the project webpage](http://www.fluentd.org) 84 and [its documents](http://docs.fluentd.org/). 85 86 To use this logging driver, start the `fluentd` daemon on a host. We recommend 87 that you use [the Fluentd docker 88 image](https://registry.hub.docker.com/u/fluent/fluentd/). This image is 89 especially useful if you want to aggregate multiple container logs on a each 90 host then, later, transfer the logs to another Fluentd node to create an 91 aggregate store. 92 93 ### Testing container loggers 94 95 1. Write a configuration file (`test.conf`) to dump input logs: 96 97 <source> 98 @type forward 99 </source> 100 101 <match docker.**> 102 @type stdout 103 </match> 104 105 2. Launch Fluentd container with this configuration file: 106 107 $ docker run -it -p 24224:24224 -v /path/to/conf/test.conf:/fluentd/etc -e FLUENTD_CONF=test.conf fluent/fluentd:latest 108 109 3. Start one or more containers with the `fluentd` logging driver: 110 111 $ docker run --log-driver=fluentd your/application