Monitoring custom metrics using cloud watch
- In this series, lets see how to use cloud watch agent to monitor custom metrics
- Downloading and installing the cloud watch agent Refer Here
- Installing on Amazon linux2
wget https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
sudo rpm -ivh amazon-cloudwatch-agent.rpm
- Install the collectd if you want to collect custom metrics (Collect application and system performance metrics on a periodic basis)
sudo amazon-linux-extras install collectd
-
Creating an IAM role used by CloudWatch agent
- Navigate to IAM Console and create an IAM Role
- Navigate to IAM Console and create an IAM Role
-
Attach this IAM role to the ec2 instance
-
Run the cloud watch agent on the ec2 instance
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
- Once the wizard creation is completed it will create a configuration file @/opt/aws/amazon-cloudwatch-agent/bin/config.json
- To validate and start the cloud watch agent
sudo /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
- To verify if the cloudwatch agent is running
ps aux | grep -i amazon-cloudwatch-agent
- Now navigate to the cloud watch and check metrics
CloudWatch Events
- AWS Cloud watch events are similar to alarms but instead of configuring alarms or thresholds, they match event patterns.
- The event patterns can be related to
- EC2 state change
- S3 File upload
- RDS instance State change
- Exercise
- Create an Event to notify when ec2 instance state is changed for all the ec2 instances.
- Shutdown the ec2 instance and verify the email.
