0

我已经配置了 docker-daemon,还添加了修改的 auto_conf。我应该如何传递 %%host%% 变量?

sudo docker run -d --name dd-agent \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -v /proc/:/host/proc/:ro \
  -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
  -e API_KEY=XXXXXXXXXXXXXXX \
  -e SD_BACKEND=docker \
  -e SD_CONFIG_BACKEND=etcd \
  -e SD_BACKEND_HOST=XX.XXX.XX.XX \
  -e SD_BACKEND_PORT=XXXX \
  datadog/docker-dd-agent:latest

更改了 etcd.yaml

docker_images:
  - image1

init_config:

instances:
  - url: "http://XX.XXX.XX.XX:XXXX"

但是当我尝试做

sudo docker exec -it dd-agent /etc/init.d/datadog-agent configcheck

2017-08-07 19:18:37,637 | WARNING | dd.collector | utils.service_discovery.abstract_sd_backend(abstract_sd_backend.py:66) | Failed to interpolate variable %%host%% for the url parameter. Dropping this configuration.

收集器日志显示

NotFound: 404 Client Error: Not Found ("No such image: sha256:6d13e6f1665c7abcd9edeba651a1f883ab68dbb73153d6cc55145add585373fc")
2017-08-08 17:16:11 UTC | ERROR | dd.collector | utils.dockerutil(dockerutil.py:548) | Exception getting docker image name
Traceback (most recent call last):
  File "/opt/datadog-agent/agent/utils/dockerutil.py", line 533, in image_name_extractor
    image_spec = self.client.inspect_image(image)
  File "/opt/datadog-agent/embedded/lib/python2.7/site-packages/docker/utils/decorators.py", line 21, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/opt/datadog-agent/embedded/lib/python2.7/site-packages/docker/api/image.py", line 136, in inspect_image
    self._get(self._url("/images/{0}/json", image)), True
  File "/opt/datadog-agent/embedded/lib/python2.7/site-packages/docker/client.py", line 178, in _result
    self._raise_for_status(response)
  File "/opt/datadog-agent/embedded/lib/python2.7/site-packages/docker/client.py", line 173, in _raise_for_status
    raise errors.NotFound(e, response, explanation=explanation)
4

1 回答 1

1

嗯,所以您正在尝试使用自动发现来查找 dd-agent 应该在哪个容器上运行 etcd 检查?并且您正在使用 auto_conf 文件方法?在那里,您想知道如何应用%%host%%模板变量?

如果这就是您感兴趣的内容,我想您会希望将其添加到您etcd.yamlurl行中,如示例文件所示,如下所示:

docker_images:
  - etcd

init_config:

instances:
  - url: "http://%%host%%:%%port_0%%"
于 2017-08-07T23:56:57.403 回答