Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

datadog agent not reachable from inside docker container

I installed dd-agent on Amazon linux ec2. If I run my python script directly on the host machine (I used the SDK named "dogstatsd-python"), all the metrics can be sent to datadog (I logged in to datadoghq.com and saw the metrics there). the script is something like:

from statsd import statsd
statsd.connect('localhost', 8125)
statsd.increment('mymetrics')

However, I launched a docker container and run the same script from inside the container:

from statsd import statsd
statsd.connect('172.14.0.1', 8125)
statsd.increment('my metrics')

'172.14.0.1' is the IP of the host, which was extracted with command

netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}'

No metrics were sent to datadog at all.....

I'm guessing that maybe it's due to some configuration issue like "address binding". Maybe the dd-agent I installed on the host can only receive metrics from 'localhost'.

Hope someone could help me. Thank you in advance.

like image 251
sheny35 Avatar asked Jan 31 '16 06:01

sheny35


People also ask

How do I collect Docker logs?

Docker container logs are generated by the Docker containers. They need to be collected directly from the containers. Any messages that a container sends to stdout or stderr is logged then passed on to a logging driver that forwards them to a remote destination of your choosing.

What is the Datadog agent written in?

By default, the Agent will be built to use Python 3 but you can select which Python version you want to use: invoke agent.

What is an agent in Docker?

The Docker agent executes flow runs in individual Docker containers. This provides more isolation and control than the Local Agent, while still working well on a single machine.


1 Answers

You will need to set non_local_traffic: yes in your /etc/dd-agent/datadog.conf file. Otherwise the agent will reject metrics from containers.

After setting, you will need to restart the agent for the change to take effect: sudo /etc/init.d/datadog-agent restart or sudo service datadog-agent restart

The docker-dd-agent image enables non_local_traffic: yes by default.

like image 126
Scott Enriquez Avatar answered Oct 17 '22 04:10

Scott Enriquez