码头容器内无法达到数据采集代理 [英] datadog agent not reachable from inside docker container
问题描述
脚本是这样的:
从statsd导入statsd
statsd.connect('localhost' 8125)
statsd.increment('mymetrics')
但是,我启动了一个docker容器并从容器内运行相同的脚本:
c $ c from statsd import statsd
statsd.connect('172.14.0.1 ',8125)
statsd.increment('my metrics')
'172.14.0.1 '是主机的IP,它是用命令提取的。
netstat -nr | grep'^ 0\.0\.0\.0'| awk'{print $ 2}'
没有指标发送到datadog .....
我猜这可能是由于某些配置问题,如地址绑定。也许我在主机上安装的dd代理只能从'localhost'接收指标。
希望有人可以帮助我。先谢谢你。
您将需要设置 non_local_traffic:yes
c $ c> /etc/dd-agent/datadog.conf 文件。否则代理将拒绝来自容器的指标。
设置完成后,您需要重新启动代理才能使更改生效: sudo / etc /init.d/datadog-agent restart
或 sudo service datadog-agent restart
docker-dd-agent 图像启用 non_local_traffic:yes
。
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.
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.
这篇关于码头容器内无法达到数据采集代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!