Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 37 ยท Agent and Integrations

Installing the Datadog Agent on Linux, Windows, Docker and Kubernetes

Install the Datadog Agent in every common way: package manager, Windows MSI, a Docker container, Helm on Kubernetes, and configuration management such as Ansible and Terraform.

Your first host used the one-line script. Real environments are more varied: Windows servers, container hosts, Kubernetes clusters, and fleets installed by tools. This lesson shows each installation method, what is different about it, and how to choose. All commands are real Datadog installation patterns, shown read-only here; the TryIt stand-ins generate and validate them.

Always take the exact command from Integrations > Agent in your account when you install. It includes your key and site, and flags change between versions.

Linux

Package manager (recommended for servers). The install script sets up Datadog's APT or YUM repository and installs datadog-agent. Because it uses a repository, apt-get upgrade keeps it current. To install manually, add the repository and signing key from the docs, then:

Terminal
sudo apt-get update && sudo apt-get install datadog-agent   # Debian/Ubuntu
sudo yum install datadog-agent                              # RHEL/CentOS/Amazon Linux

Configure /etc/datadog-agent/datadog.yaml (add api_key and site), then sudo systemctl restart datadog-agent.

Windows

Download the MSI from the Agent page and install it interactively, or silently with msiexec:

POWERSHELL
Start-Process -Wait msiexec -ArgumentList '/qn /i datadog-agent-7-latest.amd64.msi APIKEY="<YOUR_API_KEY>" SITE="datadoghq.com"'

The Agent installs as the DatadogAgent service, config lives in C:\ProgramData\Datadog\datadog.yaml, and the GUI Datadog Agent Manager shows status. Windows adds Windows-specific checks: performance counters, event logs, IIS, and Active Directory integrations are configured the same conf.d way. The service runs as the ddagentuser account, which needs rights for protected counters or logs.

macOS

The Agent installs as a DMG or a one-line script for laptops and build machines. It is meant for development and CI runners rather than production servers.

Docker

Run the Agent as a container on a Docker host. It reads container data through the Docker socket:

Terminal
docker run -d --name datadog-agent \
  -e DD_API_KEY=<YOUR_API_KEY> \
  -e DD_SITE="datadoghq.com" \
  -e DD_LOGS_ENABLED=true \
  -e DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true \
  -e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -v /proc/:/host/proc/:ro \
  -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
  -v /var/lib/docker/containers:/var/lib/docker/containers:ro \
  gcr.io/datadoghq/agent:7

Every datadog.yaml setting has an environment variable form: prefix DD_ and use the upper-case name (logs_enabled becomes DD_LOGS_ENABLED). Mounting the Docker socket gives the Agent power over your host's containers, so treat it as privileged and keep the mount read-only.

Kubernetes

On Kubernetes the Agent runs as a DaemonSet: one Agent pod per node, so it sees that node's containers and the kubelet. The easiest route is the official Helm chart:

Terminal
helm repo add datadog https://helm.datadoghq.com
helm repo update
kubectl create secret generic datadog-secret --from-literal api-key=<YOUR_API_KEY>
helm install datadog-agent datadog/datadog -f values.yaml

with a values.yaml such as:

YAML
datadog:
  apiKeyExistingSecret: datadog-secret
  site: datadoghq.com
  logs:
    enabled: true
    containerCollectAll: true
  apm:
    portEnabled: true
  tags:
    - "env:prod"
clusterAgent:
  enabled: true

The Cluster Agent is a separate deployment that talks to the Kubernetes API once on behalf of all nodes, reducing API load and enabling cluster-level checks and autoscaling on Datadog metrics. A Datadog Operator is an alternative to Helm. Containers are covered fully in containers and Kubernetes.

Configuration management and cloud images

For fleets, do not install by hand:

  • Ansible has an official datadog.datadog role, Chef, Puppet and Salt have modules, and Terraform can install through user data and configure the Datadog provider for monitors and dashboards.
  • Cloud images: bake the Agent into an AMI or image without a host-specific key or hostname, and inject DD_API_KEY at boot from a secrets manager.
  • Serverless: for AWS Lambda you add the Datadog Lambda extension layer rather than an Agent; ECS uses an Agent sidecar or daemon task.
Python Stand-in: build an install command for each platform

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python Stand-in: turn datadog.yaml keys into environment variables

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The nested key conversion in the stand-in matches the rule for most settings (dots become underscores), but a few settings have special names, so check the documentation before relying on a guess.

Choosing a method

Situation Method
A few servers, learning One-line script
Many Linux servers Ansible/Chef/Puppet/Salt role
Windows servers MSI, silent install, or config management
Docker host Agent container
Kubernetes Helm chart or Operator (DaemonSet + Cluster Agent)
AWS Lambda / ECS Fargate Lambda extension / sidecar

Whatever you choose, pin the Agent version in production and upgrade in stages: canary hosts first, then the rest.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How does the Agent run on Kubernetes?

    A DaemonSet places an Agent pod on every node to see that node's containers.
  2. 2. How do you set logs_enabled in a container?

    Settings map to environment variables with a DD_ prefix and upper-case names.
  3. 3. What is the Cluster Agent for?

    It reduces API server load and provides cluster-level checks and metadata.
  4. 4. Why should a golden machine image not contain your API key?

    Inject secrets at runtime so they are not baked into reusable images.

Summary

  • Linux uses packages or the install script; Windows uses the MSI; macOS is for development.
  • Docker runs the Agent as a container with the socket and host folders mounted read-only.
  • Kubernetes uses a DaemonSet plus the Cluster Agent, usually via Helm or the Operator.
  • Fleets use Ansible/Chef/Puppet/Terraform; inject keys at runtime and pin versions.

Next: Configuring the Agent: datadog.yaml