From d82daa0186b0ec1b15f041358c10399ae814107e Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Fri, 27 Oct 2023 07:05:55 +0200 Subject: [PATCH] chore: tier 1 freshness: content/config/containers/logging/fluentd.md Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- content/config/containers/logging/fluentd.md | 85 +++++++++++--------- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/content/config/containers/logging/fluentd.md b/content/config/containers/logging/fluentd.md index 8ff4495eb5..26f6216c1a 100644 --- a/content/config/containers/logging/fluentd.md +++ b/content/config/containers/logging/fluentd.md @@ -1,11 +1,11 @@ --- -description: Describes how to use the fluentd logging driver. +description: Learn how to use the fluentd logging driver keywords: Fluentd, docker, logging, driver title: Fluentd logging driver aliases: -- /engine/reference/logging/fluentd/ -- /reference/logging/fluentd/ -- /engine/admin/logging/fluentd/ + - /engine/reference/logging/fluentd/ + - /reference/logging/fluentd/ + - /engine/admin/logging/fluentd/ --- The `fluentd` logging driver sends container logs to the @@ -18,40 +18,38 @@ In addition to the log message itself, the `fluentd` log driver sends the following metadata in the structured log message: | Field | Description | -|:-----------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------| +| :--------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | | `container_id` | The full 64-character container ID. | -| `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. | +| `container_name` | The container name at the time it was started. If you use `docker rename` to rename a container, the new name isn't reflected in the journal entries. | | `source` | `stdout` or `stderr` | | `log` | The container log | -The `docker logs` command is not available for this logging driver. +The `docker logs` command isn't available for this logging driver. ## Usage Some options are supported by specifying `--log-opt` as many times as needed: - - `fluentd-address`: specify a socket address to connect to the Fluentd daemon, ex `fluentdhost:24224` or `unix:///path/to/fluentd.sock` - - `tag`: specify a tag for fluentd message, which interprets some markup, ex `{{.ID}}`, `{{.FullID}}` or `{{.Name}}` `docker.{{.ID}}` +- `fluentd-address`: specify a socket address to connect to the Fluentd daemon, ex `fluentdhost:24224` or `unix:///path/to/fluentd.sock`. +- `tag`: specify a tag for Fluentd messages. Supports some Go template markup, ex `{{.ID}}`, `{{.FullID}}` or `{{.Name}}` `docker.{{.ID}}`. - - To use the `fluentd` driver as the default logging driver, set the `log-driver` - and `log-opt` keys to appropriate values in the `daemon.json` file, which is - located in `/etc/docker/` on Linux hosts or - `C:\ProgramData\docker\config\daemon.json` on Windows Server. For more about - +configuring Docker using `daemon.json`, see - +[daemon.json](../../../engine/reference/commandline/dockerd.md#daemon-configuration-file). +To use the `fluentd` driver as the default logging driver, set the `log-driver` +and `log-opt` keys to appropriate values in the `daemon.json` file, which is +located in `/etc/docker/` on Linux hosts or +`C:\ProgramData\docker\config\daemon.json` on Windows Server. For more about +configuring Docker using `daemon.json`, see [daemon.json](../../../engine/reference/commandline/dockerd.md#daemon-configuration-file). The following example sets the log driver to `fluentd` and sets the `fluentd-address` option. - ```json - { - "log-driver": "fluentd", - "log-opts": { - "fluentd-address": "fluentdhost:24224" - } - } - ``` +```json +{ + "log-driver": "fluentd", + "log-opts": { + "fluentd-address": "fluentdhost:24224" + } +} +``` Restart Docker for the changes to take effect. @@ -65,13 +63,17 @@ Restart Docker for the changes to take effect. To set the logging driver for a specific container, pass the `--log-driver` option to `docker run`: - docker run --log-driver=fluentd ... +```text +docker run --log-driver=fluentd ... +``` Before using this logging driver, launch a Fluentd daemon. The logging driver connects to this daemon through `localhost:24224` by default. Use the `fluentd-address` option to connect to a different address. - docker run --log-driver=fluentd --log-opt fluentd-address=fluentdhost:24224 +```text +docker run --log-driver=fluentd --log-opt fluentd-address=fluentdhost:24224 +``` If container cannot connect to the Fluentd daemon, the container stops immediately unless the `fluentd-async` option is used. @@ -97,7 +99,6 @@ By default, Docker uses the first 12 characters of the container ID to tag log m Refer to the [log tag option documentation](log_tags.md) for customizing the log tag format. - ### labels, labels-regex, env, and env-regex The `labels` and `env` options each take a comma-separated list of keys. If @@ -128,7 +129,7 @@ How long to wait between retries. Defaults to 1 second. ### fluentd-max-retries -The maximum number of retries. Defaults to `4294967295` (2**32 - 1). +The maximum number of retries. Defaults to `4294967295` (2\*\*32 - 1). ### fluentd-sub-second-precision @@ -148,20 +149,26 @@ aggregate store. ### Test container loggers -1. Write a configuration file (`test.conf`) to dump input logs: +1. Write a configuration file (`test.conf`) to dump input logs: - - @type forward - + ```none + + @type forward + - - @type stdout - + + @type stdout + + ```none -2. Launch Fluentd container with this configuration file: +2. Launch Fluentd container with this configuration file: - $ docker run -it -p 24224:24224 -v /path/to/conf/test.conf:/fluentd/etc/test.conf -e FLUENTD_CONF=test.conf fluent/fluentd:latest + ```none + $ docker run -it -p 24224:24224 -v /path/to/conf/test.conf:/fluentd/etc/test.conf -e FLUENTD_CONF=test.conf fluent/fluentd:latest + ``` -3. Start one or more containers with the `fluentd` logging driver: +3. Start one or more containers with the `fluentd` logging driver: - $ docker run --log-driver=fluentd your/application \ No newline at end of file + ```none + $ docker run --log-driver=fluentd your/application + ```