How to Install Datadog Agent with Apache2 on EC2 Ubuntu 22.04

In this blog, we’ll show you a simple way to use Datadog for monitoring an Apache2 web server. Are you using an Ubuntu 22.04 EC2 instance? Perfect! We’ve got step-by-step instructions ready for you. Our goal is to make it easy to understand, so you can get Datadog up and running quickly. Let’s get started!


Step 1: Install the Datadog Agent 7

SSH into your EC2 instance:

ssh username@your_ec2_ip

Update your package lists:

sudo apt-get update

Install or update the Datadog Agent 7 using the following command:


You should provide your Datadog API key in place of “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX” in the command. This key is necessary for authentication and access to Datadog’s services.

Step 2: Enable Apache2 Status Module

Assuming the Apache2 is already installed, to enable mod_status for Apache2 use the following command:

sudo a2enmod status

Edit the Apache2 configuration to allow status reports:

sudo nano /etc/apache2/mods-enabled/status.conf

Ensure to enable the following block to the configuration file:

<Location "/server-status">
    SetHandler server-status
    Require local
ExtendedStatus On

Reload Apache2 for the changes to take effect:

sudo systemctl reload apache2

Step 3: Configure the Datadog Agent

Navigate to the Apache integration config directory:

cd /etc/datadog-agent/conf.d/apache.d/

Rename the existing configuration file:

sudo mv conf.yaml.example conf.yaml

Edit the configuration file:

sudo nano conf.yaml

Ensure the instances section is properly configured:

  - apache_status_url: http://localhost/server-status?auto

Configure the logs collection:

  - type: file
    path: /var/log/apache2/access.log
    service: apache
    source: apache

  - type: file
    path: /var/log/apache2/error.log
    service: apache
    source: apache

To exit nano (text-editor) and save, press Ctrl + X, then Y, and Enter.

Step 4: Set Up Datadog API Key

Navigate to the Datadog Agent configuration directory:


Open the datadog.yaml file to review the configuration:

sudo nano /etc/datadog-agent/datadog.yaml

Ensure your API key is properly configured and log collection is enabled, as shown below:

api_key: your_datadog_api_key
logs_enabled: true

Adjust permissions for the Apache2 logs:

sudo chmod 755 -R /var/log/apache2/

Restart the Datadog Agent:

sudo systemctl restart datadog-agent
sudo systemctl status datadog-agent

Step 5: Configure Datadog Integration on the Console

Log in to the Datadog console and navigate to Integrations. Find and install the Apache integration. Then, configure it as needed and click install configuration:

How to Install Datadog with Apache2 Web Server on EC2 Ubuntu 22.04

Your Apache metrics should start appearing on the dashboard shortly, as shown below:

How to Install Datadog with Apache2 Web Server on EC2 Ubuntu 22.04


You’ve successfully installed Datadog on your EC2 instance with Ubuntu 22.04 and configured it to monitor your Apache2 web server. Give it a few minutes, then check your Datadog dashboard to see your server’s metrics.

Feel free to add additional monitoring features and set up alerts according to your needs. If you encounter any issues, refer to Datadog’s documentation or reach out to their support team.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.