Setting up RAM monitoring on AWS - mtholyoke/JupyterHub-on-AWS GitHub Wiki

AWS has CPU usage graphs by default, but does not automatically provide RAM usage graphs. To monitor RAM, CloudWatch Agent must be installed on the instance.

One-time setup - create the IAM role

You must create an IAM role to use with CloudWatch Agent. This only needs to be done once for the organization - once it exists, it can be attached to multiple instances.

Adding RAM monitoring to an existing instance

  1. Starting at step 7 (we already have an instance), follow these directions to attach the IAM role to the instance.

Install CloudWatchAgent

  1. On the left bar in the EC2 console, click on Instances and select the EC2 Instance with the CloudWatchAgentServerRole IAM role.
  2. ssh to the EC2 instance
  3. Follow the instructions to find the appropriate download link (ARM64 Ubuntu) and directions for installation.
  4. Essentially:
    wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/arm64/latest/amazon-cloudwatch-agent.deb
    sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
    
  5. Perform step 5 in these instructions to configure the CloudWatch Agent. Use the answers given in the article - for any questions that aren't in the article, pick the default.

Start the CloudWatch Agent

  1. Start the CloudWatch Agent:
    sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s
    

View the graphs

You're done! It does take a few minutes to get to the AWS console, so if you don't see anything immediately, don't panic.

  1. On the Amazon CloudWatch console page, select "All Metrics".
  2. Click CWAgent
  3. Click ImageID,InstanceID,InstanceType
  4. Select the Instance from the list below