Monitoring Docker Containers with Datadog on Ubuntu
The Astronomer
Posted on August 17, 2024
I just started monitoring my docker containers running on Ubuntu server. Just in case it helps someone else too, I wanted to share the steps I followed. I will try to walk you through the process of setting up Datadog to monitor your Docker containers on an Ubuntu server, from signing up for a free trial to configuring the Datadog Agent.
1. Sign Up for a Datadog Free Trial
- Find Datadog Website: Google the link to sign up for free trial and visit the page.
- Sign Up: Click on "Start Free Trial" and fill out the registration form. Follow the prompts to create your brand new account.
- Install Agent: After you are signed up, Datadog will provide you with an installation command specific to your account. This command is used to install the Datadog Agent on your Ubuntu server.
2. Install the Datadog Agent on Ubuntu
Run the Installation Command: Datadog will give you a list of options to get installation steps for different kinds of machines. Since we are doing this on Ubuntu machine, choose Ubuntu from the list. There it shows the command that we need. It also has the API Key in it. Copy and paste the installation command provided by Datadog into your terminal where you are logged on to your ubuntu server.
Verify Installation: After running the command, the Datadog Agent should be installed on your server. You can verify this by checking the service status:
sudo systemctl status datadog-agent
3. Configure Datadog to Monitor Docker Containers
Fun starts now. Datadog should take you to the integration page where you can select and install Docker. Go back to the terminal for now and do step 1 first:
-
Add
dd-agent
User to Docker Group: To allow the Datadog Agent to communicate with Docker, you need to add thedd-agent
user to the Docker group. Run:
sudo usermod -a -G docker dd-agent
After running this command, you may need to log out and log back in for the group changes to take effect. I didn't have to do that.
-
Enable Docker Integration in Datadog:
- Back to Datadog website: Go to the Datadog Integrations page.
- Search for docker if not already shown to you: Locate the Docker integration and click "Install". Btw, this will also show you the steps there but I found it really confusing (like I didn't really know where this conf.d folder was located). Hence, I decided to write this article as it might be helpful for others.
-
Configure Docker Integration:
-
Edit Configuration File:
Open the configuration file for Docker integration. If you go to
/etc/datadog-agent/conf.d/docker.d/
on your machine, you may not see the yaml file there. This command will create a new one for you.:
sudo nano /etc/datadog-agent/conf.d/docker.d/docker_daemon.yaml
-
Edit Configuration File:
Open the configuration file for Docker integration. If you go to
-
Add Configuration:
Add the following configuration to the file:
init_config: instances: - url: "unix://var/run/docker.sock"
This configuration sets the Datadog Agent to connect to the Docker daemon via the Docker socket.
Save and Exit: In
nano
, save changes by pressingCTRL + O
, thenEnter
, and exit withCTRL + X
. If you have never used nano before, you can find how to use it by quick Googling. You just need 1 or 2 commands for this though. No need to learn everything.
-
Restart the Datadog Agent:
To apply the changes, restart the Datadog Agent service:- Stop the Agent: Stop command:
sudo systemctl stop datadog-agent
-
Start the Agent:
To start the Datadog Agent again, use:
sudo systemctl start datadog-agent
-
Verify Integration:
Check the status of the Datadog Agent to ensure that the Docker integration is working correctly:
sudo datadog-agent status
Look for the docker
section under Checks
to confirm that Docker monitoring is active. Then just go to the dashboard on Datadog website to see the metrics.
Conclusion
By following these steps, you can effectively monitor your Docker containers with Datadog on an Ubuntu server. This setup allows you to gain deep insights into your containerized applications. Now you can quickly respond to any performance issues or anomalies.
Posted on August 17, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 30, 2024
November 30, 2024