Skip to main content

CloudWatch agent installation guide

Updated over a week ago

Overview

PointFive identifies cost optimization opportunities by analyzing AWS resource utilization metrics. CloudWatch Agent provides the essential Memory usage data required for accurate opportunity detection and optimization recommendations.


High-Level Integration Flow


Why CloudWatch Agent is Required

Without CloudWatch Agent

With CloudWatch Agent

Limited visibility into resource usage

Complete visibility into CPU utilization

Cannot identify underutilized resources

Identifies inactive and underutilized instances

Basic cost reporting only

Data-driven optimization recommendations

Example Opportunities Enabled by CPU Metrics

Opportunity

Description

Inactive EC2 Instance

Detects EC2 instances with consistently low CPU usage

Underutilized EC2 Instance

Identifies EC2 instances with low CPU utilization that can be downsized

CloudWatch Agent Cost Breakdown

This section details all AWS costs associated with CloudWatch Agent installation and operation. Bear in mind that you might be already using custom metrics, and therefore the cost implication will be different (or even zero)

CloudWatch Custom Metrics

Tiers

Cost (metric/month)

First 10,000 metrics

$0.30

Next 240,000 metrics

$0.10

Next 750,000 metrics

$0.05

Over 1,000,000 metrics

$0.02

Memory-only configuration cost per instance: 1 metric × $0.30 = $0.30/instance/month

Example fleet costs (memory-only):

Fleet Size

Monthly Cost

10 instances

$3.00

50 instances

$15.00

100 instances

$30.00

500 instances

$150.00

1,000 instances

$300.00

SSM Parameter Store

Tier

Storage

API Calls

Notes

Standard (Free)

10,000 parameters

10,000 ops/month free

Sufficient for this setup

Advanced

$0.05/parameter/month

$0.05 per 10,000 ops

Not needed for config storage

This guide uses: 1 Standard parameter = $0.00/month

Systems Manager (SSM)

All SSM services used in this guide (Distributor, Fleet Manager, Run Command, Maintenance Windows, etc.) are free with no additional charges.

SSM Operations: $0.00/month


Total Cost Summary

Cost Per Instance

  • CloudWatch Custom Metrics: $0.30/month

  • SSM Parameter Store: $0.00/month

  • SSM Operations: $0.00/month

Total per instance: $0.30/month

Total Fleet Costs

Fleet Size

Monthly Cost

Annual Cost

10 instances

$3.00

$36.00

50 instances

$15.00

$180.00

100 instances

$30.00

$360.00

500 instances

$150.00

$1,800.00

1,000 instances

$300.00

$3,600.00


Reference:

AWS CloudWatch Agent Installation Guide

Purpose: Install and configure CloudWatch Agent on existing EC2 instances and Auto Scaling Groups to collect memory metrics.

Target Audience: AWS administrators and DevOps engineers

Estimated Time:

  • EC2 installation: 15-20 minutes

  • ASG installation: 30-40 minutes


Prerequisites

Required IAM Permissions

Your EC2 instances must have an IAM role with the following AWS managed policies:

  • CloudWatchAgentServerPolicy - Allows sending metrics to CloudWatch

  • AmazonSSMManagedInstanceCore - Allows Systems Manager operations

Create IAM Role (If Not Already Configured)

  1. Go to IAM ConsoleRolesCreate role

  2. Select AWS serviceEC2Next

  3. Attach policies:

    • CloudWatchAgentServerPolicy

    • AmazonSSMManagedInstanceCore

  4. Name: CloudWatchAgent-EC2-Role

  5. Attach this role to your EC2 instances:

    • EC2 Console → Select instance → ActionsSecurityModify IAM role

Verify Systems Manager Access

Ensure your instances appear in Systems ManagerFleet Manager:

  • Status should be “Online”

  • If missing, verify IAM role is attached and SSM agent is running


Configuration Setup

Create Memory Metrics Configuration

This configuration collects only memory utilization metrics to minimize costs.

  1. Go to Systems Manager ConsoleParameter Store

  2. Click Create parameter

  3. Configure:

    • Name: /cloudwatch-agent/config/memory-only

    • Type: String

    • Value: Copy the JSON below

{
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "root"
},
"metrics": {
"namespace": "CWAgent",
"metrics_collected": {
"mem": {
"measurement": [
{
"name": "mem_used_percent",
"unit": "Percent"
}
],
"metrics_collection_interval": 60
}
}
}
}
  1. Click Create parameter

What this configures:

  • Collects memory utilization percentage every 60 seconds

  • Publishes to CloudWatch namespace CWAgent

  • Metric name: MemoryUtilization


EC2 Installation Guide

For installing CloudWatch Agent on existing EC2 instances.

Method 1: One-Time Installation (Recommended for Small Fleets)

When to use: Installing on specific instances immediately.

Overview: Installation is a two-step process:

  1. Install the CloudWatch Agent software (the program itself)

  2. Configure the agent (tell it what metrics to collect from where)

Both steps are required and must be done in order.

Step 1: Install CloudWatch Agent Package

This installs the CloudWatch Agent software on your instances.

  1. Go to Systems ManagerDistributor

  2. Click AmazonCloudWatchAgent

  3. Click Install on a schedule

  4. Configure:

    Name: Install-CloudWatch-Agent-EC2

    Installation configuration:

    • Installation type: Uninstall and reinstall

    • Action: Install

    Specify targets:

    • Target selection: Choose instances manually (or specify by tags)

    • Select your EC2 instances

    • Click Add

    Schedule:

    • No schedule (executes immediately)

    Rate control:

    • Leave defaults

  5. Click Create Association

Step 2: Configure CloudWatch Agent

This tells the agent what metrics to collect and where to send them. It applies the memory-only configuration you created in Parameter Store.

  1. Go to Systems ManagerRun Command

  2. Click Run command

  3. Select document: AmazonCloudWatch-ManageAgent

  4. Configure parameters:

    • Action: configure

    • Mode: ec2

    • Optional Configuration Source: ssm

    • Optional Configuration Location: /cloudwatch-agent/config/memory-only

    • Optional Restart: yes

  5. Targets: Select the same instances

  6. Click Run

Result: CloudWatch Agent is installed and configured. Metrics will appear in CloudWatch within 2-3 minutes.


Method 2: Scheduled Installation via Maintenance Windows

When to use: Regular updates, compliance checks, or managing large fleets.

Step 1: Create Maintenance Window

  1. Go to Systems ManagerMaintenance Windows

  2. Click Create maintenance window

  3. Configure:

    • Name: CloudWatchAgent-Installation-Window

    • Description: Installs and configures CloudWatch Agent

    • Unregistered targets: ✅ Check “Allow unregistered targets”

    • Schedule: rate(7 days) or your preferred schedule

    • Duration: 1 hour

  4. Click Create maintenance window

Step 2: Register Target Instances

  1. Select your maintenance window (checkbox)

  2. Click ActionsRegister targets

  3. Configure:

    • Target name: EC2-Instances

    • Target selection: Specifying tags

    • Tag key: Choose a tag that identifies your instances (e.g., Environment)

    • Tag value: The tag value (e.g., Production)

    • Click Add

  4. Click Register target

Step 3: Register Installation Task

  1. Select your maintenance window (checkbox)

  2. Click ActionsRegister Run command task

  3. Configure:

    Task details:

    • Name: Install-CloudWatch-Agent

    • Description: Installs CloudWatch Agent package

    Command document: AWS-ConfigureAWSPackage

    Task priority: 1

    Targets: Select the registered target group

    Parameters:

    • Action: Install

    • Installation Type: Uninstall and reinstall

    • Name: AmazonCloudWatchAgent

    Rate control:

    • Concurrency: 1 targets

    • Error threshold: 1 errors

    IAM service role: Leave auto-selected (blank)

  4. Click Register Run command task

Step 4: Register Configuration Task

  1. Select your maintenance window (checkbox)

  2. Click ActionsRegister Run command task

  3. Configure:

    Task details:

    • Name: Configure-CloudWatch-Agent

    • Description: Configures CloudWatch Agent

    Command document: AmazonCloudWatch-ManageAgent

    Task priority: 2 (runs after installation)

    Targets: Select the registered target group

    Parameters:

    • Action: configure

    • Mode: ec2

    • Optional Configuration Source: ssm

    • Optional Configuration Location: /cloudwatch-agent/config/memory-only

    • Optional Restart: yes

    Rate control:

    • Concurrency: 1 targets

    • Error threshold: 1 errors

  4. Click Register Run command task

Result: CloudWatch Agent will be installed/updated automatically according to your schedule.


Auto Scaling Group Installation Guide

For automatically installing CloudWatch Agent on all ASG instances, including newly launched ones.

Overview

Auto Scaling Groups present a unique challenge: new instances can launch at any time. Using Maintenance Windows with tag-based targeting ensures automatic installation.

Step 1: Tag Your ASG Instances

Ensure your ASG is configured to tag instances:

  1. Go to EC2Auto Scaling Groups

  2. Select your ASG → Details tab

  3. Scroll to Tags

  4. Add tag (if not present):

    • Key: ASG

    • Value: CloudWatchAgent

    • Tag new instances: Enabled

Step 2: Create Maintenance Window

Follow the same process as EC2 Method 2, Step 1:

  1. Systems ManagerMaintenance WindowsCreate maintenance window

  2. Configure:

    • Name: CloudWatchAgent-ASG-Installation

    • Unregistered targets: ✅ Must be checked (critical for ASG)

    • Schedule: rate(30 minutes) (frequent checks for new instances)

    • Duration: 1 hour

Why frequent schedule?: New ASG instances will get the agent installed within 30 minutes of launch.

Step 3: Register ASG Instances as Targets

  1. Select maintenance window → ActionsRegister targets

  2. Configure:

    • Target name: ASG-Instances

    • Target selection: Specifying tags

    • Tag key: ASG

    • Tag value: CloudWatchAgent

    • Click Add

  3. Click Register target

Step 4: Register Installation Task

Same as EC2 Method 2, Step 3:

  1. Select window → ActionsRegister Run command task

  2. Command document: AWS-ConfigureAWSPackage

  3. Priority: 1

  4. Parameters:

    • Action: Install

    • Installation Type: Uninstall and reinstall

    • Name: AmazonCloudWatchAgent

  5. Targets: Select ASG target group

  6. Rate control: Concurrency 1, Error threshold 1

Step 5: Register Configuration Task

Same as EC2 Method 2, Step 4:

  1. Select window → ActionsRegister Run command task

  2. Command document: AmazonCloudWatch-ManageAgent

  3. Priority: 2

  4. Parameters:

    • Action: configure

    • Mode: ec2

    • Optional Configuration Source: ssm

    • Optional Configuration Location: /cloudwatch-agent/config/memory-only

    • Optional Restart: yes

  5. Targets: Select ASG target group


Verification

Check CloudWatch Metrics

  1. Go to CloudWatch ConsoleMetricsAll metrics

  2. Under “Custom namespaces”, find CWAgent

  3. Click CWAgentInstanceId

  4. You should see all instances with mem_used_percent metric

  5. Select instances to view graphs

Timeline: First metrics appear 2-3 minutes after agent configuration.

Additional Resources

AWS Documentation

Did this answer your question?