Setting up CloudWatch with your Linux Instances on AWS

Document created by fadi.josef Expert on Jan 24, 2018Last modified by cud on Nov 7, 2018
Version 15Show Document
  • View in full screen mode

In this document, we will be looking at how we can setup CloudWatch for Linux. By following this document, you will be able to setup your Linux instance to publish Used Memory stats to CloudWatch and then Turbonomic will be able to collect the data. This document was created to cover deploying this on a large scale.


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



  • Requirements
  • Installing CloudWatch Agent 
  • Creating Parameter Store
  • Deploying CloudWatch Configuration file 


  • 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.
  • Access to AWS System Manager: AmazonEC2RoleforSSM Policy attached to your user
  • IAM Role for the Instance to run with AmazonSSMFullAccess
  • Access to CloudWatch service to confirm data collection
  • Your AWS Instance must have internet access or direct access to CloudWatch so the data can be pushed to CloudWatch


Permissions Required:

  • AmazonEC2ReadOnlyAccess
  • AmazonS3ReadOnlyAccess
  • AmazonRDSReadOnlyAccess
  • AmazonEC2RoleforSSM
  • CloudWatchFullAccess
  • AmazonSSMFullAccess


Installing CloudWatch Agent on your Linux Instances

  • Navigate to your EC2 section 
  • In the navigation pane, under Systems Manager Services, choose Run 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 end, you should see the status saying Success 

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}"




In addition, 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 we will need to create a parameter store so that we can store our configuration so then we can deploy it the configuration across multiple VMs

  • Navigate to your EC2 section 
  • In the navigation pane, choose Parameter Store
  • If you don't have any Parameter Store then you will see the Welcome Screen. Click on Get Started Now
  • Copy and paste the json agent configuration you created in the above step into the Value field (also attached below)

  • Under the Name field, you can enter anything but I chose CloudWatchLinux
  • Now click Create Parameter

Now you should see a message saying it has been created.

Once you click Close you should the Parameter created

Deploying CloudWatch Configuration File

  • In the navigation pane, choose Run Command.

  • Click on Run Command once the page loads up 

  • In the Command document list, choose AmazonCloudWatch-ManageAgent

  • In the Targets area, choose the instance or multiple instances on which you want to deploy CloudWatch Configuration on
  • Under Action select configure 
  • Under Mode leave it as ec2
  • Change the Optional Configuration Source to ssm
  • Under Optional Configuration Location enter the exact 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)
  • Now click on Run

In the end, you should see something like this. 



  • Eva Tuczai
  • Ben Yemini


4 people found this helpful