logzio/logzio-logging-plugin

By logzio

Updated over 5 years ago

Plugin
0

921

Logz.io Docker logging plugin

This Docker plugin ships container logs to your Logz.io account. These instructions are for Linux host systems. For other platforms, see the Docker Engine managed plugin system documentation.

Prerequisites

Here's what you need to run the plugin:

  • Docker Engine version 17.05 or later. If you plan to configure this plugin using daemon.json, you need Docker Community Edition (Docker-ce) 18.03 or later.
  • A Logz.io account

Install and configure the Logz.io Docker logging plugin

Step 1: Install the plugin

Choose how you want to install the plugin:

Option 1: Install from Docker CLI
  1. Pull the plugin:
$ docker plugin install logzio/logzio-logging-plugin:<version>

  1. Enable the plugin, if needed:
$ docker plugin enable logzio/logzio-logging-plugin

Continue to Step 2: Set configuration variables

Option 2: Install from source
  1. Clone the repository and check out release branch:
$ git clone https://github.com/logzio/Docker-Logging-Driver.git
$ cd Docker-Logging-Driver
$ git checkout release
  1. Build the plugin:
$ make all
  1. Enable the plugin:
$ docker plugin logzio/logzio-logging-plugin enable
  1. Restart the docker daemon for the changes to apply:
$ service docker restart

Continue to Step 2: Set configuration variables

Step 2: Set configuration variables

Choose how you want to configure the plugin parameters:

Option 1: Configure all containers with daemon.json

The daemon.json file allows you to configure all containers with the same options.

For example:

{
  "log-driver": "logzio/logzio-logging-plugin",
  "log-opts": {
    "logzio-url": "<logzio_account_token>",
    "logzio-token": "<logzio_account_url>",
    "logzio-dir-path": "<dir_path_to_logs_disk_queue>"
  }
}
  1. (Optional) Set any environment variables
  2. Include all required variables in your configuration and any optional variables.

Continue to Step 3: Run containers

Option 2: Configure individual containers at run time

Configure the plugin separately for each container when using the docker run command. For example:

$ docker run --log-driver=logzio/logzio-logging-plugin --log-opt logzio-token=<logzio_account_token> --log-opt logzio-url=<logzio_account_url> --log-opt logzio-dir-path=<dir_path_for_logs_disk_queue> <your_image>
  1. (Optional) Set any environment variables
  2. Include all required variables in your configuration and any optional variables.

Continue to Step 3: Run containers

Required Variables

VariableDescriptionNotes
logzio-tokenLogz.io account token.
logzio-urlLogz.io listener URL. For the EU region, use https://listener-eu.logz.io:8071. Otherwise, use https://listener.logz.io:8071.To find your region, look at your login URL. app.logz.io is US. app-eu.logz.io is EU.
logzio-dir-pathLogs disk path. All the unsent logs are saved to the disk in this location.

Optional Variables

VariableDescriptionDefault value
logzio-sourceEvent source
logzio-formatLog message format, either json or text.text
logzio-tagSee Docker's log tag option documentation{{.ID}} (12 characters of the container ID)
labelsComma-separated list of labels to be included in the log message.
envComma-separated list of environment variables to be included in message.
env-regexA regular expression to match logging-related environment variables. Used for advanced log tag options. If there is collision between the label and env keys, env wins. Both options add additional fields to the attributes of a logging message.
logzio-attributesMeta data in a json format that will be part of every log message that is sent to Logz.io account.

Advanced options: Environment Variables

VariableDescriptionDefault value
LOGZIO_DRIVER_LOGS_DRAIN_TIMEOUTTime to sleep between sending attempts5s
LOGZIO_DRIVER_DISK_THRESHOLDAbove this threshold (in % of disk usage), plugin will start dropping logs70
LOGZIO_DRIVER_CHANNEL_SIZEHow many pending messages can be in the channel before adding them to the disk queue.10000
LOGZIO_MAX_MSG_BUFFER_SIZEAppends logs that are segmented by docker with 16kb limit. It specifies the biggest message, in bytes, that the system can reassemble. 1 MB is the default and the maximum allowed.1048576 (1 MB)
LOGZIO_MAX_PARTIAL_BUFFER__DURATIONHow long the buffer keeps the partial logs before flushing them500ms
Usage example
$ docker run --log-driver=logzio/logzio-logging-plugin \
             --log-opt logzio-token=123456789 \
             --log-opt logzio-url=https://listener.logz.io:8071 \
             --log-opt logzio-dir-path=./docker_logs \
             --log-opt logzio-tag="{{.Name}}/{{.FullID}}" \
             --log-opt labels=region \
             --log-opt env=DEV \
             --env "DEV=true" \
             --label region=us-east-1 \
             <docker_image>

Step 3: Run containers

Now that the plugin is installed and configured, it will send the container while the container is running.

To run your containers, see Docker Documentation.

Credits

This plugin relies on the open source Logz.io go https shipper by Douglas Chimento

Docker Pull Command

docker plugin install logzio/logzio-logging-plugin