Configuring CloudWatch SM-Agent: A Step-by-Step Guide.

Introduction Amazon CloudWatch is a monitoring service provided by Amazon Web Services (AWS) that enables developers to monitor, log and troubleshoot their applications and infrastructure running on the AWS Cloud. CloudWatch provides several features, including monitoring metrics, setting alarms, and creating custom metrics, among others. One of the most useful features of CloudWatch is the Systems Manager Agent (SM-Agent), which helps monitor and manage Amazon EC2 instances. In this blog post, we will discuss how to configure CloudWatch SM-Agent.

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:

  1. Open the AWS Management Console and go to the EC2 service.
  2. Select the EC2 instance that you want to install the agent on.
  3. Click the Connect button and follow the instructions to connect to the instance.
  4. Once you are connected to the instance, open the terminal or command prompt.
  5. 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:

  1. Open the terminal or command prompt.
  2. 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:

  1. Open the AWS Management Console and go to the EC2 service.
  2. Select the EC2 instance that you want to configure the agent on.
  3. Click the Actions button and select the Instance Settings option.
  4. Click the Configure CloudWatch Agent option.
  5. Follow the instructions to configure the agent.

To configure the Systems Manager Agent using the AWS CLI, follow these steps:

  1. Open the terminal or command prompt.
  2. Run the following command to create a configuration file for the agent:

sudo nano /opt/aws/amazon-cloudwatch-agent/bin/config.json

  1. 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”: [
“*”
]
}
}
}
}

  1. Save and close the file.
  2. 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:

 

DevOps Practices Group:

https://www.facebook.com/groups/1911594275816833/about/

 

Cloud Practices Group:

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/

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s