Docker Logstash Integration - run once per Docker host.
1M+
Ship all your logs from Docker (including in container logs) to Logstash via logstash-forwarder (aka lumberjack).
This means:
/etc/logstash-forwarder.conf, only the files section gets evaluated while network section is globally configured).I wasn't too happy with existing possibilities and while I know that the Docker team is working on a solution, this scratches my itch right now.
Also I didn't see an obvious way to extend docker-gen to handle generic in container templates.
Besides that, how much reason do you need to play with Go & Docker? ;-)
docker-logstash-forwarder listens to Docker events and continually restarts a logstash-forwarder instance, after refreshing its configuration, every laziness seconds after a new event was received (to avoid unnecessary restarts - configurable via -laziness flag - defaults to 5 seconds).
For every running container the docker log file is added and it is checked if a logstash-forwarder config exists within the container at /etc/logstash-forwarder.conf.
If an in container specific config exists, the path of all files will be expanded to be valid within the logstash-forwarder container before adding them to the global configuration.
This requires the following (in container defaults in brackets):
/var/lib/docker)unix:///var/run/docker.sock)logstash:5043)Mount the directory containing your Docker data into the containers /var/lib/docker - i.e. run the container with -v /var/lib/docker:/var/lib/docker:ro (assuming your Docker files are stored in /var/lib/docker on the host).
For communication with Docker the following endpoints are evaluated:
-docker command line flag$DOCKER_HOST environment variableunix:///var/run/docker.sockIt is suggested to use the later - as in run the container with -v /var/run/docker.sock:/var/run/docker.sock
Behind the screens fsouza/go-dockerclient is used for communication with Docker.
For communication with Logstash the following endpoints are evaluated:
-logstash command line flag$LOGSTASH_HOST environment variablelogstash:5043This allows you to docker -link your Logstash instance to the containers logstash host.
logstash-forwarder authentication can be managed in the following ways:
-config flag (only the network section is evaluated)/mnt/logstash-forwarderIf you have my elasticsearch & logstash containers running just do
$ docker pull digitalwonderland/logstash-forwarder
$ docker run -d --name logstash-forwarder -v /var/lib/docker:/var/lib/docker:ro -v /var/run/docker.sock:/var/run/docker.sock --link logstash:logstash --volumes-from logstash digitalwonderland/logstash-forwarder
If you start from scratch / use Vagrant / are on a Mac: just clone this repository and run vagrant up. This gives you a VM based on CoreOS (which is awesome btw) running those 3 containers & Kibana listening to localhost:5601 (Docker listens to localhost:2375).
docker-logstash-forwarder must be run as root until Docker provides configurable ownership of shared volumes, because /var/lib/docker is owned by root on the host and mounted read only, so a non root user can not read from it (docker#7918).
The path of the containers content, on the hosts file system, has to be calculated by trying to take an educated guess based on your currently used docker driver since the docker folks consider this path internal and don't want to make it available via API (docker#7915).
Known to be working drivers are:
Last but not least it probably should be mentioned, that this is the first time I wrote any go code (a few days, after work), so any 'Duh' pointers are greatly appreciated.
Pull Requests welcome :)
Content type
Image
Digest
sha256:b3456ef27…
Size
80.2 MB
Last updated
about 9 years ago
docker pull digitalwonderland/logstash-forwarder