Cloud security, Cloud Training, Corporate Training

5 Mins Read

Steps To Monitor Memory Utilization of EC2 Instance with CloudWatch

What is Amazon CloudWatch?

Your Amazon Web Services (AWS) resources and the AWS apps you use are continuously monitored by Amazon CloudWatch. Metrics, which are variables you can monitor for your resources and applications, can be gathered and tracked using CloudWatch.  

Every AWS service you use has metrics automatically displayed on the CloudWatch home page. Also, you can design dashboards that show metrics related to your apps.  

When a threshold is crossed for a defined metric, you can set alarms to send messages or modify the resources you are monitoring automatically. For example, you can track your Amazon EC2 instances’ CPU consumption, disc reads, write and use the information to decide whether to deploy more instances to accommodate an increase in load.  

Monitor Your Instances Using CloudWatch

You can keep a record of your instances utilizing Amazon CloudWatch, which analyzes and interprets raw data from Amazon EC2 into observable, nearly real-time metrics. You can access past data and better understand how your web application or service works. These statistics are kept for 15 months.  

By default, Amazon EC2 sends 5-minute intervals of metric data to CloudWatch. You can enable detailed monitoring on the instance to submit metric data for your instance to CloudWatch in 1-minute intervals. A series of graphs based on the raw data from Amazon CloudWatch is shown on the Amazon EC2 console.  

The AWS/EC2 namespace includes the following instance metrics.  

  1. CPUUtilization  
  1. DiskReadOps  
  1. DiskWriteOps  
  1. DiskReadBytes  
  1. DiskWriteBytes  
  1. MetadataNoToken  
  1. NetworkIn  
  1. NetworkOut  
  1. NetworkPacketsIn  
  1. NetworkPacketsOut  
  1. CPUCreditUsage  

  

Notice that there are no metrics for memory utilization. You won’t find them in the CloudWatch console also. If you don’t have a personal monitoring device and you don’t want to log into the virtual machine each time to monitor memory usage, it is possible for AWS and provides you with these metrics. These types of metrics are known as custom metrics.  

In this article, I’ll walk you through the steps necessary to view these memory consumption metrics on the AWS CloudWatch console.  

Attend Any 5 AWS Certification Trainings at the cost of 2 with AWS Mastery Pass

  • AWS Authorized Instructor led Sessions
  • AWS Official Curriculum
Subscribe Now

Steps to Monitor Memory Utilization of EC2 Instance

1. Create IAM Role You must attach IAM roles to your EC2 instance and confirm they have the “CloudWatchFullAccess” rights. This explains how to create a role and properly assign it to an EC2 machine if you already don’t have one.  

Search for IAM, select “Roles” from the menu, and click “Create Role”.

Now select AWS Service, then EC2, and click Next because you want it to be attached by your EC2 instance.

Search for the policy “CloudWatchFullAccess,” select it, and click next.  

 

In the next step, you can add some TAGs and do next to the summary. In the last tab, give your role a name, and you can add a description. 

 

Now you need to assign it to the EC2 instance. To do this, select the instance from the list of EC2 instances, and click on Action/ Security/ Modify IAM role. Then select the created role from the drop-down list and click Save. 

 

2. Installing CloudWatch Agent First, log in to the EC2 instance, and download the CloudWatch agent.   

Reference:- Installing the CloudWatch agent – Amazon CloudWatch  

If you want CloudWatch Agent can send memory usage information every 60 seconds. Simply use an editor to fill out the /opt/aws/amazon-cloudwatch-agent/bin/config.json file with the necessary information. I shall prefer a vi editor for this. You can set the interval as needed.  

Enter the below text in the config.json file.  

With the below command, we can start the CloudWatch Agent.  

The above command output should be like below.  

If you did everything mentioned above, you should see the new CWAgent namespace in the CloudWatch console. Click on CWAgent 

Click on InstanceId 

You can verify from the EC2 console about your instance details. Here in my console, I can see the instance-id is the same as shown in the Cloudwatch console.  

Now select your instance name in the CloudWatch console, and you can see the memory utilization 

Pricing

There is no advance commitment or certain fee. You will be charged for the services you require and will be invoiced at the end of every month for your consumption.  

Metrics  

  • Standard Monitoring Parameters (at 5-minute frequency)   
  • 10 Comprehensive Monitoring Metrics (at 1-minute interval)   
  • 1 Million API requests (not relevant to GetMetricData and GetMetricWidgetImage)   

All custom metrics charges only when you send metrics to CloudWatch.  

Tiers  

Cost (metric/month)  

First 10,000 metrics  $0.30  

Next 240,000 metrics $0.10  

Next 750,000 metrics $0.05  

Over 1,000,000 metrics  

$0.02  

About CloudThat

As a pioneer in the Cloud consulting realm, CloudThat is AWS (Amazon Web Services) Advanced Consulting Partner, AWS authorized Training Partner, Microsoft Gold Partner, and Winner of the Microsoft Asia Superstar Campaign for India: 2021. Our team has designed and delivered various Disaster Recovery strategies to our customers.   

We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere to advance in their businesses.   

To get started, go through our Expert Advisory page and Managed Services Package that CloudThat’s offers. Then, you can quickly get in touch with our highly accomplished team of experts to carry out your migration needs. Feel free to drop a comment or any queries about Audio-to-text Automated Conversion, AWS Transcribe, or any other AWS services; we will get back to you quickly.   

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

Incepted in 2012 is the first Indian organization to offer Cloud training and consultancy for mid-market and enterprise clients. Our business goal is to provide global services on Cloud Engineering, Cloud Training, and Cloud Expert Line. The expertise in all major cloud platforms, including Microsoft Azure, Amazon Web Services (AWS), VMware, and Google Cloud Platform (GCP), position us as pioneers in the realm. 

WRITTEN BY Babajan Tamboli

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!