2026年11月14日

2026年11月14日

Monitor a Linux Server with Datadog: Agent 7, MySQL, Logs, Alerts

This article is a localized edition of the Japanese original. Read the Japanese original

Datadog is a cloud monitoring service that collects the state of servers and applications and turns it into graphs and alert notifications. When you install a program called the Datadog Agent on a server, values (metrics) such as CPU, memory, disk and network are sent to Datadog.

This article covers installing Agent 7 on a Linux server such as Ubuntu, then setting up basic monitoring, MySQL monitoring, log collection and alerts. Commands and file locations were checked as of November 2026 against the official Datadog documentation and the official install script (version 1.48.0).

Before you start: account and site

Pricing at a glance

As of November 2026, the official pricing page lists these Infrastructure Monitoring plans (prices are per host per month, in US dollars).

Plan Details
Free Free for up to 5 hosts. Metrics are kept for 1 day
Pro $15 billed annually, $18 on demand
Enterprise $23 billed annually, $27 on demand

Log Management and APM are billed separately. Check the latest terms on Datadog's pricing page.

Datadog sites (regions)

Datadog stores data in separate "sites," and you choose one when you create your account. The Agent must be pointed at the same site, or your data will not arrive.

Site Web app URL Value to set (DD_SITE)
US1 https://app.datadoghq.com datadoghq.com
US3 https://us3.datadoghq.com us3.datadoghq.com
US5 https://us5.datadoghq.com us5.datadoghq.com
EU1 https://app.datadoghq.eu datadoghq.eu
AP1 (Japan) https://ap1.datadoghq.com ap1.datadoghq.com
AP2 (Australia) https://ap2.datadoghq.com ap2.datadoghq.com

You can tell your site from the URL in your browser after you log in.

API key

The Agent identifies your account by its API key. You can view and create keys under "API Keys" in Organization Settings. Anyone who learns your API key can push data into your account, so do not paste it into Git repositories or chats.

Step 1: Install the Agent

When you pick a platform in Fleet Automation (the Agent install screen) in the web app, it shows a command with your API key and site filled in. In most cases you simply copy and run it. It looks like this:

DD_API_KEY="YOUR_API_KEY" DD_SITE="ap1.datadoghq.com" bash -c "$(curl -L https://install.datadoghq.com/scripts/install_script_agent7.sh)"

Replace DD_SITE with your own site's value (if omitted, it defaults to datadoghq.com, which is US1). The script registers Datadog's package repository, installs the datadog-agent package, writes the API key and site into the configuration file, and starts the Agent.

URLs such as https://datadoghq.com/install.sh and configuration files under /etc/dd-agent/, which appear in older articles, either date from the Agent 5 era or never existed, and are not used with today's Agent 7.

Step 2: Confirm it is running

sudo systemctl status datadog-agent
sudo datadog-agent status

datadog-agent status shows the Agent version, whether the API key is valid, which checks (units of collection) are running, and whether any sends have failed. If cpu, disk, load, memory and so on appear under "Checks" with no errors, collection is working.

After a few minutes, confirm that the server appears in Infrastructure (the host list) in the web app. You can also search for datadog.agent.running in the metrics explorer.

Task Command
Start, stop, restart sudo systemctl start datadog-agent / stop / restart
Detailed status sudo datadog-agent status
List loaded configurations sudo datadog-agent configcheck
Run a single check as a test sudo datadog-agent check check-name (for example sudo datadog-agent check mysql)
Log location /var/log/datadog/ (the main Agent log is agent.log)

Configuration file locations

Location Contents
/etc/datadog-agent/datadog.yaml Agent-wide settings (API key, site, hostname, tags, whether to collect logs, and so on)
/etc/datadog-agent/datadog.yaml.example A sample with every setting documented
/etc/datadog-agent/conf.d/integration-name.d/conf.yaml Per-integration settings. A conf.yaml.example sits in the same place

After changing settings, apply them with sudo systemctl restart datadog-agent.

Step 3: Organize hosts with tags

As the number of servers grows, adding tags in datadog.yaml lets you filter graphs and alerts by environment or role.

# Append to /etc/datadog-agent/datadog.yaml
tags:
  - env:production
  - role:web

You can also pass them at install time with DD_TAGS="env:production,role:web".

Step 4: Monitor MySQL

To collect MySQL connection counts, query counts, InnoDB status and more, configure the MySQL integration. It is built into the Agent, so nothing extra needs to be installed.

First, create a MySQL user for monitoring (MySQL 8.0 example, following the official documentation).

CREATE USER 'datadog'@'%' IDENTIFIED BY 'monitoring-password';
ALTER USER 'datadog'@'%' WITH MAX_USER_CONNECTIONS 5;
GRANT REPLICATION CLIENT ON *.* TO 'datadog'@'%';
GRANT PROCESS ON *.* TO 'datadog'@'%';
-- To collect additional metrics
GRANT SELECT ON performance_schema.* TO 'datadog'@'%';

If the Agent only connects to MySQL on the same server, you can narrow the source by changing '%' to 'localhost' (in that case, change 'datadog'@'%' to 'datadog'@'localhost' in every statement).

Next, create the configuration file.

sudo cp /etc/datadog-agent/conf.d/mysql.d/conf.yaml.example /etc/datadog-agent/conf.d/mysql.d/conf.yaml
sudo nano /etc/datadog-agent/conf.d/mysql.d/conf.yaml
init_config:

instances:
  - host: 127.0.0.1
    username: datadog
    password: "monitoring-password"
    port: 3306

The official documentation says to use 127.0.0.1 rather than localhost. Wrap the password in quotes if it contains symbols. Because this file holds a password, give it the same owner and permissions as the sample file (readable by dd-agent) and keep it unreadable by other users.

sudo chown dd-agent:dd-agent /etc/datadog-agent/conf.d/mysql.d/conf.yaml
sudo chmod 640 /etc/datadog-agent/conf.d/mysql.d/conf.yaml
sudo systemctl restart datadog-agent
sudo datadog-agent check mysql

If mysql appears under "Checks" in datadog-agent status with no errors, the setup is complete.

Step 5: Collect logs (if needed)

Log collection is disabled by default. To use it, enable it in datadog.yaml (Log Management is billed separately).

# /etc/datadog-agent/datadog.yaml
logs_enabled: true

The files to collect are listed in per-integration configuration files. For your own application's log, for example:

sudo mkdir -p /etc/datadog-agent/conf.d/myapp.d
sudo nano /etc/datadog-agent/conf.d/myapp.d/conf.yaml
logs:
  - type: file
    path: "/var/log/myapp/app.log"
    service: "myapp"
    source: "myapp"

The Agent runs as the dd-agent user, so it cannot collect a log file that dd-agent cannot read. Check with sudo -u dd-agent cat /var/log/myapp/app.log, and if it fails, adjust the group or permissions. After configuring, restart the Agent and check the "Logs Agent" section of datadog-agent status.

Step 6: Create alerts (monitors)

Beyond watching graphs, set up notifications when a threshold is crossed. Create a new monitor from Monitors in the web app, choose the Metric type, and specify the metric and threshold.

What to watch Example metric Notes
CPU load system.load.1 1-minute load average. Base the threshold on the number of CPU cores
CPU usage system.cpu.user, system.cpu.system Percent
Disk usage system.disk.in_use A fraction from 0 to 1 (0.9 means 90%)
Free memory system.mem.pct_usable Fraction of usable memory (0 to 1)
Agent stopped datadog.agent.running Configure it to notify you when data from the host stops arriving

Set the notification target in the monitor's message field, using an email address or a connected chat tool. Start with a small number of monitors, and if you get many false alarms, adjust the thresholds or the evaluation window.

Operational tips

  • Keep the Agent updated: it is installed as a package, so sudo apt update && sudo apt upgrade updates it.
  • Manage API keys: revoke keys you no longer use. Using separate keys per server or per team limits the damage if one leaks.
  • Host count and cost: billing is mainly per host. Do not leave the Agent on servers you were only testing, and uninstall it with sudo apt-get remove --purge datadog-agent when you remove it.

For monitoring a WordPress site with Datadog, see Monitoring a WordPress site with Datadog. If you want to trace application processing time as well, see How to set up APM monitoring with New Relic.

Summary

  • Install Agent 7 with the command shown in the web app (install_script_agent7.sh), and set DD_SITE to your site (for Japan, ap1.datadoghq.com and so on).
  • Check status with sudo datadog-agent status, and write settings in /etc/datadog-agent/datadog.yaml and conf.d/integration-name.d/conf.yaml.
  • Collect MySQL data with a monitoring user and mysql.d/conf.yaml, collect logs with logs_enabled: true plus per-integration logs: entries, and set monitors on the key metrics.

Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)

お気軽にご相談ください

お見積りへ お問い合わせへ
▲