Setting up CloudWatch Memory Metrics on Linux Instances on AWS

Document created by fadi.josef Expert on Jan 24, 2018Last modified by jacob.bendavid on Jul 16, 2019
Version 33Show Document
  • View in full screen mode

Turbonomic leverages MemoryUsed reported into CloudWatch. This document covers configuring the AWS CloudWatch agent to capture Linux EC2 MemoryUsed stats in Turbonomic by leveraging AWS Systems Manager. 


If you are looking for the Windows version then you can find it here: Setting up CloudWatch for Windows


How-to Video:


  • AWS SSM Agent Installed on EC2
    • Linux image already has the SSM Agent installed. Linux SSM Agent is now installed by default on Amazon Linux AMIs dated 2017.09 and later. You would only need to manually install SSM Agent on other versions of Linux, as described in this article.
  • IAM Role with the following permissions: AmazonSSMFullAccess 

      Note: the least privilege permissions needed for the IAM role are AmazonEC2RoleforSSM (a custom policy to allow       the action "ssm:GetParameter" to the resource "arn:aws:ssm:*:*:parameter/*", see JSON example)


Attach IAM Role

To configure each Linux EC2 instance through System Manager you need to attach an IAM role with the above permissions to each EC2 instance.  

  • Select the EC2 instance and click on Actions>Instance Settings>Attach/Replace IAM role. Then select the IAM role with the required permissions and click apply (see example below).

Now you should see the role attached to the EC2 instance (see Turbo_CW below)


Note, if you need a scripted approach to add the IAM role to multiple instances, please contact Turbonomic Support. 


Installing CloudWatch Agent on your Linux Instances

  • Navigate to the 'System Manager' service under the account and region you'd like to configure  
  • In the navigation pane, choose Run Command and then click on Run a Command:

  • In the Command document list, choose AWS-ConfigureAWSPackage

  • In the Targets area, choose the instance or multiple instances on which to install the CloudWatch agent. If you do not see a specific instance, it might not be configured for Run Command.
  • In the Action list, choose Install.
  • In the Name field, type AmazonCloudWatchAgent
  • Leave Version set to latest to install the latest version of the agent.
  • Choose Run. In the next screen, you should see a confirmation message that the command was sent successfully and the status should be Success after few seconds

Create the Agent Configuration

The CW Agent will be configured to define which metric(s) are being sent to a CW Namespace, and other data required.  The following JSON represents the minimum requirements and cannot be changed.  By default, this configuration will store the metrics in the region in which the VM exists.

This will be used in the next step. 


      "agent": {

        "metrics_collection_interval": 60,

        "logfile": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log"


"metrics": {

    "metrics_collected": {

      "mem": {

        "measurement": [

          {"name": "used", "rename": "MemoryUsed"},

          {"name": "mem_available", "rename": "MemoryAvailable"}




    "append_dimensions": {

      "InstanceId": "${aws:InstanceId}"




Also, you can configure optional parameters of the CW Namespace (CWAgent is the default when not defined), and region (default region where data is located in the region where the instance runs).  Note adding more metrics to be collected will not be reflected in Turbonomic – only Used Memory will be collected at this time. Refer to AWS Documentation for more details.

Creating Parameter Store

Now you will need to create a parameter store for the above configuration so it can be deployed across multiple EC2 instances 

  • Navigate to the 'System Manager' service under the account and region you'd like to configure  
  • In the navigation pane, choose Parameter Store and then click Create Parameter

  • Copy and paste the JSON agent configuration you created in the above step into the Value field (leave all options at default)

  • Under the Name field, you can enter any name, but you must use the same name in the next step, for example, we used CloudWatchLinux
  • Now click Create Parameter -  you should see a message saying it has been created and the parameter listed

Deploying The CloudWatch Configuration File

  • In the 'System Manager' navigation pane, choose Run Command and then click on Run a Command
  • In the Command document list, choose AmazonCloudWatch-ManageAgent
  • Under Action select configure 
  • Under Mode leave it as ec2
  • Change the Optional Configuration Source to ssm
  • Under Optional Configuration Location enter the same name of the parameter you created in the Parameter Store (previous section). In this example, the parameter is called CloudWatchLinux
  • Optional Restart should be set to Yes (This will restart the CloudWatch agent, not the instance)

  • In the Targets area, choose the instance or multiple instances on which you want to deploy CloudWatch Configuration on

  • Now click on Run - In the end, you should see something like this. 


Installation Complete!

To confirm that the instance is sending the Memory Metrics, head to the CloudWatch page, click on Metrics and locate the CWAgent  namespace (only be created if the process worked successfully), click on InstanceId > there should be 2 Metrics per Linux instance, click on 'MemeoryUsed' and confirm data is collected:

Please note it can take up to 30 minutes in some cases for Memory metric to show up in the Turbonomic user interface.


  • Eva Tuczai
  • Ben Yemini
  • Jacob Ben-David


4 people found this helpful