首页 > 其他 > 详细

[AWS] Lab: Install CloudWatch Agent on EC2 instance

时间:2021-05-03 18:56:02      阅读:21      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

1. Create a Role for CloudWatchAgent

Create Role for `EC2` Service, attach prolicy

技术分享图片

2. Create an EC2 instance

  • Select the IAM role with the Role you just created
  • add to boostrap
  • #!/bin/bash 
    yum update -y

     

3. Connect to EC2 Instance

1. Bootstrap script: 
#!/bin/bash
yum update -y

Install the CloudWatch Agent: 
sudo yum install amazon-cloudwatch-agent -y

2. Configure the CloudWatch agent: 
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard

**** Say no to monitoring CollectD ****
**** Monitor /var/log/messages ****

技术分享图片

技术分享图片

技术分享图片

技术分享图片

 

3. cd /opt/aws/amazon-cloudwatch-agent/bin
   /opt/aws/amazon-cloudwatch-agent/bin/config.json is the config file

4. Start the CloudWatch Agent
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json

5. Generate some activity on our system by installing stress - it’s in the Extra Packages for Enterprise Linux (EPEL) repository, so first well install the epel repository, then well install stress:

sudo amazon-linux-extras install epel -y
sudo yum install stress -y
stress --cpu 1

 

You can see the metric it generated:

技术分享图片

[AWS] Lab: Install CloudWatch Agent on EC2 instance

原文:https://www.cnblogs.com/Answer1215/p/14727461.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!