github.com/slava-ustovytski/docker@v1.8.2-rc1/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  ## Usage
    29  
    30  Configure the default logging driver by passing the
    31  `--log-driver` option to the Docker daemon:
    32  
    33      docker --log-driver=fluentd
    34  
    35  To set the logging driver for a specific container, pass the
    36  `--log-driver` option to `docker run`:
    37  
    38      docker run --log-driver=fluentd ...
    39  
    40  Before using this logging driver, launch a Fluentd daemon. The logging driver
    41  connects to this daemon through `localhost:24224` by default. Use the
    42  `fluentd-address` option to connect to a different address.
    43  
    44      docker run --log-driver=fluentd --log-opt fluentd-address=myhost.local:24224
    45  
    46  If container cannot connect to the Fluentd daemon, the container stops
    47  immediately.
    48  
    49  ## Options
    50  
    51  Users can use the `--log-opt NAME=VALUE` flag to specify additional Fluentd logging driver options.
    52  
    53  ### fluentd-address
    54  
    55  By default, the logging driver connects to `localhost:24224`. Supply the
    56  `fluentd-address` option to connect to a different address.
    57  
    58      docker run --log-driver=fluentd --log-opt fluentd-address=myhost.local:24224
    59  
    60  ### fluentd-tag
    61  
    62  Every Fluentd's event has a tag that indicates where the log comes from. By
    63  default, the driver uses the `docker.{{.ID}}` tag.  Use the `fluentd-tag` option
    64  to change this behavior.
    65  
    66  When specifying a `fluentd-tag` value, you can use the following markup tags:
    67  
    68   - `{{.ID}}`: short container id (12 characters)
    69   - `{{.FullID}}`: full container id
    70   - `{{.Name}}`: container name
    71  
    72  ## Note regarding container names
    73  
    74  At startup time, the system sets the `container_name` field and `{{.Name}}`
    75  in the tags to their values at startup. If you use `docker rename` to rename a
    76  container, the new name is not be reflected in  `fluentd` messages. Instead,
    77  these messages continue to use the original container name.
    78  
    79  ## Fluentd daemon management with Docker
    80  
    81  About `Fluentd` itself, see [the project webpage](http://www.fluentd.org)
    82  and [its documents](http://docs.fluentd.org/).
    83  
    84  To use this logging driver, start the `fluentd` daemon on a host. We recommend
    85  that you use [the Fluentd docker
    86  image](https://registry.hub.docker.com/u/fluent/fluentd/). This image is
    87  especially useful if you want to aggregate multiple container logs on a each
    88  host then, later, transfer the logs to another Fluentd node to create an
    89  aggregate store.
    90  
    91  ### Testing container loggers
    92  
    93  1. Write a configuration file (`test.conf`) to dump input logs:
    94  
    95          <source>
    96            @type forward
    97          </source>
    98      
    99          <match docker.**>
   100            @type stdout
   101          </match>
   102  
   103  2. Launch Fluentd container with this configuration file:
   104  
   105          $ docker run -it -p 24224:24224 -v /path/to/conf/test.conf:/fluentd/etc -e FLUENTD_CONF=test.conf fluent/fluentd:latest
   106  
   107  3. Start one or more containers with the `fluentd` logging driver:
   108  
   109          $ docker run --log-driver=fluentd your/application