Step 1: Launching an EC2 Instance
The first step in configuring CloudWatch SM-Agent is to launch an EC2 instance. You can launch an EC2 instance using the AWS Management Console or the AWS CLI.
Step 2: Installing the Systems Manager Agent
After launching the EC2 instance, the next step is to install the Systems Manager Agent. You can install the agent using either the AWS Management Console or the AWS CLI.
To install the Systems Manager Agent using the AWS Management Console, follow these steps:
- Open the AWS Management Console and go to the EC2 service.
- Select the EC2 instance that you want to install the agent on.
- Click the Connect button and follow the instructions to connect to the instance.
- Once you are connected to the instance, open the terminal or command prompt.
- Run the following command to download and install the Systems Manager Agent:
sudo yum install -y amazon-ssm-agent
To install the Systems Manager Agent using the AWS CLI, follow these steps:
- Open the terminal or command prompt.
- Run the following command to download and install the Systems Manager Agent:
aws ssm create-association –name AWS-ConfigureAWSPackage –parameters ‘{“action”:[“Install”],”installationType”:[“Uninstall and reinstall”],”name”:[“AmazonCloudWatchAgent”],”version”:[“latest”]}’ –targets “Key=instanceids,Values=<instance_id>”
Step 3: Configuring the Systems Manager Agent
After installing the Systems Manager Agent, the next step is to configure it. You can configure the agent using the AWS Management Console or the AWS CLI.
To configure the Systems Manager Agent using the AWS Management Console, follow these steps:
- Open the AWS Management Console and go to the EC2 service.
- Select the EC2 instance that you want to configure the agent on.
- Click the Actions button and select the Instance Settings option.
- Click the Configure CloudWatch Agent option.
- Follow the instructions to configure the agent.
To configure the Systems Manager Agent using the AWS CLI, follow these steps:
- Open the terminal or command prompt.
- Run the following command to create a configuration file for the agent:
sudo nano /opt/aws/amazon-cloudwatch-agent/bin/config.json
- Copy and paste the following configuration code into the file:
{
“agent”: {
“metrics_collection_interval”: 60,
“run_as_user”: “cwagent”
},
“metrics”: {
“append_dimensions”: {
“AutoScalingGroupName”: “${aws:AutoScalingGroupName}”,
“InstanceId”: “${aws:InstanceId}”,
“InstanceType”: “${aws:InstanceType}”
},
“metrics_collected”: {
“mem”: {
“measurement”: [
“mem_used_percent”
],
“metrics_collection_interval”: 60,
“resources”: [
“*”
]
},
“swap”: {
“measurement”: [
“swap_used_percent”
],
“metrics_collection_interval”: 60,
“resources”: [
“*”
]
}
}
}
}
- Save and close the file.
- Run
Another way:
When you want to use Cloudwatch for monitoring the AWS Cloud services you need to configure with the below steps: a) Cloud watch agent through SM-Agent in an EC2 server with different IAM role policies. b) In the architecture you need to Install the Cloud watch agent with different IAM policy role on different EC2 clients.
- Step1:
Creating IAM Roles - Step2:
How to install and configure SSM Agent in EC2 server - Step3:
How to install Cloud-watch Agent on Client EC2.
The attached video has the class discussion and the required steps.
Visit my current running facebook groups for IT Professionals with my valuable discussions/videos/blogs posted:
https://www.facebook.com/groups/1911594275816833/about/
https://www.facebook.com/groups/585147288612549/about/
Build Cloud Solution Architects [With some videos of the live students classes/feedback]
https://www.facebook.com/vskumarcloud/
MicroServices and Docker [For learning concepts of Microservices and Docker containers]
https://www.facebook.com/MicroServices-and-Docker-328906801086961/