기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
AWS Distro for Open Telemetry를 사용하여 Amazon ECS에서의 지표 수집 설정
이 섹션에서는 AWS Distro for Open Telemetry(ADOT)를 사용하여 Amazon Elastic Container Service(Amazon ECS)에서 지표를 모으고 이를 Amazon Managed Service for Prometheus에 수집하는 방법을 설명합니다. 또한 Amazon Managed Grafana에서 지표를 시각화하는 방법도 설명합니다.
사전 조건
중요
시작하기 전에 기본 설정이 적용된 AWS Fargate 클러스터의 Amazon ECS 환경, Amazon Managed Service for Prometheus 워크스페이스, Amazon Managed Grafana 워크스페이스가 있어야 합니다. 컨테이너 워크로드, Amazon Managed Service for Prometheus, Amazon Managed Grafana에 대해 잘 알고 있다고 가정합니다.
자세한 내용은 다음 링크를 참조하십시오.
-
기본 설정이 적용된 Fargate 클러스터에서 Amazon ECS 환경을 생성하는 방법에 대한 자세한 내용은 Amazon ECS 개발자 안내서의 클러스터 생성을 참조하세요.
-
Amazon Managed Service for Prometheus 워크스페이스를 생성하는 방법에 대한 자세한 내용은 Amazon Managed Service for Prometheus 사용 설명서에서 워크스페이스 생성을 참조하세요.
-
Amazon Managed Grafana 워크스페이스를 생성하는 방법에 대한 자세한 내용은 Amazon Managed Grafana 사용 설명서에서 워크스페이스 생성을 참조하세요.
1단계: 사용자 지정 ADOT Collector 컨테이너 이미지 정의
다음 구성 파일을 템플릿으로 사용하여 고유한 ADOT Collector 컨테이너 이미지를 정의합니다. my-remote-URL
및 my-region
을 각각 endpoint
및 region
값으로 바꿉니다. 구성을 adot-config.yaml이라는 파일에 저장합니다.
참고
이 구성에서는 sigv4auth
확장 프로그램을 사용하여 Amazon Managed Service for Prometheus에 대한 호출을 인증합니다. sigv4auth
구성에 대한 자세한 내용은 GitHub의 Authenticator - Sigv4
receivers: prometheus: config: global: scrape_interval: 15s scrape_timeout: 10s scrape_configs: - job_name: "prometheus" static_configs: - targets: [ 0.0.0.0:9090 ] awsecscontainermetrics: collection_interval: 10s processors: filter: metrics: include: match_type: strict metric_names: - ecs.task.memory.utilized - ecs.task.memory.reserved - ecs.task.cpu.utilized - ecs.task.cpu.reserved - ecs.task.network.rate.rx - ecs.task.network.rate.tx - ecs.task.storage.read_bytes - ecs.task.storage.write_bytes exporters: prometheusremotewrite: endpoint:
my-remote-URL
auth: authenticator: sigv4auth logging: loglevel: info extensions: health_check: pprof: endpoint: :1888 zpages: endpoint: :55679 sigv4auth: region:my-region
service: aps service: extensions: [pprof, zpages, health_check, sigv4auth] pipelines: metrics: receivers: [prometheus] exporters: [logging, prometheusremotewrite] metrics/ecs: receivers: [awsecscontainermetrics] processors: [filter] exporters: [logging, prometheusremotewrite]
2단계: ADOT Collector 컨테이너 이미지를 Amazon ECR 리포지토리에 푸시
Dockerfile을 사용하여 컨테이너 이미지를 생성하고 Amazon Elastic Container Registry(ECR) 리포지토리에 푸시합니다.
-
Dockerfile을 빌드하여 컨테이너 이미지를 복사하고 OTEL 도커 이미지에 추가합니다.
FROM public.ecr.aws/aws-observability/aws-otel-collector:latest COPY adot-config.yaml /etc/ecs/otel-config.yaml CMD ["--config=/etc/ecs/otel-config.yaml"]
-
Amazon ECR 리포지토리를 생성합니다.
# create repo: COLLECTOR_REPOSITORY=$(aws ecr create-repository --repository aws-otel-collector \ --query repository.repositoryUri --output text)
-
컨테이너 이미지를 생성합니다.
# build ADOT collector image: docker build -t $COLLECTOR_REPOSITORY:ecs .
참고
여기서는 컨테이너가 실행될 환경과 동일한 환경에서 컨테이너를 빌드한다고 가정합니다. 그렇지 않은 경우 이미지를 빌드할 때
--platform
파라미터를 사용해야 할 수 있습니다. -
Amazon ECR 리포지토리에 로그인합니다.
my-region
을region
값으로 바꿉니다.# sign in to repo: aws ecr get-login-password --region
my-region
| \ docker login --username AWS --password-stdin $COLLECTOR_REPOSITORY -
컨테이너 이미지를 푸시합니다.
# push ADOT collector image: docker push $COLLECTOR_REPOSITORY:ecs
3단계: Amazon Managed Service for Prometheus를 스크래핑할 Amazon ECS 태스크 정의 생성
Amazon Managed Service for Prometheus를 스크래핑할 Amazon ECS 태스크 정의를 생성합니다. 태스크 정의에는 이름이 adot-collector
인 컨테이너와 이름이 prometheus
인 컨테이너가 포함되어야 합니다. prometheus
는 지표를 생성하고 adot-collector
는 prometheus
를 스크래핑합니다.
참고
Amazon Managed Service for Prometheus는 서비스로 실행되며 컨테이너에서 지표를 수집합니다. 이 경우 컨테이너는 Prometheus를 로컬에서 에이전트 모드로 실행하여 로컬 지표는 Amazon Managed Service for Prometheus로 전송됩니다.
예제: 태스크 정의
다음은 태스크 정의의 모양을 보여 주는 예제입니다. 이 예제를 템플릿으로 사용하여 자체 태스크 정의를 생성할 수 있습니다. adot-collector
의 image
값을 리포지토리 URL 및 이미지 태그($COLLECTOR_REPOSITORY:ecs
)로 바꿉니다. adot-collector
및 prometheus
의 region
값을 region
값으로 바꿉니다.
{ "family": "adot-prom", "networkMode": "awsvpc", "containerDefinitions": [ { "name": "adot-collector", "image": "
account_id
.dkr.ecr.region
.amazonaws.com/image-tag
", "essential": true, "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/ecs-adot-collector", "awslogs-region": "my-region
", "awslogs-stream-prefix": "ecs", "awslogs-create-group": "True" } } }, { "name": "prometheus", "image": "prom/prometheus:main", "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/ecs-prom", "awslogs-region": "my-region
", "awslogs-stream-prefix": "ecs", "awslogs-create-group": "True" } } } ], "requiresCompatibilities": [ "FARGATE" ], "cpu": "1024" }
4단계: Amazon Managed Service for Prometheus에 액세스할 수 있는 작업 권한 부여
스크래핑된 지표를 Amazon Managed Service for Prometheus로 보내려면 Amazon ECS 태스크에 AWS API 작업을 호출할 수 있는 올바른 권한이 있어야 합니다. 태스크에 대한 IAM 역할을 생성하고 이 역할에 AmazonPrometheusRemoteWriteAccess
정책을 연결해야 합니다. 이 역할을 생성하고 정책을 연결하는 방법에 대한 자세한 내용은 태스크에 대한 IAM 역할 및 정책 생성을 참조하세요.
AmazonPrometheusRemoteWriteAccess
를 IAM 역할에 연결하고 해당 역할을 태스크에 사용하면 Amazon ECS에서 스크래핑한 지표를 Amazon Managed Service for Prometheus로 보낼 수 있습니다.
5단계: Amazon Managed Grafana에서 지표 시각화
중요
시작하기 전에 Amazon ECS 태스크 정의에서 Fargate 태스크를 실행해야 합니다. 그렇지 않으면 Amazon Managed Service for Prometheus에서 지표를 사용할 수 없습니다.
-
Amazon Managed Grafana 워크스페이스의 탐색 창에서 AWS 아이콘 아래에 있는 데이터 소스를 선택합니다.
-
데이터 소스 탭의 서비스에서 Amazon Managed Service for Prometheus를 선택하고 기본 리전을 선택합니다.
-
데이터 소스 추가를 선택합니다.
-
ecs
및prometheus
접두사를 사용하여 지표를 쿼리하고 확인합니다.