Forwarding Docker container logs

Now that we have a basic functional ELK stack, we can start forwarding our Docker logs to it. Support for custom logging drivers has been available from Docker 1.7 onward. In this section, we will configure our Docker host to use the GELF driver. Let's go through the following steps to start receiving our container logs in the ELK stack:

  1. Update the base.rb recipe as follows:
# cookbooks/dockerhost/recipes/base.rb# ...docker_service 'default' do  log_driver 'gelf'  log_opts "gelf-address=udp://#{node['ipaddress']}:12201"  # misc_opts ... (for metrics in the previous section)  # ...end# ...
  1. Update the policy and deploy it using the following code:
$ chef update policies/base.rb$ chef push production policies/base.lock.json ...

Get Docker High Performance - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.