Lesson 5-AWS SysOps Administrator Associate

Unified CloudWatch Agent

Learn to deploy and configure the Unified CloudWatch Agent for collecting system metrics, logs, and monitoring individual processes.

14 Topics
5 Quiz Questions
65 XP Reward

What You'll Learn

1

Introduction to the Unified CloudWatch Agent

The Unified CloudWatch Agent is a powerful tool that runs on your EC2 instances (and on-premises servers) to collect system-level metrics that AWS doesn't provide by default, like RAM usage and disk space. It can also collect logs from your applications and send them to CloudWatch Logs. Without an agent, no logs from inside your EC2 instance will be sent to CloudWatch Logs.

Key Point

The Unified CloudWatch Agent enables collection of system metrics (RAM, disk) and application logs that AWS doesn't provide automatically.

Vocabulary

Key Terms

|

A single agent that collects both system-level metrics and logs from EC2 instances and on-premises servers

|

The default namespace in CloudWatch where metrics collected by the Unified CloudWatch Agent are stored

|

AWS service for storing configuration data, used to centrally manage CloudWatch Agent configurations

Unified CloudWatch Agent Architecture

How the agent works across different environments

CloudWatch

Receives metrics and logs

EC2 Instance

With Unified CW Agent

Data Types

Metrics + Logs

On-Premises Server

With Unified CW Agent

What the Unified CloudWatch Agent Collects

  • Memory (RAM) utilization and available memory
  • Disk space utilization across all mounted volumes
  • Swap space usage
  • CPU metrics at a more granular level
  • Network interface statistics
  • Process-level metrics (via procstat plugin)
  • Application and system logs

Installing and Configuring the Agent

1

Install the Agent

Download and install the Unified CloudWatch Agent using SSM Run Command, manually via the command line, or through your configuration management tool.

2

Create Configuration

Use the agent configuration wizard or create a JSON configuration file specifying which metrics and logs to collect.

3

Store in Parameter Store

Optionally store the configuration in SSM Parameter Store for centralized management across multiple instances.

4

Configure IAM Permissions

Ensure the EC2 instance role has CloudWatchAgentServerPolicy or equivalent permissions for pushing metrics and logs.

5

Start the Agent

Start the agent service, referencing the configuration from Parameter Store or a local file.

IAM Permissions Required

The EC2 instance role must have proper IAM permissions for the agent to work: • CloudWatchAgentServerPolicy (AWS managed policy) or • Custom policy with cloudwatch:PutMetricData and logs:PutLogEvents permissions

Default Namespace

The default namespace for metrics collected by the Unified CloudWatch Agent is 'CWAgent'. You can customize this in the agent configuration if needed. Look for metrics under this namespace in the CloudWatch console.

8

The procstat Plugin

The procstat plugin is a powerful feature of the Unified CloudWatch Agent that lets you monitor individual processes. You can track how much CPU time and memory specific processes are using. This is invaluable for debugging application performance issues or ensuring critical processes are running within expected parameters.

Key Point

The procstat plugin enables monitoring of individual process metrics like CPU and memory usage.

Comparison

Process Selection Methods for procstat

MethodDescriptionExample
pid_fileBy PID file pathSelect process by its PID file/var/run/nginx.pid
exeBy executable nameRegEx match on process name"exe": "nginx"
patternBy command lineRegEx match on command line"pattern": "config.*/myapp"

You can use any combination of these methods to select which processes to monitor

procstat Metrics Examples

  • procstat_cpu_time: Total CPU time used by the process
  • procstat_cpu_usage: CPU usage percentage
  • procstat_memory_rss: Resident Set Size (physical memory)
  • procstat_memory_vms: Virtual Memory Size
  • procstat_read_bytes: Bytes read by the process
  • procstat_write_bytes: Bytes written by the process

Metric Prefix

All metrics collected by the procstat plugin begin with the 'procstat' prefix, making them easy to identify and filter in CloudWatch. For example: procstat_cpu_time, procstat_cpu_usage, procstat_memory_rss.

procstat Configuration Example

Problem

You need to monitor CPU and memory usage for your Nginx web server process

Solution

{ "procstat": [ { "exe": "nginx", "measurement": [ "cpu_time", "cpu_usage", "memory_rss" ] } ] }

Why This Works

This configuration uses the 'exe' method to find all processes with 'nginx' in the name and collects CPU time, CPU usage percentage, and resident memory metrics for them.

Comparison

CloudWatch Agent: Supports Both Linux and Windows

PlatformInstallationConfiguration
LinuxRPM, DEB, or SSMJSON config fileSame metrics available
WindowsMSI installer or SSMJSON config fileSame metrics available

The Unified CloudWatch Agent works consistently across Linux and Windows servers

Reflection

Pause & Ponder

How would you use the Unified CloudWatch Agent to monitor a microservices architecture?

  • Consider which system metrics are most important for each service type
  • Think about how procstat could help identify resource-hungry processes
  • How would you centralize configuration management across many instances?

Ready to Start Learning?

Dive deeper into this lesson with our interactive learning experience. Complete the quiz and earn 65 XP!

Start This Lesson

Continue Your Journey