This is a quick guide on setting up td-agent container with Docker 1.8
- Create a directory to store your dockerfile and td-agent config file.
- Create a dockerfile as shown below
- Create td-agent.conf file as shown below
- Build the docker image
- Start elasticsearch container. As you can see from the td-agent.conf, the td-agent container will link to this elasticsearch container. Please note that this setup is not using any persistent storage mapping. You can refer to this link for more information on how to setup that mapping.
- Start your td-agent container
- Launch a hello-world to see if td-agent is forwarding log to elasticsearch container. Please note that Docker 1.8 add fluentd as one of the logging-driver. So this command will not work if you are using Docker with older version
- Use the following command to check if elasticsearch container is receiving log. You can check container ID or container name using docker ps -a
mkdir ~/td-agent-es && cd ~/td-agent-es
docker build -t td-agent-es .
docker run -d -p 9200:9200 -p 9300:9300 --name es elasticsearch
docker run -d -p 24224:24224 --link es:es --name td-agent td-agent-es
docker run --log-driver=fluentd --log-opt fluentd-address=[your-host-IP-address]:24224 hello-world
curl -XGET 'http://[your-host-IP-address]:9200/_all/_search?q=*'
No comments:
Post a Comment