From 70d4a1f2fdd1cdcadbe22f67b835e8621df7b828 Mon Sep 17 00:00:00 2001 From: Misty Stanley-Jones Date: Tue, 22 Nov 2016 14:58:22 -0800 Subject: [PATCH] Fix-ups, rewrites, metadata changes --- engine/admin/logging/nats.md | 55 +++++++++-------- engine/admin/logging/overview.md | 101 ++++++++++++++----------------- 2 files changed, 74 insertions(+), 82 deletions(-) diff --git a/engine/admin/logging/nats.md b/engine/admin/logging/nats.md index 74373952ed0b..81f11ccb007a 100644 --- a/engine/admin/logging/nats.md +++ b/engine/admin/logging/nats.md @@ -1,15 +1,9 @@ --- description: Describes how to use NATS for publishing log entries -keywords: -- NATS, nats.io, messaging, docker, logging, driver -menu: - main: - parent: smn_logging +keywords: NATS, nats.io, messaging, docker, logging, driver title: NATS logging driver --- -# NATS Logging driver - Docker logging driver for sending container the logs as events published to NATS in JSON format. ## Usage @@ -17,12 +11,16 @@ Docker logging driver for sending container the logs as events published to NATS You can configure the default logging driver by passing the `--log-driver` option to the Docker daemon: - dockerd --log-driver=nats +```bash +$ dockerd --log-driver=nats +``` You can set the logging driver for a specific container by using the `--log-driver` option to `docker run`: - docker run --log-driver=nats ... +```bash +$ docker run --log-driver=nats ... +``` This log driver does not implement a reader so it is incompatible with `docker logs`. @@ -50,36 +48,41 @@ for NATS: Below is an example usage of the driver for sending logs to a node in a NATS cluster to the `docker.logs` subject: -``` - docker run --log-driver=nats \ - --log-opt nats-subject=docker.logs - --log-opt nats-servers=nats://nats-node-1:4222,nats://nats-node-2:4222, nats://nats-node-3:4222 - your/application +```bash +$ docker run --log-driver=nats \ + --log-opt nats-subject=docker.logs \ + --log-opt nats-servers=nats://nats-node-1:4222,nats://nats-node-2:4222,nats://nats-node-3:4222 \ + your/application ``` By default, the tag is used as the subject for NATS, so it has to be a valid subject in case subject it is left unspecified: -``` - docker run --log-driver nats \ - --log-opt tag="docker.{{.ID}}.{{.ImageName}}" your/application +```bash +{% raw %} +$ docker run --log-driver nats \ + --log-opt tag="docker.{{.ID}}.{{.ImageName}}" + your/application +{% endraw %} ``` Secure connection to NATS using TLS can be customized by setting `tls://` scheme in the URI and absolute paths to the certs and key files: -``` - docker run --log-driver nats \ - --log-opt nats-tls-key=/srv/configs/certs/client-key.pem \ - --log-opt nats-tls-cert=/srv/configs/certs/client-cert.pem \ - --log-opt nats-tls-ca-cert=/srv/configs/certs/ca.pem \ - --log-opt nats-servers="tls://127.0.0.1:4223,tls://127.0.0.1:4222" your/application +```bash +docker run --log-driver nats \ + --log-opt nats-tls-key=/srv/configs/certs/client-key.pem \ + --log-opt nats-tls-cert=/srv/configs/certs/client-cert.pem \ + --log-opt nats-tls-ca-cert=/srv/configs/certs/ca.pem \ + --log-opt nats-servers="tls://127.0.0.1:4223,tls://127.0.0.1:4222" \ + your/application ``` Skip verify is enabled by default, in order to deactivate we can specify `nats-tls-skip-verify`: -``` +```bash docker run --log-driver nats \ - --log-opt nats-tls-skip-verify \ - --log-opt nats-servers="tls://127.0.0.1:4223,tls://127.0.0.1:4222" your/application + --log-opt nats-tls-skip-verify \ + --log-opt nats-servers="tls://127.0.0.1:4223,tls://127.0.0.1:4222" \ + your/application ``` diff --git a/engine/admin/logging/overview.md b/engine/admin/logging/overview.md index 49039981209b..67625dad5c2e 100644 --- a/engine/admin/logging/overview.md +++ b/engine/admin/logging/overview.md @@ -1,17 +1,9 @@ - - - -# Configure logging drivers +keywords = "docker, logging, driver, Fluentd" +--- The container can have a different logging driver than the Docker daemon. Use the `--log-driver=VALUE` with the `docker run` command to configure the @@ -33,45 +25,42 @@ supported: | `gcplogs` | Google Cloud Logging driver for Docker. Writes log messages to Google Cloud Logging. | | `nats` | NATS logging driver for Docker. Publishes log entries to a NATS server. | -The `docker logs`command is available only for the `json-file` and `journald` +The `docker logs` command is only available for the `json-file` and `journald` logging drivers. The `labels` and `env` options add additional attributes for use with logging drivers that accept them. Each option takes a comma-separated list of keys. If -there is collision between `label` and `env` keys, the value of the `env` takes -precedence. +there is a collision between `label` and `env` keys, the value of the `env` +takes precedence. -To use attributes, specify them when you start the Docker daemon. For example, -to manually start the daemon with the `json-file` driver, and include additional -attributes in the output, run the following command: +Specify attributes when you start the Docker daemon. For example, the following +command starts the daemon with the `json-file` driver and includes additional +attributes in the output. ```bash -$ dockerd \ - --log-driver=json-file \ - --log-opt labels=foo \ - --log-opt env=foo,fizz +$ dockerd --log-driver=json-file \ + --log-opt labels=foo \ + --log-opt env=foo,fizz ``` -Then, run a container and specify values for the `labels` or `env`. For -example, you might use this: +This command runs a container with specific values for the `labels` or `env`. ```bash $ docker run -dit --label foo=bar -e fizz=buzz alpine sh ``` -This adds additional fields to the log depending on the driver, e.g. for -`json-file` that looks like: +This adds additional fields to the log depending on the driver. If you use +`json-file`, it might add the attributes as follows: ```json "attrs":{"fizz":"buzz","foo":"bar"} ``` - ## json-file options The following logging options are supported for the `json-file` logging driver: -```bash +```none --log-opt max-size=[0-9]+[kmg] --log-opt max-file=[0-9]+ --log-opt labels=label1,label2 @@ -94,7 +83,7 @@ from the newest log file. The following logging options are supported for the `syslog` logging driver: -```bash +```none --log-opt syslog-address=[tcp|udp|tcp+tls]://host:port --log-opt syslog-address=unix://path --log-opt syslog-address=unixgram://path @@ -203,16 +192,16 @@ must specify a `port` value. The following example shows how to connect the ```bash $ docker run -dit \ - --log-driver=gelf \ - --log-opt gelf-address=udp://192.168.0.42:12201 \ - alpine sh + --log-driver=gelf \ + --log-opt gelf-address=udp://192.168.0.42:12201 \ + alpine sh ``` By default, Docker uses the first 12 characters of the container ID to tag log messages. Refer to the [log tag option documentation](log_tags.md) for customizing the log tag format. -The `labels` and `env` options are supported by the gelf logging +The `labels` and `env` options are supported by the `gelf` logging driver. It adds additional key on the `extra` fields, prefixed by an underscore (`_`). @@ -246,72 +235,71 @@ For example, to specify both additional options: ```bash $ docker run -dit \ - --log-driver=fluentd \ - --log-opt fluentd-address=localhost:24224 \ - --log-opt tag="docker.{{.Name}}" \ - alpine sh + --log-driver=fluentd \ + --log-opt fluentd-address=localhost:24224 \ + --log-opt tag="docker.{{.Name}}" \ + alpine sh ``` -If container cannot connect to the Fluentd daemon on the specified address and -`fluentd-async-connect` is not enabled, the container stops immediately. -For detailed information on working with this logging driver, -see [the fluentd logging driver](fluentd.md) - +If cthe ontainer cannot connect to the Fluentd daemon on the specified address +and `fluentd-async-connect` is not enabled, the container stops immediately. For +detailed information about working with this logging driver, see [the fluentd +logging driver](fluentd.md) ## Amazon CloudWatch Logs options The Amazon CloudWatch Logs logging driver supports the following options: -```bash +```none --log-opt awslogs-region= --log-opt awslogs-group= --log-opt awslogs-stream= ``` -For detailed information on working with this logging driver, see [the awslogs -logging driver](awslogs.md) reference documentation. +For detailed information about working with this logging driver, see +[the awslogs logging driver](awslogs.md) reference documentation. ## Splunk options -The Splunk logging driver requires the following options: +The `splunk`` logging driver requires the following options: -```bash +```none --log-opt splunk-token= --log-opt splunk-url=https://your_splunk_instance:8088 ``` -For detailed information about working with this logging driver, see the +For detailed information about working with the `splunk` logging driver, see the [Splunk logging driver](splunk.md) reference documentation. ## ETW logging driver options -The etwlogs logging driver does not require any options to be specified. This -logging driver forwards each log message as an ETW event. An ETW listener -can then be created to listen for these events. +The `etwlogs` logging driver forwards each log message as an ETW event. An ETW +listener can then be created to listen for these events. This driver does not +accept any options. The ETW logging driver is only available on Windows. For detailed information -on working with this logging driver, see [the ETW logging driver](etwlogs.md) +about working with this logging driver, see [the ETW logging driver](etwlogs.md) reference documentation. ## Google Cloud Logging options The Google Cloud Logging driver supports the following options: -```bash +```none --log-opt gcp-project= --log-opt labels=, --log-opt env=, --log-opt log-cmd=true ``` -For detailed information about working with this logging driver, see the -[Google Cloud Logging driver](gcplogs.md). reference documentation. +For detailed information about working with the Google Cloud logging driver, see +the [Google Cloud Logging driver](gcplogs.md). reference documentation. ## NATS logging options The NATS logging driver supports the following options: -```bash +```none --log-opt labels=, --log-opt env=, --log-opt tag= @@ -324,4 +312,5 @@ The NATS logging driver supports the following options: --log-opt nats-tls-skip-verify="" ``` -For detailed information, see [the NATS logging driver](nats.md) reference documentation. +For detailed information, see [the NATS logging driver](nats.md) reference +documentation.