logzio / logzio-docker

Forward all your Docker logs to Logz.io
Apache License 2.0
35 stars 17 forks source link

This project has been replaced

Please note that logzio-docker is deprecated. You can continue to use this project in existing implementations—but we encourage you to migrate your Docker log and metrics shipping to these new open source projects from Logz.io:

Happy shipping!
The Support and Integrations teams

logzio-docker

Forward all your Docker logs to Logz.io

ELK Apps Docker dashboard

Usage as a Container

The simplest way to forward all your container's log to Logz.io is to run this repository as a container, with:

docker run -d --restart=always -v /var/run/docker.sock:/var/run/docker.sock logzio/logzio-docker -t ***TOKEN*** -a env=prod

You can pass the --no-stats flag if you do not want stats to be published to Logz.io every second. You need this flag for Docker version < 1.5.

You can pass the --no-logs flag if you do not want logs to be published to Logz.io.

You can also pass the -j switch if all of the logs generated in the containers are in JSON format

You can pass the --no-dockerEvents flag if you do not want events to be published to Logz.io.

The -i/--statsinterval <STATSINTERVAL> downsamples the logs sent to Logz.io. It collects samples and averages them before sending to Logz.io.

The -a allows to add more fields to the log - this can be used to tag specific application, environment etc.

The -z allows you to specify the Zone of your account, us if your account is located in the USA or eu if your account is located in the EU. (set to us by default)

The -e/--endpoint allows controlling to which logzio endpoint the logs will be sent (will override any zone definition)

You can also filter the containers for which the logs/stats are forwarded with:

You can also set your Logz.io token and zone with the following environment variables:

To enrich all log events published to Logz.io with labels that are set on the container use the following options:

Running container in a restricted environment.

Some environments(such as Google Compute Engine) does not allow to access the docker socket without special privileges. You will get EACCES(Error: read EACCES) error if you try to run the container. To run the container in such environments add --privileged to the docker run command.

Example:

docker run --privileged -d --restart=always -v /var/run/docker.sock:/var/run/docker.sock logzio/logzio-docker -t ***TOKEN*** -a env=prod
docker run --privileged -d --restart=always -v /var/run/docker.sock:/var/run/docker.sock logzio/logzio-docker --token=***TOKEN*** -a env=prod

How it works

This container wraps four Docker APIs:

This module wraps docker-loghose and docker-stats to fetch the logs and the stats as a never ending stream of data.