Monitor AWS Autoscaling Server Memory and Disk in CloudWatch


2 min read

Monitor AWS Autoscaling Server Memory and Disk in CloudWatch

Monitoring AWS Auto Scaling server memory and disk metrics in Amazon CloudWatch involves installing and configuring the CloudWatch agent on your instances. Here's a step-by-step guide to help you achieve this:

Step 1: Prepare IAM Role

  1. Create an IAM Role:

    • Open the AWS Management Console and navigate to the IAM (Identity and Access Management) service.

    • Create a new IAM role with the necessary permissions for CloudWatch. Attach the "CloudWatchAgentServerPolicy" policy to the role.

Step 2: Install CloudWatch Agent on Your Auto Scaling Instances

  1. Connect to Your Instances:

    • SSH into your EC2 instances that are part of your Auto Scaling Group.
  2. Download and Install the CloudWatch Agent:

    • Download the CloudWatch agent on your instances:

        sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
  3. Configure the CloudWatch Agent:

    • Edit a configuration file sudo vi /opt/aws/amazon-cloudwatch-agent/bin/config.json for the CloudWatch agent. You can use a sample configuration or create a custom one. Example configuration for both memory and disk metrics:

    • (Make sure autoscaling group tag with Instance name)

          "agent": {
            "metrics_collection_interval": 60,
            "run_as_user": "root"
          "metrics": {
            "metrics_collected": {
              "mem": {
                "measurement": [
              "disk": {
                "measurement": [
                "resources": [
            "append_dimensions": {
              "AutoScalingGroupName": "${aws:AutoScalingGroupName}"
            "aggregation_dimensions": [
    • Save this configuration to a file.

  4. Start the CloudWatch Agent:

    • Start the CloudWatch agent with the configured file:

        sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a append-config -m ec2 -c file:/path/to/cloudwatch-config.json -s
        sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
  5. Check the logs of CloudWatch Agent:

    • If you encounter any issues during these steps, please check the CloudWatch Agent logs for more information:
    cat /opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log

Step 3: Verify Metrics in CloudWatch Console

  1. Navigate to CloudWatch:

    • Open the AWS Management Console and navigate to the CloudWatch service.
  2. View Metrics:

    • In the CloudWatch console, go to "Metrics" and select "CWAgent" namespace.

    • Look for metrics related to memory and disk usage, such as "mem_used_percent" and "disk_used_percent" under "AutoscalingGroup" Section.

By following these steps, you can monitor memory and disk metrics on your AWS Auto Scaling instances using Amazon CloudWatch. Adapt the configuration based on your specific use case and metrics of interest

Did you find this article valuable?

Support Rahul wath by becoming a sponsor. Any amount is appreciated!