How I Added Datadog Monitoring to My AWS EC2 Servers

I was managing three servers — two production web servers and one bastion server — without proper server-level monitoring.

I had no CPU dashboard, no memory visibility, and no reliable way to know when something was going wrong with a server until a user reported it.

Then I experienced a 502 Bad Gateway error at around 2am on one of my web servers.

That incident made me realize that simply having access to my EC2 instances wasn't enough. I needed proper monitoring so I could see the health of my servers and receive alerts before a problem became a user-facing issue.

I decided to integrate Datadog into my AWS environment.

After installing the Datadog Agent on my three Ubuntu servers, I was able to see them from one dashboard and monitor metrics such as CPU usage and host health.

Here is how I set it up.

Prerequisites

You will need:

  1. A Datadog account. The free trial is enough for a lab environment.

  2. An Ubuntu 20.04/22.04 EC2 instance or another supported Linux server.

  3. Your Datadog API key and Datadog site.

To get your API key, go to:

Datadog → Organization Settings → API Keys

Copy your API key and note your Datadog site.

My account uses:

us5.datadoghq.com

Your account may use another Datadog site, such as us1 or eu1.


Step 1: Install the Datadog Agent

First, SSH into the EC2 server:

ssh ubuntu@your-server-ip

Then run the Datadog Agent installation command.

Replace YOUR_DD_API_KEY with your actual Datadog API key and use the Datadog site associated with your account.

DD_API_KEY=YOUR_DD_API_KEY DD_SITE=us5.datadoghq.com bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script_agent7.sh)"

The installer downloads and installs Datadog Agent 7 and registers the server with your Datadog account.

I repeated the installation on all three servers in my environment:

  • WebServer-1

  • WebServer-2

  • Bastion-Server-01



Step 2: Verify That the Agent Is Running

After installation, I checked the Agent status:

sudo datadog-agent status

This provides information about the Agent and its connection to Datadog.

I also checked the Linux service:

sudo systemctl status datadog-agent

The expected result is:

active (running)

If the Agent is running but the host does not appear in Datadog, one of the first things to check is the Datadog site configuration.

You can check it with:

cat /etc/datadog-agent/datadog.yaml | grep site

Make sure the configured site matches your Datadog account.

For example:

site: us5.datadoghq.com

Using the wrong Datadog site can prevent the Agent from reporting correctly to your account.


Step 3: Check the Hosts Dashboard

Once the Agent started reporting, I went to:

Datadog → Infrastructure → Hosts

My three servers appeared in the Hosts dashboard.

I could now see information such as:

  • Host name

  • CPU usage

  • Host status

  • Environment information

  • AWS/EC2 information

  • Configured monitors

My environment contained:

  • WebServer-1 — production

  • WebServer-2 — production

  • Bastion-Server-01 — development/administration

This was a major improvement compared with manually checking individual servers.

Instead of connecting to each EC2 instance separately, I could start from one monitoring dashboard.


fig-1



Step 4: Organizing Hosts With Environment Tags

Because I had both production and non-production infrastructure, I wanted to be able to distinguish them easily.

I used environment information such as:

env:prod

for my production web servers and:

env:dev

for the bastion server.

This makes it easier to filter hosts and avoid confusing development or administrative infrastructure with production systems.

Datadog also allows hosts to be grouped and filtered using attributes and tags.

For example, I can focus on production infrastructure rather than looking at every server at once.


Step 5: What I Can Monitor Now

After integrating the Datadog Agent, I gained much better visibility into my servers.

CPU Usage

I can see the CPU usage of each host and identify unusual spikes.

This is useful when a web application starts consuming excessive resources or when a server is under unexpected load.

Host Health

Instead of waiting for a user to tell me something is wrong, I can monitor the health of my infrastructure from the Datadog dashboard.

Environment

Using environment tags makes it easier to distinguish production servers from other infrastructure.

AWS/EC2 Information

The Datadog dashboard also identifies my AWS infrastructure, making it easier to understand which monitored hosts belong to my EC2 environment.


Step 6: Adding Alerts

Monitoring becomes much more useful when it can notify you about a problem.

For example, I configured a CPU alert so that I can be notified when CPU utilization remains above a defined threshold.

One of the conditions I used was:

CPU usage > 85% for 5 minutes

The idea is simple:

Normal CPU usage
       ↓
CPU starts increasing
       ↓
CPU remains above threshold
       ↓
Datadog detects the condition
       ↓
Alert/notification is triggered
       ↓
I investigate before the problem becomes worse

Depending on the notification channels configured, alerts can be sent through options such as email or Slack.

This gives me an opportunity to investigate a problem before it becomes a complete service outage.


Common Problems I Encountered

1. Host Does Not Appear After Installation

One of the first things to check is the Datadog site.

For example:

cat /etc/datadog-agent/datadog.yaml | grep site

Make sure the site matches the site shown in your Datadog account.

Also verify that the Agent is running:

sudo systemctl status datadog-agent

2. Permission Problems When Collecting Logs

If you configure log collection and encounter permission problems, the dd-agent user may need access to the appropriate log files.

For example:

sudo usermod -a -G adm dd-agent

After changing group permissions, restart the Agent:

sudo systemctl restart datadog-agent

The exact permissions required will depend on which logs you are collecting.


3. Datadog Agent Consuming More Resources Than Expected

Monitoring software also consumes some resources.

If the Agent is using more resources than expected, check which integrations and features you have enabled.

You can review the Agent configuration at:

/etc/datadog-agent/datadog.yaml

and disable unnecessary integrations or features rather than collecting data that you don't need.


What Changed After Adding Monitoring?

Before this setup, my approach was mostly reactive.

Something would go wrong, and I would discover it by checking the server or, worse, after a user reported a problem.

After integrating Datadog, I have a central place where I can see my EC2 hosts and monitor their resource usage.

The biggest lesson for me was that running a server is not the same thing as monitoring a server.

You need visibility into what is happening inside your infrastructure.

For my three-server environment, adding Datadog gave me a much better starting point for that visibility.

It also gives me room to expand my monitoring later with additional metrics, logs, application monitoring, and more detailed alerts.

Final Thoughts

The 2am 502 error was the reason I finally took monitoring seriously.

I don't want to wait for another client complaint before discovering that a production server has a problem.

Now, instead of manually checking servers one by one, I can start from a single dashboard and investigate what is happening across my infrastructure.

If you are running multiple EC2 instances and still rely entirely on manually checking top, systemctl, or individual server logs, adding a monitoring solution is a worthwhile next step.

For me, this was another small but important step toward managing infrastructure more proactively.


Read Also

How I Helped Shift Twinset Industries Ltd From Localhost to HTTPS

https://blog.sirvickcloud9.online/2026/10/how-we-built-and-shipped-twinset.html

Building My Netflix Clone From Aba

https://blog.sirvickcloud9.online/2026/10/building-my-netflix-clone-from-aba.html

Comments

Popular posts from this blog

How I Fixed GitHub Error: failed to push some refs to github.com in 2026

How I Deployed Netflix Clone (NGold) to AWS EC2 - Live at 32.196.145.76:3000 [Docker + Nginx Guide]

Understanding Linux Environment — The Real Engine Behind My AWS Cloud Deployment