Installing and Running the CloudWatch Agent On Your Servers

Make sure your server is running a supported operating system, such as Windows Server, Amazon Linux, Amazon Linux 2, CentOS, Ubuntu, or Red Hat Enterprise Linux (RHEL). Make sure your server has internet access so it can download the required configurations and packages.

Steps to Install and Configure Cloud Watch Agent

Step 1: Firstly, log in to your AWS account then If the IAM role is already created, go to -> EC2 Dashboard and create a new instance. Otherwise, Create a new IAM Role.

Step 2: Go to Instances in Resources then click on Launch Instance in EC2 Dashboard.

then enter the appropriate Name for example MyCWInstance and select after searching instance type Amazon Linux 2 AMI(HVM) -Kernel 5.10, SSD volume Type in Application and OS Images.

Step 3: By default, selected t2. the micro then select vockey in Key Pair then select Your IAM role in the IAM instance profile of Advanced details and successfully initiated the launch of the Instance through click on Launch Instance Button.

Step 4: We can see our Instance (MyCWInstance) in EC2 instance Dashboard.

Select the check box of our Instance and go to ->Action and Connect for Connect to Instance. then click on Connect.

Step 5: Enter the command in the console β€˜ sudo yum install amazon-cloud watch-agent -y β€˜ to install successfully CloudWatch agent.

Step 6: Next thing is to we need to move the folder in where it is installed then we will launch the CloudWatch Configuration result β€˜ sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard β€˜.

  • Choose Answer:
    • Select OS-> Linux,
    • Default Region->EC2,
    • User planning to run the agent-> root,
    • StatsD daemon->Yes,
    • Default port [8125] -> Enter,
    • IThe interval10S,
    • The interval for metrics-> the 60s,
    • Do you want to monitor from CollectD?-> No,
    • Do you want to monitor any host metrics? ->Yes,
    • Do you want to monitor CPU metrics per core->Yes,
    • Do you want to add an ec2 dimension-> Yes,
    • Do you want to add an ec2 dimension->Yes,
    • Would you like to collect your metrics at high resolution? -> 60s,
    • Default metrics-> Standard,
    • Satisfied above config->Yes,
    • Have any Existing CloudWatch log agent->No,
    • Want to monitor->Yes,
    • Log File Path-> /var/log/messages
    • Log group name->ec2logforcwagentinstance
    • Log stream name-> Enter for default.
    • Log group->2 – 1
    • Do you want to Additional log files to monitor? ->No
    • Do you want to store the config in the SSM parameter store? ->No then display Program exists now.

Step 7: Clear our screen->clear then β€˜ cd /opt/aws/amazon-cloud watch-agent/bin β€˜ then β€˜ ls β€˜.

Step 8: Enter β€˜ sudo /opt/aws/amazon-cloud watch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloud watch-agent/bin/config.json β€˜ Configuration validation succeeded.

Step 9: Enter β€˜ sudo amazon-linux-extras install epel -y β€˜ then β€˜ sudo yum install stress -y β€˜, β€˜ stress –cpu 1 β€˜.

Running the CloudWatch Agent:

  • Go back to services in Dashboard and click on cloud watch ->Metrics-> all Metrics-> EC2 -> select CloudWatchAgentERole and see the Graph.
  • CWAgent-> ImageId, InstanceId, InstanceType, device and select CWAgent named disk_used_percent and many more to see the Graph with different colors.
  • Collect Metrics and Logs with the CloudWatch Agent

The Amazon CloudWatch agent ought to now be installed and operating on your server, gathering and sending metrics and logs to CloudWatch in accordance with the configuration you provided. By monitoring your CloudWatch metrics and logs in the AWS Management Console, you can make sure that they are being processed as intended.

How to Run and Install the CloudWatch Agent on Your Servers?

Amazon CloudWatch is a powerful tool that is used to collect metrics on resources and monitor their performance of the resources. It can monitor system-level metrics like CPU usage, memory usage, and disk space and also the application levels metrics like requests per second and error rates. By collecting these data it will help the developers to analyze and know the performance of the servers.

Similar Reads

What is the CloudWatch Agent?

The Amazon Web Services (AWS) CloudWatch agent is a piece of software that lets you gather and keep track of metrics, logs, and events from various AWS resources and applications operating on your servers. It functions via virtual machines, on-premises servers, and an EC2 instance. It enables you to obtain insightful information and performance statistics that can be applied to analysis, monitoring, and troubleshooting in real time....

Types of Monitoring

Basic Monitoring Detailed Monitoring...

Benefits of Installing The CloudWatch Agent

Real-Time Monitoring Custom Metrics and Logs Centralized Monitoring Automated Alarms Troubleshooting and Diagnosis Historical Analysis Security and Compliance Administration Made Simple...

Installing and Running the CloudWatch Agent On Your Servers

Make sure your server is running a supported operating system, such as Windows Server, Amazon Linux, Amazon Linux 2, CentOS, Ubuntu, or Red Hat Enterprise Linux (RHEL). Make sure your server has internet access so it can download the required configurations and packages....

How to Troubleshooting the CloudWatch Agent?

The CloudWatch agent’s configuration, connectivity, and metric and log collecting issues must be found and fixed during troubleshooting. You can troubleshoot common issues with the CloudWatch agent by following these steps:...

FAQs On CloudWatch Agent

1. What is the CloudWatch Agent, and What Exactly Does The CloudWatch Agent Do?...