Nginx For Beginners
Performance
Demo Monitoring
In this lesson, you’ll learn how to install the Datadog Agent on an AWS EC2 Ubuntu/Debian instance to collect critical system metrics (CPU, memory, disk I/O, network, etc.) and then configure the Nginx integration for deep visibility into your web server’s performance.
Below is a quick reference of the main metric categories the Datadog Agent collects:
Metric Category | Key Metrics |
---|---|
CPU | system.cpu.user, system.cpu.idle, system.cpu.system |
Memory | system.mem.used, system.mem.free, system.mem.cached |
Disk I/O | system.io.read_time, system.io.write_time |
Network | system.net.bytes_sent, system.net.bytes_rcvd |
1. Install the Datadog Agent
Follow these steps to get the Agent up and running:
Sign up for a Datadog trial (14-day free) and skip optional steps until you reach the Agent installer.
Select Ubuntu/Debian as your platform.
Copy and run the installer command, replacing
<YOUR_API_KEY>
with your API key:DD_API_KEY="<YOUR_API_KEY>" DD_SITE="datadoghq.eu" \ bash -c "$(curl -L https://install.datadoghq.eu/scripts/install_script_agent7.sh)"
Note
If you’re in the US region, set
DD_SITE="datadoghq.com"
. For other regions, refer to Datadog Sites.Watch the installer fetch and set up packages:
gpg: imported: 1 Get:1 https://apt.datadoghq.com stable Release [26.0 kB] Get:2 https://apt.datadoghq.com stable/7 amd64 Packages [92.1 kB] Fetched 120 kB in 0s (651 kB/s) Reading package lists... Installing package(s): datadog-agent datadog-signing-keys ... Unpacking datadog-agent (1:7.62.3-1) ... Setting up datadog-agent (1:7.62.3-1) ... Starting Datadog Agent
Verify the Agent status:
sudo datadog-agent status
In the Datadog UI, click Finish, then after ~2 minutes navigate to Dashboards → Hosts to confirm your host is reporting.
You can also drill into disk I/O analytics:
2. Configure the Nginx Integration
Once the Agent is collecting system metrics, enable the Nginx integration to capture request rates, active connections, and more.
In the Datadog UI, go to Integrations → Integrations, search for Nginx, then click Configure.
Ensure the
http_stub_status_module
is compiled into your Nginx binary:nginx -V 2>&1 | grep -o http_stub_status_module
Warning
Exposing the stub status endpoint to the public internet is a security risk. Restrict access to
localhost
or your private network.Update your site configuration to expose the status endpoint on
localhost:80
. For example, in/etc/nginx/sites-available/example.conf
:server { listen 80; server_name localhost; access_log off; allow 127.0.0.1; deny all; location /nginx_status { stub_status; server_tokens on; } }
Reload Nginx and verify the endpoint:
sudo nginx -t sudo nginx -s reload curl http://127.0.0.1/nginx_status
Expected response:
Active connections: 1 server accepts handled requests 11 11 15 Reading: 0 Writing: 1 Waiting: 0
Back in Datadog, under Nginx Integration → Configuration, set:
- Host: your EC2 instance
- Endpoint:
http://localhost/nginx_status
After a few minutes, open the built-in Nginx Metrics dashboard to visualize traffic, latency, error rates, and more:
For per-host details, use the Host Map:
Next Steps
With system-level metrics and Nginx integration in place, you can:
- Configure Datadog Alerts on key thresholds (e.g., high request latency).
- Build custom dashboards for error rates and traffic patterns.
- Apply APM for detailed request tracing.
Links and References
Watch Video
Watch video content