github.com/mheon/docker@v0.11.2-0.20150922122814-44f47903a831/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 --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](/reference/logging/log_tags/) for customizing
    73  the log tag format.
    74  
    75  
    76  ## Fluentd daemon management with Docker
    77  
    78  About `Fluentd` itself, see [the project webpage](http://www.fluentd.org)
    79  and [its documents](http://docs.fluentd.org/).
    80  
    81  To use this logging driver, start the `fluentd` daemon on a host. We recommend
    82  that you use [the Fluentd docker
    83  image](https://registry.hub.docker.com/u/fluent/fluentd/). This image is
    84  especially useful if you want to aggregate multiple container logs on a each
    85  host then, later, transfer the logs to another Fluentd node to create an
    86  aggregate store.
    87  
    88  ### Testing container loggers
    89  
    90  1. Write a configuration file (`test.conf`) to dump input logs:
    91  
    92          <source>
    93            @type forward
    94          </source>
    95      
    96          <match docker.**>
    97            @type stdout
    98          </match>
    99  
   100  2. Launch Fluentd container with this configuration file:
   101  
   102          $ docker run -it -p 24224:24224 -v /path/to/conf/test.conf:/fluentd/etc -e FLUENTD_CONF=test.conf fluent/fluentd:latest
   103  
   104  3. Start one or more containers with the `fluentd` logging driver:
   105  
   106          $ docker run --log-driver=fluentd your/application