Skip to main content

Exporting to Datadog using Docker

Monitoring with Datadog

Here we provide a simple example of how to scrape CloudFlow metrics into Datadog with docker run. The basic idea is that you need to run a Datadog Agent that regularly scrapes CloudFlow’s /federate endpoint to fetch metrics, and writes the results into your Datadog cloud instance. You may run this agent on any infrastructure of your choice. It could be in a docker container on your PC, hosted on a cloud provider, or even hosted at CloudFlow. A single agent is used to scrape all of the metrics for your account.

Datadog

Obtain the following information from your instance of Datadog:

  • DATADOG_API_KEY: this will appear during the Datadog setup wizard. Or generate one by visiting the API Keys area of Organization Settings.
  • Get started with Datadog.
  • Specifically, you are using the Datadog Agent, so you will want to learn about that.

Configuration for a Datadog Agent Docker Container

The following YAML file defines a docker container that will run the Datadog agent, scrape CloudFlow’s /federate endpoint, and write the results into your Datadog cloud instance.

  • Replace CLOUDFLOW_ACCOUNT_ID with your CloudFlow Account ID, typically of the form 1234.
  • Note that the Bearer TOKEN is not something that you are supposed to replace, just leave it alone.
conf.yaml
init_config:
instances:
- namespace: cloudflow
openmetrics_endpoint: https://console.section.io/prometheus/account/CLOUDFLOW_ACCOUNT_ID/federate
auth_token:
reader:
type: file
path: /etc/datadog-agent/conf.d/openmetrics.d/token
pattern: ^(.+)$
writer:
type: header
name: Authorization
value: "Bearer <TOKEN>"
metrics:
- .+:
type: gauge

The token file should be filled with one line containing your CLOUDFLOW_API_TOKEN. Shown below is an obfuscated CloudFlow API token.

*********************************************************************4c57

The command to run the container above follows. Note the following:

  • You'll need to properly specify the location of the files datadog/openmetrics.d/conf.yaml and datadog/openmetrics.d/token. In the example below they are specified as being in /home/myhome.
  • And be sure to replace DATADOG_API_KEY.
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 \
-v /home/myhome/datadog/openmetrics.d/conf.yaml:/etc/datadog-agent/conf.d/openmetrics.d/conf.yaml \
-v /home/myhome/datadog/openmetrics.d/token:/etc/datadog-agent/conf.d/openmetrics.d/token \
-e DD_API_KEY=DATADOG_API_KEY \
-e DD_SITE="datadoghq.com" \
gcr.io/datadoghq/agent:7

If you are having trouble, try adding debugging to the list of command line arguments.

    -e DD_LOG_LEVEL=debug \

View Metrics in Datadog

Login to your Datadog account in order to see your metrics. Try our sample dashboard to get you started.