Skip to content

hyperonecom/h1-docker-journal-plugin

Repository files navigation

h1-docker-journal-plugin

Build Status

This Docker plugin extends and expands Docker's logging capabilities so that customers can push their Docker and container logs to HyperOne Journal service.

Prerequisites

Install Docker logging plugin from Registry

  1. Download plugin
docker plugin install h1cr.io/h1-docker-logging-plugin
  1. Enable plugin
docker plugin enable h1cr.io/h1-docker-logging-plugin

Install Docker logging plugin from source

  1. Clone the repository and check out release branch:
cd h1-docker-journal-plugin
git checkout release
  1. Build the plugin:
$ make build
  1. Enable the plugin:
$ make install enable

Usage

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

docker run --rm --label x \
    --log-driver 'h1cr.io/h1-docker-logging-plugin:latest' \
    --log-opt journal-fqdn=5d78e1427fd7e0228fe18f46.journal.pl-waw-1.hyperone.cloud \
    --log-opt journal-token=test \
    -it alpine id

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

Tags

Each message has the following tags assigned by default. The user has the ability to define your own tags through optional variables and they take precedence.

Required variables

  • journal-fqdn – Journal FQDN that will receive logs
  • journal-token – Credential (password) to journal indicated in the parameter journal-fqdn

Optional variables

  • labels – comma-separated list of keys of labels used for tagging of logs. Disabled by default.
  • env – comma-separated list of keys of labels used for tagging of logs. Disabled by default.
  • env-regex – A 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. Disabled by default.
  • flush-buffer-size – How many pending messages can be collected before sending to journal immediately. Default: 500
  • flush-interval – How long (in miliseconds) the buffer keeps messages before flushing them. Default: 15000

Development

  1. Customize config.json for logging plugin stdout
  "entrypoint": ["sh","-c","node /src/index.js &> logs.txt"],
  1. Run following command to access logs:
sudo bash -c 'tail -f -n 1000 /var/lib/docker/plugins/*/rootfs/src/logs.txt'

Release Notes

  • 1.0.0 - First version.

Read also