베하 ~~~~!
이번 시간에도 서 지 타 산 입니다 !!
EC2 지표를 어떤 방식으로 확인하시고 계신가요?
이번 시간에는 EC2
EC2 인스턴스의 리소스를
모니터링하기 위해
CloudWatch 대시보드를 구성하는 방법을 학습합시다.
팔로팔로팔로미 ~~~~~~~
1. Cloudwatch
- CloudWatch는 AWS 사용자들을 위해서 애플리케이션이나 시스템 성능에 대해서 전반적으로 확인하여 변경 사항에 대응할 수 있는 모니터링 시스템
- 문제나 장애 발생시 경보를 설정 하여 알림을 받을 수 있고 지표를 시각화 하여 한 눈에 파악할 수 있음
2. EC2 인스턴스 모니터링(cpu)
- Cloudwatch는 EC2 인스턴스의 CPU에 대한 지표를 기본 제공합니다.
2-1. CloudWatch 콘솔에서 대시보드를 클릭, 대시보드 생성을 선택하여 대시보드 이름을 정하고 대시보드를 생성합니다.
2-2. 위젯 추가 화면에서 행, 지표로 선택된 것을 유지하고 다음을 선택합니다.
2-3. 그리고 지표를 다음과 같이 검색하여 추가한후 위젯을 생성합니다. - CPU: CPUUtilization
2-4. 생성된 CloudWatch 대시보드를 확인하고 우측 상단의 저장을 선택합니다.
2. EC2 인스턴스 모니터링(memory, disk)
- 서버의 기본적인 메모리, 디스크 사용률에 대한 지표를 제공하지 않기 때문에
서버에 접속 후 CloudWatch Agent를 설치하는 과정을 거쳐야 합니다.
3-1. IAM 역할 생성 : EC2 인스턴스에서 CloudWatch 에이전트를 사용하려면 IAM 역할을 생성하고 연결해야 합니다.
IAM - 역할
역할 만들기
EC2 클릭 후 다음
정책 연결
이름 설정 후 역할 만들기
EC2 우클릭 - 보안 - IAM 역할 수정
CloudWatch Agent 허용 역할 추가
EC2 접속
3-2. CloudWatch 에이전트 패키지를 다운로드하고 설치합니다.(아래는 Linux 기준)
- wget을 통해 다운로드 (Amazon Linux)
[root@linux_test ~]# wget https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
- 패키지 설치(내려 받은 파일)
[root@linux_test ~]# rpm -ivh amazon-cloud-watch-agent.rpm
- Agent 구성 마법사 실행
[root@linux_test ~]# /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
=============================================================
= Welcome to the AWS CloudWatch Agent Configuration Manager =
=============================================================
On which OS are you planning to use the agent?
1. linux
2. windows
3. darwin
default choice: [1]:
1
Trying to fetch the default region based on ec2 metadata...
Are you using EC2 or On-Premises hosts?
1. EC2
2. On-Premises
default choice: [1]:
1
Which user are you planning to run the agent?
1. root
2. cwagent
3. others
default choice: [1]:
1
Do you want to turn on StatsD daemon?
1. yes
2. no
default choice: [1]:
2
Do you want to monitor metrics from CollectD?
1. yes
2. no
default choice: [1]:
2
Do you want to monitor any host metrics? e.g. CPU, memory, etc.
1. yes
2. no
default choice: [1]:
1
Do you want to monitor cpu metrics per core? Additional CloudWatch charges may apply.
1. yes
2. no
default choice: [1]:
2
Do you want to add ec2 dimensions (ImageId, InstanceId, InstanceType, AutoScalingGroupName) into all of your metrics if the info is available?
1. yes
2. no
default choice: [1]:
1
Would you like to collect your metrics at high resolution (subminute resolution)? This enables sub-minute resolution for all metrics, but you can customize for specific metrics in the output json file.
1. 1s
2. 10s
3. 30s
4. 60s
default choice: [4]:
4
Which default metrics config do you want?
1. Basic
2. Standard
3. Advanced
4. None
default choice: [1]:
1
Are you satisfied with the above config? Note: it can be manually customized after the wizard completes to add additional items.
1. yes
2. no
default choice: [1]:
1
Do you have any existing CloudWatch Log Agent configuration file to import for migration?
1. yes
2. no
default choice: [2]:
2
Do you want to monitor any log files?
1. yes
2. no
default choice: [1]:
2
Do you want to store the config in the SSM parameter store?
1. yes
2. no
default choice: [1]:
2
- CloudWatch Agent 실행
[root@linux_test ~]# /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s
![](https://blog.kakaocdn.net/dn/broZcb/btsoyrN5Xu2/5j7uTCMXmemapCM8jCAO80/img.png)
대시보드에서 위젯 추가 시 새로 만든 지표가 생성되어있습니다.
![](https://blog.kakaocdn.net/dn/dzJuC5/btsoxbZwLsB/xkicpaBPalm6KIbbgWsRT0/img.png)
![](https://blog.kakaocdn.net/dn/A5IMM/btsoDH3Ajxo/k8VRJYuUs058l7HteYXpE0/img.png)
여기까지 Cloudwatch를 이용한 ECC2 모니터링에 대해 간단히 알아봤습니다.
항상 건강하시고 좋은 하루 되시길 바랍니다 :)
'CSP (Cloud Service Provider) > AWS' 카테고리의 다른 글
[AWS] ROOT 계정 이메일 변경 방법 (0) | 2023.07.28 |
---|---|
Lambda_API Gateway 트리거 설정 & 엑세스 로깅을 활성화 (0) | 2023.07.24 |
[AWS] AWS ELB Prewarming (0) | 2023.07.21 |
[AWS] MWAA(Managed Workflows for Apache Airflow) (0) | 2023.07.21 |
[AWS] AWS DLM (Data Lifecycle Manager) 실습 (0) | 2023.07.21 |
댓글