3‐ Datadog Agent on Linux Servers - harishgorla5/HINTechnologies_datadog GitHub Wiki

🐧 Install Datadog Agent on Linux Servers

This guide provides step-by-step instructions to install the Datadog Agent on Linux-based servers (Ubuntu, CentOS, RHEL, etc.) and configure it to monitor metrics and logs.


📋 Prerequisites

  • ✅ A valid Datadog API Key
  • ✅ Root or sudo privileges on the Linux server
  • ✅ Outbound internet access to *.datadoghq.com

🖥️ Step 1: Install the Agent

Run the following command to install the Datadog Agent:

For Debian/Ubuntu:

DD_API_KEY=<YOUR_DATADOG_API_KEY> DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)"

For RHEL/CentOS/Fedora/Amazon Linux:

DD_API_KEY=<YOUR_DATADOG_API_KEY> DD_SITE="datadoghq.com" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)"

Replace <YOUR_DATADOG_API_KEY> with your actual key.

Optional: Change the site to datadoghq.eu or us5.datadoghq.com based on your region.


⚙️ Step 2: Agent Configuration

Main config file:
/etc/datadog-agent/datadog.yaml

Edit to customize:

logs_enabled: true
apm_config:
  enabled: true

Restart the agent after making changes:

sudo systemctl restart datadog-agent

🗂️ Step 3: Enable Log Collection

  1. Create a config file for your log source:
    • Example: /etc/datadog-agent/conf.d/myapp.d/conf.yaml
logs:
  - type: file
    path: /var/log/myapp.log
    service: myapp
    source: custom
  1. Make sure the Agent has read access to log files.

  2. Restart the Agent:

sudo systemctl restart datadog-agent

🔍 Step 4: Verify Agent Status

To verify the Agent is running and collecting data:

sudo datadog-agent status

To check logs:

sudo tail -f /var/log/datadog/agent.log

📊 Step 5: View in Datadog

Log in to your Datadog dashboard and go to:

  • Infrastructure → Host Map
  • Logs → Live Tail
  • APM → Services
  • Dashboards → Host Overview

🔒 Optional: Secure Config

  • Store API key in /etc/datadog-agent/datadog.yaml or use environment variables
  • Use role-based access and config file permissions to protect credentials

🧹 Uninstall Datadog Agent

To remove the Agent:

sudo apt-get remove datadog-agent        # Debian/Ubuntu
sudo yum remove datadog-agent            # RHEL/CentOS

Also remove config files:

sudo rm -rf /etc/datadog-agent

📎 Useful Links