AWS Elastic Beanstalk

개요

AWS Elastic Beanstalk은 Apache, Nginx, Passenger 및 IIS 등 자주 사용되는 서버에서 자바(Java), .NET, PHP, Node.js, 파이썬(Python), 루비(Ruby), 고(Go) 및 도커(Docker)로 개발된 웹 애플리케이션과 서비스를 간단하게 배포하고 확장할 수 있도록 해주는 서비스로, 손쉽게 이용할 수 있습니다.

설정

설치

이미 하지 않았다면 먼저 Amazon Web Services 통합을 설정하세요. Elastic Beanstalk 메트릭을 수신하려면 환경에서 [Enhanced Health Reporting 기능을 활성화]해야 합니다. 또한 환경이 [클라우드와치(CloudWatch)에 향상된 상태 메트릭을 게시]하도록 설정해야 합니다.

참고: 이러한 설정은 클라우드와치(CloudWatch) 커스텀 메트릭 요금을 상승시킬 수 있습니다.

수집한 데이터

메트릭

aws.elasticbeanstalk.application_latency_p_1_0
(gauge)
The average time to complete the fastest 10 percent of requests.
Shown as second
aws.elasticbeanstalk.application_latency_p_5_0
(gauge)
The average time to complete the fastest 50 percent of requests.
Shown as second
aws.elasticbeanstalk.application_latency_p_7_5
(gauge)
The average time to complete the fastest 75 percent of requests.
Shown as second
aws.elasticbeanstalk.application_latency_p_8_5
(gauge)
The average time to complete the fastest 85 percent of requests.
Shown as second
aws.elasticbeanstalk.application_latency_p_9_0
(gauge)
The average time to complete the fastest 90 percent of requests.
Shown as second
aws.elasticbeanstalk.application_latency_p_9_5
(gauge)
The average time to complete the fastest 95 percent of requests.
Shown as second
aws.elasticbeanstalk.application_latency_p_9_9
(gauge)
The average time to complete the fastest 99 percent of requests.
Shown as second
aws.elasticbeanstalk.application_latency_p_9_9_9
(gauge)
The average time to complete the fastest 99.9 percent of requests.
Shown as second
aws.elasticbeanstalk.application_requests_2xx
(count)
The number of requests that completed with a 2XX status code.
Shown as request
aws.elasticbeanstalk.application_requests_3xx
(count)
The number of requests that completed with a 3XX status code.
Shown as request
aws.elasticbeanstalk.application_requests_4xx
(count)
The number of requests that completed with a 4XX status code.
Shown as request
aws.elasticbeanstalk.application_requests_5xx
(count)
The number of requests that completed with a 5XX status code.
Shown as request
aws.elasticbeanstalk.application_requests_total
(count)
The number of requests completed by the instance or environment.
Shown as request
aws.elasticbeanstalk.cpuidle
(gauge)
[Instance] The percentage of time the CPU was in the idle state in the last minute.
Shown as percent
aws.elasticbeanstalk.cpuiowait
(gauge)
[Instance] The percentage of time the CPU was in the iowait state in the last minute.
Shown as percent
aws.elasticbeanstalk.cpuirq
(gauge)
[Instance] The percentage of time the CPU was in the interrupt request state in the last minute.
Shown as percent
aws.elasticbeanstalk.cpunice
(gauge)
[Instance] The percentage of time the CPU was in the nice state in the last minute.
Shown as percent
aws.elasticbeanstalk.cpusoftirq
(gauge)
[Instance] The percentage of time the CPU was in the soft interrupt request state in the last minute.
Shown as percent
aws.elasticbeanstalk.cpusystem
(gauge)
[Instance] The percentage of time the CPU was in the system state in the last minute.
Shown as percent
aws.elasticbeanstalk.cpuuser
(gauge)
[Instance] The percentage of time the CPU was in the user state in the last minute.
Shown as percent
aws.elasticbeanstalk.environment_health
(gauge)
[Environment] The health status of the environment. The possible values are 0 (OK) 1 (Info) 5 (Unknown) 10 (No data) 15 (Warning) 20 (Degraded) and 25 (Severe).
aws.elasticbeanstalk.instance_health
(gauge)
[Instance] The health status of the instance.
Shown as instance
aws.elasticbeanstalk.instances_degraded
(count)
[Environment] The number of instances with Degraded health status.
Shown as instance
aws.elasticbeanstalk.instances_info
(count)
[Environment] The number of instances with Info health status.
Shown as instance
aws.elasticbeanstalk.instances_no_data
(count)
[Environment] The number of instances with no health status data.
Shown as instance
aws.elasticbeanstalk.instances_ok
(count)
[Environment] The number of instances with OK health status.
Shown as instance
aws.elasticbeanstalk.instances_pending
(count)
[Environment] The number of instances with Pending health status.
Shown as instance
aws.elasticbeanstalk.instances_severe
(count)
[Environment] The number of instances with Severe health status.
Shown as instance
aws.elasticbeanstalk.instances_unknown
(count)
[Environment] The number of instances with Unknown health status.
Shown as instance
aws.elasticbeanstalk.instances_warning
(count)
[Environment] The number of instances with Warning health status.
Shown as instance
aws.elasticbeanstalk.load_average_1min
(gauge)
[Instance] The average CPU load over the last minute.
aws.elasticbeanstalk.load_average_5min
(gauge)
[Instance] The average CPU load over the last five minutes.
aws.elasticbeanstalk.root_filesystem_util
(gauge)
[Instance] The percentage of disk space in use.
Shown as percent

AWS에서 검색된 각 메트릭에는 호스트 이름, 보안 그룹 등을 포함하되 이에 국한되지 않고 AWS 콘솔에 표시되는 동일한 태그가 할당됩니다.

이벤트

AWS Elastic Beanstalk 통합은 이벤트를 포함하지 않습니다.

서비스 검사

AWS Elastic Beanstalk 통합은 서비스 점검을 포함하지 않습니다.

Datadog 에이전트 설정

다음 단계에서 Elastic Beanstalk VM에 Datadog 에이전트를 배포합니다. 그러므로 AWS 통합에서 수집한 메트릭과 함께 호스트 메트릭을 보고하게 됩니다. 자세한 정보는 [클라우드 인스턴스에서 Datadog 에이전트를 설치해야 하는 이유]를 읽어보세요.

설치 방법을 선택해 Elastic Beanstalk 환경에서 에이전트를 설정합니다.

컨테이너 설정이 없는 경우 설정 파일을 통한 Advanced Environment Customization을 사용하여 Elastic Beanstalk에서 Datadog 에이전트를 설치합니다. (.ebextensions):

  1. 애플리케이션 소스 번들의 루트에 .ebextensions란 이름의 폴더를 생성합니다.
  2. 99datadog.config를 다운로드한 다음 .ebextensions 폴더에 넣습니다.
  3. Datadog API 키를 사용해 /etc/datadog-agent/datadog.yaml 파일 템플릿 내에서 api_key 값을 변경합니다.
  4. Datadog 지역(예: )에 대해 /etc/datadog-agent/datadog.yaml에서 site 값을 변경하여 에이전트다 올바른 Datadog 위치에 데이터를 보내도록 합니다.
  5. option_settings 아래 DD_AGENT_VERSION를 설정하고 특정 에이전트 버전을 고정하여 모든 호스트에 동일한 버전의 에이전트가 실행되도록 합니다.
  6. Elastic Beanstalk Console, EB CLI 또는 AWS CLI를 사용해 애플리케이션을 배포합니다.

/etc/datadog-agent/datadog.yaml에 부수적으로 에이전트 설정을 추가할 수 있습니다.

예를 들어, Live 프로세스 모니터링을 활성화라려면,

process_config:
  enabled: "true"

트레이스 수집

애플리케이션이 컨테이너화되지 않았고 Datadog 에이전트가 99datadog.config로 설정된 경우, 애플리케이션이 트레이싱 라이브러리 설정으로 계측되었다면 추가 설정 없이 트레이싱이 활성화된 것입니다.

컨테이너 설정이 없는 경우 설정 파일을 통한 Advanced Environment Customization을 사용하여 Elastic Beanstalk에서 Datadog 에이전트를 설치합니다. (.ebextensions):

  1. 애플리케이션 소스 번들의 루트에 .ebextensions란 이름의 폴더를 생성합니다.
  2. 99datadog-windows.config를 다운로드한 다음 .ebextensions 폴더로 이동시킵니다.
  3. 99datadog-windows.config에서 APIKEY 값을 Datadog API 키로 대체합니다.
  4. (선택 항목) 99datadog-windows.config 파일이 .NET APM 트레이싱 라이브러리에 추가되어 트레이스를 생성합니다. 환경에서 APM을 활성화하지 않으려면, packages 섹션, 02_setup-APM1 섹션, 03_setup-APM2 섹션을 제거합니다.
  5. (선택 항목) 환경 변수를 추가하려면 99datadog-windows.config00_setup-env1 섹션에서 설정합니다. 환경 변수를 설정하지 않으려면 이 섹션을 제거할 수 있습니다.
  6. Elastic Beanstalk Console, EB CLI 또는 AWS CLI를 사용해 애플리케이션을 배포합니다.

트레이스 수집

애플리케이션이 컨테이너화되지 않았고 Datadog 에이전트가 99datadog-windows.config로 설정되지 않은 경우 트레이싱은 추가 설정 없이 활성화됩니다. 트레이싱 계측에 대한 자세한 정보는 Datadog APM 설정을 참조하세요.

단일 도커(Docker) 컨테이너 설정의 경우 설정 파일을 사용한 Advanced Environment Customization을 통해 Elastic Beanstalk에서 Datadog 에이전트를 설치합니다.

참고: 이 설정을 위해서는 소스 코드의 일부인 API 키가 .ebextensions 디렉터리에 있어야 합니다. AWS Secret Manager 또는 기타 기밀 관리 도구를 사용해 API 키를 보호하세요.

  1. 애플리케이션 소스 번들의 루트에서 .ebextensions란 이름의 폴더를 생성하세요.
  2. 99datadog.config를 다운로드하고 .ebextensions 폴더에 넣습니다.
  3. Datadog API 키를 사용해 /etc/datadog-agent/datadog.yaml 파일 템플릿 내에 api_key 값을 변경합니다.
  4. Datadog 지역(예: )에 대해 /etc/datadog-agent/datadog.yaml에서 site 값을 변경하여 에이전트다 올바른 Datadog 위치에 데이터를 보내도록 합니다.
  5. option_settings 아래 DD_AGENT_VERSION를 설정하고 특정 에이전트 버전을 고정하여 모든 호스트에 동일한 버전의 에이전트가 실행되도록 합니다.
  6. Elastic Beanstalk Console, EB CLI 또는 AWS CLI를 사용해 애플리케이션을 배포합니다.

/etc/datadog-agent/datadog.yaml에 부수적으로 에이전트 설정을 추가할 수 있습니다.

예를 들어, Live 프로세스 모니터링을 활성화라려면,

process_config:
  enabled: "true"

트레이스 수집

단일 도커 컨테이너의 트레이싱을 활성화하려면,

  1. apm_non_local_traffic을 사용해 99datadog.config 파일에서 /etc/datadog-agent/datadog.yaml 섹션을 업데이트합니다. 형식은 다음과 같습니다.

    apm_config:
      enabled: "true"
      apm_non_local_traffic: "true"
    
  2. 트레이싱 라이브러리를 설정하여 브리지 네트워크의 게이트웨이 IP에 트레이스를 전달합니다. 애플리케이션 컨테이너 내부에서 게이트웨이 IP 기본값은 172.17.0.1입니다. (이 값이 게이트웨이 IP인지 명확하지 않다면 docker inspect <container id>를 실행해 확인하세요.)

모든 언어에 대해 게이트웨이 IP에 대한 환경 변수를 DD_AGENT_HOST로 설정합니다. 대신 프로그래밍 방식으로 다음을 사용해 아래 언어에 대한 호스트 이름을 설정할 수 있습니다.

Python
from ddtrace import tracer

tracer.configure(hostname="172.17.0.1")
Node.js
const tracer = require('dd-trace');

tracer.init({ hostname: "172.17.0.1" });
Ruby
require 'ddtrace'

Datadog.configure do |c|
  c.tracer hostname: "172.17.0.1")
end
Go
package main

import (
    "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

func main() {
  tracer.Start(tracer.WithAgentAddr("172.17.0.1"))
  defer tracer.Stop()

  // ...
}

다수의 도커 컨테이너에 대해 컨테이너화된 Datadog 에이전트와 Dockerrun.aws.json란 이름의 파일을 사용해 도커를 모니터링할 수 있습니다.

Dockerrun.aws.json 파일은 Elastic Beanstalk입니다. 즉, 특정 JSON 파일로 Elastic Beanstalk 애플리케이션으로 도커(Docker) 컨테이너 세트를 배포하는 방법을 설명합니다. 이 파일을 멀티컨테이너 도커 환경에 사용할 수 있습니다. Dockerrun.aws.json은 환경 내 각 컨테이너 인스턴스에 컨테이너를 배포하는 방법을 설명합니다. 또한 마운트할 컨테이너에 대한 호스트 인스턴스에서 데이터 볼륨을 생성하는 방법을 설명합니다.

Dockerrun.aws.json 파일은 단일 아카이브에서 추가적인 소스 코드를 사용해 압축하거나 자체적으로 사용할 수 있습니다. Dockerrun.aws.json로 아카이브된 소스 코드는 컨테이너 인스턴스로 배포되며 /var/app/current/ 디렉터리에서 액세스할 수 있습니다. 설정의 volumes 섹션을 사용해 인스턴스에서 실행되는 컨테이너의 마운트 지점을 제공합니다. 또한 내장 컨테이너 정의의 mountPoints 섹션을 활용해 컨테이너에 대해 마운트합니다.

다음 코드 샘플은 Datadog 에이전트를 정의하는 Dockerrun.aws.json을 설명합니다. Datadog API 키, 태그(옵션), 또는 부수적인 컨테니어 정의를 사용해 containerDefinitions 섹션을 업데이트합니다. 필요한 경우 이 파일은 위에 설명된 대로 추가적인 콘텐츠와 함께 압축될 수 있습니다. 이 파일의 구문에 대한 자세한 정보는 멀티컨테이너 도커 설정을 참조하세요.

참고:

  • 리소스 사용량이 높은 경우, 더 높은 메모리 한도가 필요할 수 있습니다.
  • 모든 호스트에서 동일한 에이전트 버전이 실행되도록 하려면 agent:7를 특정 도커 이미지 부 버전으로 변경하는 것이 좋습니다.

  • DD_SITE로 설정해 에이전트가 올바른 Datadog 위치에 데이터를 전송하도록 합니다.

{
    "AWSEBDockerrunVersion": 2,
    "volumes": [
        {
            "name": "docker_sock",
            "host": {
                "sourcePath": "/var/run/docker.sock"
            }
        },
        {
            "name": "proc",
            "host": {
                "sourcePath": "/proc/"
            }
        },
        {
            "name": "cgroup",
            "host": {
                "sourcePath": "/cgroup/"
            }
        }
    ],
    "containerDefinitions": [
        {
            "name": "dd-agent",
            "image": "gcr.io/datadoghq/agent:7",
            "environment": [
                {
                    "name": "DD_API_KEY",
                    "value": "<YOUR_DD_API_KEY>"
                },
                {
                    "name": "DD_SITE",
                    "value": "<YOUR_DD_SITE>"
                },
                {
                    "name": "DD_TAGS",
                    "value": "<SIMPLE_TAG>, <KEY:VALUE_TAG>"
                }
            ],
            "memory": 256,
            "mountPoints": [
                {
                    "sourceVolume": "docker_sock",
                    "containerPath": "/var/run/docker.sock",
                    "readOnly": false
                },
                {
                    "sourceVolume": "proc",
                    "containerPath": "/host/proc",
                    "readOnly": true
                },
                {
                    "sourceVolume": "cgroup",
                    "containerPath": "/host/sys/fs/cgroup",
                    "readOnly": true
                }
            ]
        }
    ]
}

환경 생성

컨테이너 정의가 준비되면 Elastic Beanstalk로 전달합니다. 구체적인 지침은 AWS Elastic Beanstalk 설명서의 멀티컨테이너 도커 환경을 참조하세요.

DogStatsD

멀티컨테이너 도커 환경에서 DogStatsD를 사용해 애플리케이션 컨테이너에서 커스텀 메트릭을 수집하려면, Dockerrun.aws.json에 다음을 추가합니다.

  1. dd-agent 컨테이너 아래에 DD_DOGSTATSD_NON_LOCAL_TRAFFIC 환경 변수 추가:

    {
      "name": "DD_DOGSTATSD_NON_LOCAL_TRAFFIC",
      "value": "true"
    }
    
  2. 애플리케이션 컨테이너 아래 dd-agent 컨테이너에 대한 링크 추가:

    "links": [ "dd-agent:dd-agent"]
    

추가 정보는 DogStatsD 및 Docker를 참조하세요.

다수의 도커 컨테이너

  1. 애플리케이션과 동일한 Dockerrun.aws.json에서 datadog/agent 이미지를 사용해 Datadog 에이전트 컨테이너를 추가합니다. 다음을 추가합니다.
    • portMappings 섹션에서 containerPort 8126을 사용해 hostPort 8126을 추가합니다.
    • environment 섹션에서 DD_APM_ENABLEDDD_APM_NON_LOCAL_TRAFFICtrue로 설정합니다.
  2. [트레이싱 라이브러리 설정][14]으로 계측된 애플리케이션 컨테이너 아래에서 다음을 추가합니다.
    • environment 섹션 아래에서 DD_AGENT_HOST로 불리는 환경 변수를 Datadog 에이전트 컨테이너 이름에 추가합니다.
    • links 섹션에서 에이전트 컨테이너가 환경 변수로 사용되도록 설정합니다.

예는 아래와 같습니다.

 "containerDefinitions": [    {
      "name": "dd-agent",
      "image": "datadog/agent:latest",
      "environment": [
          {
              "name": "DD_API_KEY",
              "value": "<api key>"
          },
          {
              "name": "DD_APM_ENABLED",
              "value": "true"
          },
          {
             "name": "DD_APM_NON_LOCAL_TRAFFIC",
             "value": "true"
          },
         # any other environment variables needed
      ],
      "portMappings": [
        {
          "hostPort": 8126,
          "containerPort": 8126
        }
      ],
      "memory": 256,
      "mountPoints": [
          # any mountpoints needed
         }
      ]
    },
    {
      "name": "application-container",
      "image": "<application image name>",
      "environment": [
        {
          "name": "DD_AGENT_HOST",
          "value": "dd-agent",
          # any other environment variables needed
        }
      ],
      "links": [
        "dd-agent:dd-agent"
      ],

트러블슈팅

도움이 필요하신가요? Datadog 지원팀에 문의하세요.

참고 자료

Additional helpful documentation, links, and articles: