From af72814c47842988f0c16c6beb6208b1580f82a3 Mon Sep 17 00:00:00 2001 From: Haissam Kaj Date: Thu, 7 Apr 2016 13:19:40 +0000 Subject: [PATCH] add option to enable network check and document it --- Dockerfile | 1 - README.md | 13 +++++++++++++ entrypoint.sh | 4 ++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ed241e79..4d8b567e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,6 @@ RUN mv /etc/dd-agent/datadog.conf.example /etc/dd-agent/datadog.conf \ && sed -i "/user=dd-agent/d" /etc/dd-agent/supervisor.conf \ && sed -i 's/AGENTUSER="dd-agent"/AGENTUSER="root"/g' /etc/init.d/datadog-agent \ && chmod +x /etc/init.d/datadog-agent \ - && rm /etc/dd-agent/conf.d/network.yaml.default \ && ln -s /opt/datadog-agent/agent/dogstatsd.py /usr/bin/dogstatsd # Add Docker check diff --git a/README.md b/README.md index 5d390951..41b015ee 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ A few parameters can be changed with environment variables. * `PROXY_HOST`, `PROXY_PORT`, `PROXY_USER` and `PROXY_PASSWORD` set the proxy configuration. * `DD_URL` set the Datadog intake server to send Agent data to (used when [using an agent as a proxy](https://github.com/DataDog/dd-agent/wiki/Proxy-Configuration#using-the-agent-as-a-proxy) ) * `DOGSTATSD_ONLY` tell the image to only start a standalone dogstatsd instance. +* `NETWORK_CHECK` enable the network check. **Warning**: read the [network check instructions](#network-check) if you want to enable it. ### Enabling integrations @@ -63,6 +64,18 @@ To enable integrations you can write your YAML configuration files in the `/conf Now when the container starts, all files in `/opt/dd-agent-conf.d` with a `.yaml` extension will be copied to `/etc/dd-agent/conf.d/`. Please note that to add new files you will need to restart the container. + +#### Network check + +By default the network check is not included in this Docker image. That is because the container's network is separated from the host's, so the metrics this check would collect would be irrelevant. + +If you wish to collect host-level network metrics, you will need to run the agent container with the `NETWORK_CHECK` environment variable (`-e NETWORK_CHECK=true`) to explicitly enable the network check, and the `--net=host` option. +This option tells Docker to not containerize the container's networking. It allows the agent to collect network metrics at the host level. + +Using this option requires a few adjustments: +* The `--net=host` option must replace the `-h` one, as recent versions of Docker make these flags mutually exclusive. +* You need to make sure all ports used by the Datadog agent are free on the host. Since the container's networking is not containerized, it will use the ports directly from the host. Refer to the [agent architecture page](https://github.com/DataDog/dd-agent/wiki/Agent-Architecture#supervision-privileges-and-network-ports) for a list of said ports. + ### Build an image To configure specific settings of the agent straight in the image, you may need to build a Docker image on top of this image. diff --git a/entrypoint.sh b/entrypoint.sh index f755a01b..a5b12db9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -40,6 +40,10 @@ if [[ $STATSD_METRIC_NAMESPACE ]]; then sed -i -e "s/^# statsd_metric_namespace:.*$/statsd_metric_namespace: ${STATSD_METRIC_NAMESPACE}/" /etc/dd-agent/datadog.conf fi +if ! [[ $NETWORK_CHECK ]]; then + rm /etc/dd-agent/conf.d/network.yaml.default +fi + find /conf.d -name '*.yaml' -exec cp {} /etc/dd-agent/conf.d \; find /checks.d -name '*.py' -exec cp {} /etc/dd-agent/checks.d \;