Datadog Agent

[!tldr] 한줄 요약 Datadog Agent는 호스트에 설치되어 메트릭, 로그, 트레이스를 수집하고 Datadog 백엔드로 전송하는 경량 소프트웨어로, Collector·DogStatsD·Forwarder·APM Agent·Process Agent로 구성된다.

핵심 내용

Datadog Agent란?

호스트에 설치되어 메트릭, 로그, 트레이스를 수집하고 Datadog 서버로 전송하는 경량 소프트웨어. Datadog의 모든 데이터 수집은 Agent에서 시작된다.

아키텍처 (Agent 7 기준)

┌─────────────────────────────────────────┐
│              Datadog Agent              │
│                                         │
│  ┌───────────┐  ┌──────────────────┐    │
│  │ Collector  │  │   DogStatsD      │    │
│  │ (Checks)  │  │  (UDP :8125)     │    │
│  └─────┬─────┘  └────────┬─────────┘    │
│        │                 │              │
│        ▼                 ▼              │
│  ┌─────────────────────────────────┐    │
│  │         Forwarder               │    │
│  │   (HTTPS → Datadog Backend)     │    │
│  └─────────────────────────────────┘    │
│                                         │
│  ┌──────────────┐  ┌───────────────┐    │
│  │  APM Agent   │  │ Process Agent │    │
│  │ (트레이스)    │  │ (프로세스 정보) │    │
│  └──────────────┘  └───────────────┘    │
└─────────────────────────────────────────┘
graph TB
    subgraph Agent["Datadog Agent"]
        Collector["Collector<br/>(Checks)"]
        DogStatsD["DogStatsD<br/>(UDP :8125)"]
        APM["APM Agent<br/>(트레이스)"]
        Process["Process Agent<br/>(프로세스 정보)"]
        Forwarder["Forwarder"]
    end

    Host["호스트 메트릭<br/>(CPU, 메모리, 디스크)"]
    Integrations["통합(Integration)<br/>(MySQL, Redis, etc.)"]
    AppMetrics["애플리케이션<br/>커스텀 메트릭"]
    Traces["애플리케이션<br/>트레이스"]
    ProcessInfo["프로세스/컨테이너<br/>정보"]
    Backend["Datadog 백엔드"]

    Host --> Collector
    Integrations --> Collector
    AppMetrics --> DogStatsD
    Traces --> APM
    ProcessInfo --> Process

    Collector --> Forwarder
    DogStatsD --> Forwarder
    APM --> Forwarder
    Process --> Forwarder

    Forwarder -->|HTTPS| Backend

Collector (수집기)

DogStatsD

Forwarder (전송기)

APM Agent

Process Agent

설정 파일

핵심 설정 파일은 datadog.yaml:

# 기본 설정
api_key: <YOUR_API_KEY>        # 필수: Datadog API 키
site: datadoghq.com            # Datadog 사이트 (US/EU)

# 태깅
tags:
  - env:production
  - service:web-api
  - team:backend

# 로그 수집 활성화
logs_enabled: true

# APM 활성화
apm_config:
  enabled: true

# DogStatsD
dogstatsd:
  port: 8125

Kubernetes 환경에서의 배포

방법설명권장
Datadog OperatorCRD 기반 선언적 관리프로덕션 권장
Helm ChartHelm으로 한 번에 설치빠른 시작에 적합
DaemonSet 직접 작성YAML 매니페스트로 수동 관리세밀한 제어 필요 시

모든 방식 공통: DaemonSet으로 배포하여 클러스터의 모든 노드에 Agent 1개씩 배치한다.

[!tip] Cluster Agent 추가로 Cluster Agent를 Deployment로 배포하면 Kubernetes API 서버 부하를 줄일 수 있다. Node Agent가 직접 API 서버에 질의하지 않고 Cluster Agent를 통해 클러스터 수준 메타데이터를 받는다.

Agent vs Agentless

Agent 방식Agentless (API 직접)
데이터 수집호스트에서 직접 수집클라우드 API로 수집
실시간성높음 (15초 간격)낮음 (API 폴링 주기)
커스텀 메트릭DogStatsD로 가능불가
트레이싱APM Agent로 가능불가
사용 사례VM, 컨테이너, K8sAWS CloudWatch 등 클라우드 서비스

예시

# DogStatsD로 커스텀 메트릭 전송 (Python)
from datadog import statsd

# 카운터: 주문 수 증가
statsd.increment('orders.count', tags=['env:production', 'service:checkout'])

# 게이지: 현재 활성 사용자 수
statsd.gauge('users.active', 150, tags=['env:production'])

# 히스토그램: API 응답 시간
statsd.histogram('api.response_time', 0.235, tags=['endpoint:/api/orders'])

[!example] DogStatsD 동작 흐름 애플리케이션 → UDP :8125 → DogStatsD(집계) → Forwarder → Datadog 백엔드 UDP이므로 전송 실패가 애플리케이션 성능에 영향을 주지 않는다.

참고 자료

관련 노트