Datadog

Datadog is a full monitoring platform; it supports various servers, platforms, and applications. Wikipedia describes the service as:

"Datadog is a SaaS-based monitoring and analytics platform for IT infrastructure, operations and development teams. It brings together data from servers, databases, applications, tools and services to present a unified view of the applications that run at scale in the cloud."

It uses an agent that is installed on your host machine; this agent sends metrics back to the Datadog service periodically. It also support multiple cloud platforms, such as Amazon Web Services, Microsoft Azure, and OpenStack to name a few.

The aim is to bring all of your servers, applications, and host provider metrics into a single pane of glass; from here, you can create custom dashboards and alerts so that you can be notified of any problem at any level within your infrastructure.

You can sign up for a free trial of the full service at https://app.datadoghq.com/signup. You will need at least a trial account to configure the altering, and if your trial has already expired the lite account will do. For more detail on Datadog's pricing structure, please see https://www.datadoghq.com/pricing/.

Installing the agent

The agent can be installed either directly on the host machine or as a container. To install directly on the host machine, run the following command and make sure that you use your own unique DD_API_KEY:

DD_API_KEY=wn5AYlhjRhgn3shcjW14y3yOT09WsF7d bash -c "$(curl -L https://raw.githubusercontent.com/DataDog/dd-agent/master/packaging/datadog-agent/source/install_agent.sh)"

To run the agent as a container, use the following command and again make sure that you use your own DD_API_KEY:

sudo docker run -d --name dd-agent -h `hostname` -v /var/run/docker.sock:/var/run/docker.sock -v /proc/mounts:/host/proc/mounts:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e API_KEY=wn5AYlhjRhgn3shcjW14y3yOT09WsF7d datadog/docker-dd-agent

Once the agent has been installed, it will call back to Datadog and the host will appear in your account.

If the agent has been installed directly on the host machine then we will need to enable the Docker integration, if you installed the agent using the container then this will have been done for you automatically.

To do this, you first need to allow the Datadog agent access to your Docker installation by adding the dd-agent user to the Docker group by running the following command:

usermod -a -G docker dd-agent

The next step is to create the docker.yaml configuration file, luckily the Datadog agent ships with an example configuration file that we can use; copy this in place and then restart the agent:

cp -pr /etc/dd-agent/conf.d/docker.yaml.example /etc/dd-agent/conf.d/docker.yaml
sudo /etc/init.d/datadog-agent restart

Now the agent on our host machine has been configured and the final step is to enable the integration through the website. To do this, go to https://app.datadoghq.com/ and click on Integrations, scroll down and then click on install on Docker:

Installing the agent

Once you click install, you will be presented with an overview of the integration, click on the Configuration tab, this gives instructions on how to configure the agent; as we have already done this step, you can click on Install Integration.

You can find more information on installing the agent and the integrations at the following URLs:

Exploring the web interface

Now, you have installed the agent and enabled the Docker integration, you can start to have a look around the web interface. To find your host, click on "Infrastructure" in the left-hand side menu.

You should be taken to a screen that contains a map of your infrastructure. Like me, you probably only have a single host machine listed, click on it and some basic stats should appear at the bottom of the screen:

Exploring the web interface

If you don't already have the containers launched, now would be a good time to do so, lets launch the WordPress installation again using:

sudo su -
mkdir ~/wordpress
curl -L https://raw.githubusercontent.com/russmckendrick/monitoring-docker/master/chapter05/wordpress/docker-compose.yml > ~/wordpress/docker-compose.yml
cd ~/wordpress
docker-compose up -d

Now, go back to the web interface, from there you can click on any of the services listed on the hexagon. This will bring up some basic metrics for the service you have selected. If you click on docker, you will see a link for a Docker Dashboard among the various graphs and so on; clicking this will take you to a more detailed view of your containers:

Exploring the web interface

As you can see, this gives us our now familiar break down of the CPU and memory metrics, along with in the top right of the dashboard a breakdown of the container activity on the host machine; this logs events, such as stopping and starting containers.

Datadog currently records the following metrics:

  • docker.containers.running
  • docker.containers.stopped
  • docker.cpu.system
  • docker.cpu.user
  • docker.images.available
  • docker.images.intermediate
  • docker.mem.cache
  • docker.mem.rss
  • docker.mem.swap

From the Metrics explorer option in the left-hand side menu, you can start to graph these metrics and once you have the graphs, you can then start to add them to your own custom dashboards or even annotate them. When you annotate a graph, a snapshot is created and the graph shows up in the events queue along with the other events, that have been recorded, such as container stopping and starting:

Exploring the web interface

Also, within the web interface you can configure monitors; these allow you to define triggers, which alert you if your conditions are not met. Alerts can be sent as e-mails or via third party services, such as Slack, Campfire, or PagerDuty.

Summary and further reading

While Datadog's Docker integration only gives you the basic metrics on your containers, it does have a wealth of features and integration with other applications and third parties. If you need to monitor a number of different services alongside your Docker containers, then this service could be for you:

Tip

Please Remember

If you have launched a cloud instance and are no longer using it then now would be a good time to power the instance down or terminate it altogether. This will ensure that you do not get billed for any services you are not using.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset