github.com/rsampaio/docker@v0.7.2-0.20150827203920-fdc73cc3fc31/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 +++ 9 <![end-metadata]--> 10 11 # Fluentd logging driver 12 13 The `fluentd` logging driver sends container logs to the 14 [Fluentd](http://www.fluentd.org/) collector as structured log data. Then, users 15 can use any of the [various output plugins of 16 Fluentd](http://www.fluentd.org/plugins) to write these logs to various 17 destinations. 18 19 In addition to the log message itself, the `fluentd` log 20 driver sends the following metadata in the structured log message: 21 22 | Field | Description | 23 -------------------|-------------------------------------| 24 | `container_id` | The full 64-character container ID. | 25 | `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. | 26 | `source` | `stdout` or `stderr` | 27 28 The `docker logs` command is not available for this logging driver. 29 30 ## Usage 31 32 Some options are supported by specifying `--log-opt` as many times as needed: 33 34 - `fluentd-address`: specify `host:port` to connect `localhost:24224` 35 - `fluentd-tag`: specify tag for fluentd message, which interpret some markup, ex `{{.ID}}`, `{{.FullID}}` or `{{.Name}}` `docker.{{.ID}}` 36 37 38 Configure the default logging driver by passing the 39 `--log-driver` option to the Docker daemon: 40 41 docker --log-driver=fluentd 42 43 To set the logging driver for a specific container, pass the 44 `--log-driver` option to `docker run`: 45 46 docker run --log-driver=fluentd ... 47 48 Before using this logging driver, launch a Fluentd daemon. The logging driver 49 connects to this daemon through `localhost:24224` by default. Use the 50 `fluentd-address` option to connect to a different address. 51 52 docker run --log-driver=fluentd --log-opt fluentd-address=myhost.local:24224 53 54 If container cannot connect to the Fluentd daemon, the container stops 55 immediately. 56 57 ## Options 58 59 Users can use the `--log-opt NAME=VALUE` flag to specify additional Fluentd logging driver options. 60 61 ### fluentd-address 62 63 By default, the logging driver connects to `localhost:24224`. Supply the 64 `fluentd-address` option to connect to a different address. 65 66 docker run --log-driver=fluentd --log-opt fluentd-address=myhost.local:24224 67 68 ### fluentd-tag 69 70 Every Fluentd's event has a tag that indicates where the log comes from. By 71 default, the driver uses the `docker.{{.ID}}` tag. Use the `fluentd-tag` option 72 to change this behavior. 73 74 When specifying a `fluentd-tag` value, you can use the following markup tags: 75 76 - `{{.ID}}`: short container id (12 characters) 77 - `{{.FullID}}`: full container id 78 - `{{.Name}}`: container name 79 80 ## Note regarding container names 81 82 At startup time, the system sets the `container_name` field and `{{.Name}}` 83 in the tags to their values at startup. If you use `docker rename` to rename a 84 container, the new name is not be reflected in `fluentd` messages. Instead, 85 these messages continue to use the original container name. 86 87 ## Fluentd daemon management with Docker 88 89 About `Fluentd` itself, see [the project webpage](http://www.fluentd.org) 90 and [its documents](http://docs.fluentd.org/). 91 92 To use this logging driver, start the `fluentd` daemon on a host. We recommend 93 that you use [the Fluentd docker 94 image](https://registry.hub.docker.com/u/fluent/fluentd/). This image is 95 especially useful if you want to aggregate multiple container logs on a each 96 host then, later, transfer the logs to another Fluentd node to create an 97 aggregate store. 98 99 ### Testing container loggers 100 101 1. Write a configuration file (`test.conf`) to dump input logs: 102 103 <source> 104 @type forward 105 </source> 106 107 <match docker.**> 108 @type stdout 109 </match> 110 111 2. Launch Fluentd container with this configuration file: 112 113 $ docker run -it -p 24224:24224 -v /path/to/conf/test.conf:/fluentd/etc -e FLUENTD_CONF=test.conf fluent/fluentd:latest 114 115 3. Start one or more containers with the `fluentd` logging driver: 116 117 $ docker run --log-driver=fluentd your/application