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:
- 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# ...
- Update the policy and deploy it using the following code:
$ chef update policies/base.rb$ chef push production policies/base.lock.json ...