Edit me

The Cloudwatch agent will run in your EC2 instances to collect metrics and send them to nOps.

This topic describes how to install Amazon CloudWatch for your AWS EC2 instances, EC2 instances that are EKS worker nodes, and then how to view the Memory Metrics through the nOps application.

  1. Install Amazon CloudWatch on EC2 Instances
  2. CloudWatch for EKS Managed EC2 Nodes (EKS Worker Nodes)
  3. How to view Memory and Usage Metrics
    1. To view metrics and usage

Install Amazon CloudWatch on EC2 Instances

To utilize the Resource Rightsizing tool to collect metrics for memory instances, install the Amazon CloudWatch agent.

nOps checks the average memory utilization for an Amazon EC2 instance over a two-week period and recommends an instance size that has at least the average memory utilization available. For example: If the current instance type has 8GB of memory available, and the average memory utilization is 700MB over a two-week period, the rightsizing recommendation will suggest an instance type that has 1GB of available memory.

How to install Amazon CloudWatch:

  1. Log in to the instance using SSH.

  2. Run the following commands at the console to download and install the Amazon CloudWatch agent:

    wget https://s3.amazonaws.com/amazoncloudwatch-agent/debian/amd64/latest/amazon-cloudwatch-agent.deb sudo dpkg -i -E ./amazon-cloudwatch-agent.deb

  3. Download and install the collectd daemon:

    sudo apt-get update && sudo apt-get install collectd

  4. Create the Amazon CloudWatch configuration file by running the Amazon CloudWatch configuration wizard:

    sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard

  5. Log in to the AWS IAM console and select the “Roles” menu item. Click the “Create role” button.

  6. On the “Select type of trusted entity” page, select “EC2” as the service to be associated with the new role. Click the “Next: Permissions” button to proceed.

  7. On the “Attach permissions policies” page, select the “CloudWatchAgentServerPolicy”. Click “Next: Tags” to proceed.

  8. On the “Add tags” page, add tags if required (optional). Click “Next: Review” to proceed.

  9. On the “Review” page, enter a name for the new role. Click “Create role” to proceed and create the new role.

  10. Once the role is created, click your username in the top right corner of the navigation bar and select “My Security Credentials” from the drop-down menu.

  11. On the “My security credentials” page, click the “Create access key” button.

  12. Note the new AWS access key ID and corresponding secret access key. You may want to save this to a file.

  13. Create an AWS credentials file with the AWS access key ID and shared access key at /home/bitnami/.aws/credentials with the following content. Replace the AWS-ACCESS-KEY-ID and AWS-SECRET-ACCESS-KEY placeholders with the keys obtained in the previous step:

    [default] aws_access_key_id=AWS-ACCESS-KEY-ID aws_secret_access_key=AWS-SECRET-ACCESS-KEY

  14. Edit the common configuration file for the Amazon CloudWatch agent at /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml and specify the path to the credentials file created in the previous step.

    sudo vi /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml

    Update the following content:

    [credentials] shared_credential_file = “/home/bitnami/.aws/credentials”

  15. Start the Amazon CloudWatch agent with the following command:

    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

  16. Check that the agent is running with the following command:

    sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status

The steps described above will also configure the Amazon CloudWatch agent to automatically start on server reboot.

Learn more through the AWS Help Article: Installing the CloudWatch Agent.

CloudWatch for EKS Managed EC2 Nodes (EKS Worker Nodes)

You can skip this section if:

  1. You don’t have any EKS worker nodes.

  2. The EKS worker nodes are already configured correctly with CloudWatch.

If you do have EKS managed EC2 nodes (EKS worker nodes), then you need to install the CloudWatch agent on EKS worker nodes using preBootstrapCommands in order to read Memory and Disk score data, otherwise the only information that will be available to you nOps will be CPU usage.

If the CloudWatch agent is not installed for EKS worker nodes, or is configured incorrectly, CloudWatch will not report any metrics for such worker nodes. If this happens, the nOps Rightsizing Recommendations will not be able to take into account the metrics that are only available through CloudWatch.

There is different set of instructions for configuring CloudWatch for EKS managed EC2 nodes (EKS worker nodes) compared to vanilla EC2 instances.

To learn how to configure/install CloudWatch agent for EKS worker nodes, see Install the CloudWatch agent on Amazon EKS worker nodes using preBootstrapCommands.

Follow the instructions in the AWS documentation provided in the link above. It will enable CloudWatch to log the data correctly. Only then nOps will be able to provide accurate recommendations.

How to view Memory and Usage Metrics

Once CloudWatch is installed and the nOps app begins to receive the data you will be able to view resource details including memory and usage metrics.

To view metrics and usage

  1. Log into the nOps application.

  2. From a User Dashboard click on the Reports menu and select Cloud Inventory from the drop-down.

  3. On the Cloud Inventory page, filter the results from the left pane by selecting AWS and search for EC2 instances using the Filters options.

  4. Click on an instance to see details.

  5. The Resource Details page contains 3 tabs including Resource Details, Cost History, and Config History.

  6. The Resource Details tab displays an EC2 Usage Graph that shows usage over 1 week, 2 weeks and 3 months.

  7. You can change the CPU Utilization drop-down to see other options including Memory Used.

  8. To see information about this resource on AWS, click the View Resource on AWS Console button. You will be required to log into the AWS console to do this.

Configure nOps Kubernetes Agent on EKS
Configure the Notification Center to get scheduled alerts
EventBridge Integration
Integrate DataDog with nOps Platform
JIRA Integration
PagerDuty Integration
Webhook Integration
Back to top       Home