{"id":2275,"date":"2026-04-25T11:12:26","date_gmt":"2026-04-25T11:12:26","guid":{"rendered":"https:\/\/sreschool.com\/blog\/?p=2275"},"modified":"2026-04-27T11:12:59","modified_gmt":"2026-04-27T11:12:59","slug":"complete-tutorial-guide-aws-cloudwatch-agent","status":"publish","type":"post","link":"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/","title":{"rendered":"Complete Tutorial Guide: AWS CloudWatch Agent"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. What is AWS CloudWatch Agent?<\/h2>\n\n\n\n<p><strong>AWS CloudWatch Agent<\/strong> is a software agent installed on servers or compute environments to collect telemetry and send it to Amazon CloudWatch.<\/p>\n\n\n\n<p>It can collect:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Telemetry<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td>Metrics<\/td><td>CPU, memory, disk, network, process metrics<\/td><\/tr><tr><td>Logs<\/td><td>Application logs, system logs, web server logs<\/td><\/tr><tr><td>Traces<\/td><td>Application traces using OpenTelemetry or X-Ray-compatible tracing<\/td><\/tr><tr><td>Custom metrics<\/td><td>Business or application-level metrics<\/td><\/tr><tr><td>StatsD metrics<\/td><td>Metrics from apps using StatsD<\/td><\/tr><tr><td>collectd metrics<\/td><td>Metrics from collectd plugins<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>AWS describes the CloudWatch Agent as a software component that collects <strong>metrics, logs, and traces<\/strong> from EC2 instances, on-premises servers, and containerized applications.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">2. Why Do We Need CloudWatch Agent?<\/h1>\n\n\n\n<p>Some AWS metrics are available automatically. For example, EC2 sends CPU and network metrics to CloudWatch by default.<\/p>\n\n\n\n<p>But some important metrics are <strong>not available by default<\/strong>, such as:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Metric<\/th><th>Available by Default?<\/th><th>Needs CloudWatch Agent?<\/th><\/tr><\/thead><tbody><tr><td>EC2 CPU utilization<\/td><td>Yes<\/td><td>No<\/td><\/tr><tr><td>EC2 network in\/out<\/td><td>Yes<\/td><td>No<\/td><\/tr><tr><td>EC2 disk read\/write<\/td><td>Yes<\/td><td>No<\/td><\/tr><tr><td>EC2 memory usage<\/td><td>No<\/td><td>Yes<\/td><\/tr><tr><td>EC2 disk space usage<\/td><td>No<\/td><td>Yes<\/td><\/tr><tr><td>Application log files<\/td><td>No<\/td><td>Yes<\/td><\/tr><tr><td>Custom app metrics<\/td><td>No<\/td><td>Yes<\/td><\/tr><tr><td>Process-level metrics<\/td><td>No<\/td><td>Yes<\/td><\/tr><tr><td>On-prem server metrics<\/td><td>No<\/td><td>Yes<\/td><\/tr><tr><td>OpenTelemetry traces<\/td><td>No<\/td><td>Yes \/ collector setup<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>So, CloudWatch Agent is mainly used when you want <strong>deeper visibility inside the operating system and application<\/strong>, not just AWS infrastructure-level metrics.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">3. CloudWatch Agent Capabilities<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">3.1 Collect System Metrics<\/h2>\n\n\n\n<p>CloudWatch Agent can collect server-level metrics such as:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Category<\/th><th>Example Metrics<\/th><\/tr><\/thead><tbody><tr><td>CPU<\/td><td>cpu_usage_idle, cpu_usage_user, cpu_usage_system<\/td><\/tr><tr><td>Memory<\/td><td>mem_used_percent, mem_available<\/td><\/tr><tr><td>Disk<\/td><td>disk_used_percent, disk_free<\/td><\/tr><tr><td>Disk I\/O<\/td><td>reads, writes, read bytes, write bytes<\/td><\/tr><tr><td>Network<\/td><td>bytes sent, bytes received, packets<\/td><\/tr><tr><td>Swap<\/td><td>swap_used_percent<\/td><\/tr><tr><td>Processes<\/td><td>process count, process CPU, process memory<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This is very important for EC2 monitoring because EC2 does not automatically provide memory and disk space metrics.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3.2 Collect Logs<\/h2>\n\n\n\n<p>CloudWatch Agent can collect log files and send them to CloudWatch Logs.<\/p>\n\n\n\n<p>Examples:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Source<\/th><th>Example Log Path<\/th><\/tr><\/thead><tbody><tr><td>Linux system log<\/td><td><code>\/var\/log\/messages<\/code><\/td><\/tr><tr><td>Ubuntu system log<\/td><td><code>\/var\/log\/syslog<\/code><\/td><\/tr><tr><td>Application log<\/td><td><code>\/opt\/app\/logs\/app.log<\/code><\/td><\/tr><tr><td>Nginx access log<\/td><td><code>\/var\/log\/nginx\/access.log<\/code><\/td><\/tr><tr><td>Nginx error log<\/td><td><code>\/var\/log\/nginx\/error.log<\/code><\/td><\/tr><tr><td>Apache logs<\/td><td><code>\/var\/log\/httpd\/access_log<\/code><\/td><\/tr><tr><td>Windows Event Logs<\/td><td>Application, System, Security<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3.3 Collect Custom Metrics<\/h2>\n\n\n\n<p>You can configure the agent to collect custom metrics from:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>StatsD<\/li>\n\n\n\n<li>collectd<\/li>\n\n\n\n<li>procstat<\/li>\n\n\n\n<li>application metric sources<\/li>\n\n\n\n<li>OpenTelemetry metrics<\/li>\n<\/ul>\n\n\n\n<p>Example custom metric use cases:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Number of active users<\/li>\n\n\n\n<li>Queue processing delay<\/li>\n\n\n\n<li>Payment failures<\/li>\n\n\n\n<li>Background job success count<\/li>\n\n\n\n<li>Number of running app workers<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3.4 Collect Traces<\/h2>\n\n\n\n<p>CloudWatch Agent can receive traces from applications using <strong>OpenTelemetry Protocol \/ OTLP<\/strong> and send them to AWS observability services.<\/p>\n\n\n\n<p>This helps with distributed tracing, especially for microservices.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3.5 Support Multiple Environments<\/h2>\n\n\n\n<p>CloudWatch Agent can run on:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Environment<\/th><th>Supported?<\/th><\/tr><\/thead><tbody><tr><td>Amazon EC2 Linux<\/td><td>Yes<\/td><\/tr><tr><td>Amazon EC2 Windows<\/td><td>Yes<\/td><\/tr><tr><td>On-premises Linux servers<\/td><td>Yes<\/td><\/tr><tr><td>On-premises Windows servers<\/td><td>Yes<\/td><\/tr><tr><td>Containerized workloads<\/td><td>Yes<\/td><\/tr><tr><td>Hybrid environments<\/td><td>Yes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">4. High-Level Architecture<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>EC2 \/ Server \/ Container\n        |\n        | CloudWatch Agent\n        v\nAmazon CloudWatch\n        |\n        |-- Metrics\n        |-- Logs\n        |-- Traces\n        |-- Alarms\n        |-- Dashboards\n<\/code><\/pre>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Linux EC2 Instance\n  \u251c\u2500\u2500 CPU metrics\n  \u251c\u2500\u2500 Memory metrics\n  \u251c\u2500\u2500 Disk metrics\n  \u251c\u2500\u2500 \/var\/log\/messages\n  \u251c\u2500\u2500 \/var\/log\/nginx\/access.log\n  \u2514\u2500\u2500 Application logs\n        |\n        v\nCloudWatch Agent\n        |\n        v\nCloudWatch Metrics + CloudWatch Logs\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">5. Prerequisites Before Installing CloudWatch Agent<\/h1>\n\n\n\n<p>Before installation, check these items.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5.1 EC2 Instance Must Exist<\/h2>\n\n\n\n<p>You need an EC2 instance, preferably Linux or Windows.<\/p>\n\n\n\n<p>For beginner labs, use Amazon Linux 2, Amazon Linux 2023, Ubuntu, or Windows Server.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5.2 IAM Role Is Required<\/h2>\n\n\n\n<p>The EC2 instance needs an IAM role with permission to send data to CloudWatch.<\/p>\n\n\n\n<p>Attach this AWS managed policy to the EC2 instance role:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CloudWatchAgentServerPolicy\n<\/code><\/pre>\n\n\n\n<p>If you are creating or storing configuration in Systems Manager Parameter Store, you may also need:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CloudWatchAgentAdminPolicy\n<\/code><\/pre>\n\n\n\n<p>For most beginner labs, use:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Use Case<\/th><th>IAM Policy<\/th><\/tr><\/thead><tbody><tr><td>Agent sends metrics\/logs to CloudWatch<\/td><td>CloudWatchAgentServerPolicy<\/td><\/tr><tr><td>Admin creates\/stores agent config<\/td><td>CloudWatchAgentAdminPolicy<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5.3 Systems Manager Agent Recommended<\/h2>\n\n\n\n<p>For console-based installation, the EC2 instance should be managed by <strong>AWS Systems Manager<\/strong>.<\/p>\n\n\n\n<p>That means:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SSM Agent is installed.<\/li>\n\n\n\n<li>Instance has an IAM role allowing Systems Manager access.<\/li>\n\n\n\n<li>Instance can reach Systems Manager endpoints.<\/li>\n\n\n\n<li>Instance appears under Systems Manager managed nodes.<\/li>\n<\/ul>\n\n\n\n<p>For Amazon Linux and many Windows AMIs, SSM Agent is often already installed.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5.4 Network Access<\/h2>\n\n\n\n<p>The instance must be able to reach:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CloudWatch<\/li>\n\n\n\n<li>CloudWatch Logs<\/li>\n\n\n\n<li>Systems Manager, if using SSM<\/li>\n\n\n\n<li>Parameter Store, if storing config there<\/li>\n<\/ul>\n\n\n\n<p>This can be through:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Public internet<\/li>\n\n\n\n<li>NAT Gateway<\/li>\n\n\n\n<li>VPC endpoints<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">6. Installation Methods<\/h1>\n\n\n\n<p>There are two common ways to install CloudWatch Agent:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Method<\/th><th>Best For<\/th><\/tr><\/thead><tbody><tr><td>AWS Systems Manager console<\/td><td>Console-only labs and managed EC2<\/td><\/tr><tr><td>Manual server installation<\/td><td>When you have SSH\/RDP access<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Since your students have <strong>AWS Console access only<\/strong>, the best method is:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Install CloudWatch Agent using AWS Systems Manager Run Command from the AWS Console.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">7. Step-by-Step: Install CloudWatch Agent Using AWS Console<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Goal<\/h2>\n\n\n\n<p>Install CloudWatch Agent on an EC2 instance without using CLI or SSH.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Attach IAM Role to EC2<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <strong>AWS Console<\/strong>.<\/li>\n\n\n\n<li>Go to <strong>EC2<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Instances<\/strong>.<\/li>\n\n\n\n<li>Select the target EC2 instance.<\/li>\n\n\n\n<li>Click <strong>Actions<\/strong>.<\/li>\n\n\n\n<li>Choose <strong>Security<\/strong>.<\/li>\n\n\n\n<li>Choose <strong>Modify IAM role<\/strong>.<\/li>\n\n\n\n<li>Attach an IAM role that has:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>CloudWatchAgentServerPolicy\nAmazonSSMManagedInstanceCore\n<\/code><\/pre>\n\n\n\n<p>If no role exists, your instructor or admin must create one.<\/p>\n\n\n\n<p>Required policies:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Policy<\/th><th>Purpose<\/th><\/tr><\/thead><tbody><tr><td>AmazonSSMManagedInstanceCore<\/td><td>Allows Systems Manager to manage the instance<\/td><\/tr><tr><td>CloudWatchAgentServerPolicy<\/td><td>Allows CloudWatch Agent to publish metrics and logs<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Confirm Instance Appears in Systems Manager<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <strong>AWS Systems Manager<\/strong>.<\/li>\n\n\n\n<li>In the left menu, go to <strong>Node Management<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Fleet Manager<\/strong> or <strong>Managed Nodes<\/strong>.<\/li>\n\n\n\n<li>Confirm your EC2 instance appears.<\/li>\n<\/ol>\n\n\n\n<p>If the instance does not appear:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>IAM role may be missing.<\/li>\n\n\n\n<li>SSM Agent may not be installed.<\/li>\n\n\n\n<li>Network access may be blocked.<\/li>\n\n\n\n<li>Wrong AWS Region may be selected.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Use Run Command to Install Agent<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <strong>AWS Systems Manager<\/strong>.<\/li>\n\n\n\n<li>Go to <strong>Run Command<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Run command<\/strong>.<\/li>\n\n\n\n<li>In <strong>Command document<\/strong>, search for:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>AWS-ConfigureAWSPackage\n<\/code><\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>Select <strong>AWS-ConfigureAWSPackage<\/strong>.<\/li>\n\n\n\n<li>In <strong>Command parameters<\/strong>, set:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Field<\/th><th>Value<\/th><\/tr><\/thead><tbody><tr><td>Action<\/td><td>Install<\/td><\/tr><tr><td>Name<\/td><td>AmazonCloudWatchAgent<\/td><\/tr><tr><td>Version<\/td><td>latest<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ol start=\"7\" class=\"wp-block-list\">\n<li>In <strong>Targets<\/strong>, select your EC2 instance.<\/li>\n\n\n\n<li>Scroll down.<\/li>\n\n\n\n<li>Click <strong>Run<\/strong>.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Verify Installation<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Stay on the Run Command result page.<\/li>\n\n\n\n<li>Wait for command status to become:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>Success\n<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>If it fails, click the command output and check the error.<\/li>\n<\/ol>\n\n\n\n<p>Common failure reasons:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Error Type<\/th><th>Possible Cause<\/th><\/tr><\/thead><tbody><tr><td>Instance not listed<\/td><td>Not managed by Systems Manager<\/td><\/tr><tr><td>Access denied<\/td><td>IAM role missing permissions<\/td><\/tr><tr><td>Timeout<\/td><td>Network issue<\/td><\/tr><tr><td>Package failure<\/td><td>OS\/package issue<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">8. Configure CloudWatch Agent<\/h1>\n\n\n\n<p>Installing the agent is not enough. You must configure what it should collect.<\/p>\n\n\n\n<p>The CloudWatch Agent configuration is a <strong>JSON file<\/strong> that defines:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Which metrics to collect<\/li>\n\n\n\n<li>Which logs to collect<\/li>\n\n\n\n<li>Which traces to collect<\/li>\n\n\n\n<li>Collection interval<\/li>\n\n\n\n<li>Log group names<\/li>\n\n\n\n<li>Metric namespace<\/li>\n\n\n\n<li>Dimensions such as InstanceId<\/li>\n<\/ul>\n\n\n\n<p>AWS documentation states that before running the agent, you must create one or more configuration files, and the file specifies metrics, logs, and traces to collect.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">9. Step-by-Step: Create Agent Configuration Using Console and Wizard<\/h1>\n\n\n\n<p>There are several ways to create the configuration. For beginner training, the easiest is:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Use the CloudWatch Agent configuration wizard through Systems Manager or create a simple JSON configuration manually.<\/p>\n<\/blockquote>\n\n\n\n<p>Since you asked for a complete guide, below is a beginner-friendly configuration example.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">10. Simple Linux CloudWatch Agent Configuration<\/h1>\n\n\n\n<p>This example collects:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CPU<\/li>\n\n\n\n<li>Memory<\/li>\n\n\n\n<li>Disk usage<\/li>\n\n\n\n<li>Swap<\/li>\n\n\n\n<li>System log<\/li>\n\n\n\n<li>Application log<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"agent\": {\n    \"metrics_collection_interval\": 60,\n    \"run_as_user\": \"root\"\n  },\n  \"metrics\": {\n    \"namespace\": \"CWAgent\",\n    \"append_dimensions\": {\n      \"InstanceId\": \"${aws:InstanceId}\",\n      \"InstanceType\": \"${aws:InstanceType}\",\n      \"AutoScalingGroupName\": \"${aws:AutoScalingGroupName}\"\n    },\n    \"metrics_collected\": {\n      \"cpu\": {\n        \"measurement\": &#91;\n          \"cpu_usage_idle\",\n          \"cpu_usage_user\",\n          \"cpu_usage_system\"\n        ],\n        \"metrics_collection_interval\": 60,\n        \"totalcpu\": true\n      },\n      \"mem\": {\n        \"measurement\": &#91;\n          \"mem_used_percent\",\n          \"mem_available\"\n        ],\n        \"metrics_collection_interval\": 60\n      },\n      \"disk\": {\n        \"measurement\": &#91;\n          \"used_percent\",\n          \"free\"\n        ],\n        \"metrics_collection_interval\": 60,\n        \"resources\": &#91;\n          \"*\"\n        ]\n      },\n      \"swap\": {\n        \"measurement\": &#91;\n          \"swap_used_percent\"\n        ],\n        \"metrics_collection_interval\": 60\n      }\n    }\n  },\n  \"logs\": {\n    \"logs_collected\": {\n      \"files\": {\n        \"collect_list\": &#91;\n          {\n            \"file_path\": \"\/var\/log\/messages\",\n            \"log_group_name\": \"\/aws\/ec2\/system\/messages\",\n            \"log_stream_name\": \"{instance_id}\"\n          },\n          {\n            \"file_path\": \"\/var\/log\/cloud-init.log\",\n            \"log_group_name\": \"\/aws\/ec2\/system\/cloud-init\",\n            \"log_stream_name\": \"{instance_id}\"\n          }\n        ]\n      }\n    }\n  }\n}\n<\/code><\/pre>\n\n\n\n<p>For Ubuntu, replace:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/var\/log\/messages\n<\/code><\/pre>\n\n\n\n<p>with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/var\/log\/syslog\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">11. Simple Windows CloudWatch Agent Configuration<\/h1>\n\n\n\n<p>This example collects:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CPU<\/li>\n\n\n\n<li>Memory<\/li>\n\n\n\n<li>Logical disk usage<\/li>\n\n\n\n<li>Windows System Event Log<\/li>\n\n\n\n<li>Windows Application Event Log<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"agent\": {\n    \"metrics_collection_interval\": 60\n  },\n  \"metrics\": {\n    \"namespace\": \"CWAgent\",\n    \"append_dimensions\": {\n      \"InstanceId\": \"${aws:InstanceId}\",\n      \"InstanceType\": \"${aws:InstanceType}\"\n    },\n    \"metrics_collected\": {\n      \"Processor\": {\n        \"measurement\": &#91;\n          \"% Processor Time\"\n        ],\n        \"resources\": &#91;\n          \"*\"\n        ],\n        \"metrics_collection_interval\": 60\n      },\n      \"Memory\": {\n        \"measurement\": &#91;\n          \"% Committed Bytes In Use\"\n        ],\n        \"metrics_collection_interval\": 60\n      },\n      \"LogicalDisk\": {\n        \"measurement\": &#91;\n          \"% Free Space\"\n        ],\n        \"resources\": &#91;\n          \"*\"\n        ],\n        \"metrics_collection_interval\": 60\n      }\n    }\n  },\n  \"logs\": {\n    \"logs_collected\": {\n      \"windows_events\": {\n        \"collect_list\": &#91;\n          {\n            \"event_name\": \"System\",\n            \"event_levels\": &#91;\n              \"ERROR\",\n              \"WARNING\"\n            ],\n            \"log_group_name\": \"\/aws\/ec2\/windows\/system\",\n            \"log_stream_name\": \"{instance_id}\"\n          },\n          {\n            \"event_name\": \"Application\",\n            \"event_levels\": &#91;\n              \"ERROR\",\n              \"WARNING\"\n            ],\n            \"log_group_name\": \"\/aws\/ec2\/windows\/application\",\n            \"log_stream_name\": \"{instance_id}\"\n          }\n        ]\n      }\n    }\n  }\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">12. Store Agent Configuration in Systems Manager Parameter Store<\/h1>\n\n\n\n<p>For console-based labs, storing configuration in Parameter Store is useful because Systems Manager can apply it to EC2 instances.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <strong>AWS Systems Manager<\/strong>.<\/li>\n\n\n\n<li>Go to <strong>Application Management<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Parameter Store<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Create parameter<\/strong>.<\/li>\n\n\n\n<li>Name the parameter:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>\/AmazonCloudWatch\/linux-basic-config\n<\/code><\/pre>\n\n\n\n<ol start=\"6\" class=\"wp-block-list\">\n<li>Type:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>String\n<\/code><\/pre>\n\n\n\n<ol start=\"7\" class=\"wp-block-list\">\n<li>Data type:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>text\n<\/code><\/pre>\n\n\n\n<ol start=\"8\" class=\"wp-block-list\">\n<li>Paste the CloudWatch Agent JSON configuration.<\/li>\n\n\n\n<li>Click <strong>Create parameter<\/strong>.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">13. Start CloudWatch Agent Using Console<\/h1>\n\n\n\n<p>After installing the agent and creating configuration, start the agent with Systems Manager Run Command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <strong>AWS Systems Manager<\/strong>.<\/li>\n\n\n\n<li>Go to <strong>Run Command<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Run command<\/strong>.<\/li>\n\n\n\n<li>Search for command document:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>AmazonCloudWatch-ManageAgent\n<\/code><\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>Select it.<\/li>\n\n\n\n<li>Configure parameters:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Parameter<\/th><th>Value<\/th><\/tr><\/thead><tbody><tr><td>Action<\/td><td>configure<\/td><\/tr><tr><td>Mode<\/td><td>ec2<\/td><\/tr><tr><td>Optional Configuration Source<\/td><td>ssm<\/td><\/tr><tr><td>Optional Configuration Location<\/td><td><code>\/AmazonCloudWatch\/linux-basic-config<\/code><\/td><\/tr><tr><td>Optional Restart<\/td><td>yes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ol start=\"7\" class=\"wp-block-list\">\n<li>In <strong>Targets<\/strong>, select your EC2 instance.<\/li>\n\n\n\n<li>Click <strong>Run<\/strong>.<\/li>\n\n\n\n<li>Wait for status:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>Success\n<\/code><\/pre>\n\n\n\n<p>This command applies the configuration and starts or restarts the CloudWatch Agent.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">14. Verify Metrics in CloudWatch<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Steps<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <strong>CloudWatch<\/strong>.<\/li>\n\n\n\n<li>Go to <strong>Metrics<\/strong>.<\/li>\n\n\n\n<li>Click <strong>All metrics<\/strong>.<\/li>\n\n\n\n<li>Look for namespace:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>CWAgent\n<\/code><\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>Open it.<\/li>\n\n\n\n<li>Look for dimensions such as:\n<ul class=\"wp-block-list\">\n<li>InstanceId<\/li>\n\n\n\n<li>InstanceType<\/li>\n\n\n\n<li>AutoScalingGroupName<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Select metrics:\n<ul class=\"wp-block-list\">\n<li>mem_used_percent<\/li>\n\n\n\n<li>disk_used_percent<\/li>\n\n\n\n<li>cpu_usage_user<\/li>\n\n\n\n<li>cpu_usage_system<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Graph the metrics.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Expected Result<\/h2>\n\n\n\n<p>Students should now see memory and disk metrics that were not available earlier under default EC2 metrics.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">15. Verify Logs in CloudWatch<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Steps<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <strong>CloudWatch<\/strong>.<\/li>\n\n\n\n<li>Go to <strong>Logs<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Log groups<\/strong> or <strong>Log Management<\/strong>.<\/li>\n\n\n\n<li>Look for log groups:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>\/aws\/ec2\/system\/messages\n\/aws\/ec2\/system\/cloud-init\n<\/code><\/pre>\n\n\n\n<p>For Ubuntu:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/aws\/ec2\/system\/syslog\n<\/code><\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>Open the log group.<\/li>\n\n\n\n<li>Open the log stream.<\/li>\n\n\n\n<li>Confirm log events are arriving.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">16. Basic Logs Insights Query<\/h1>\n\n\n\n<p>After logs are flowing, open <strong>CloudWatch \u2192 Logs \u2192 Logs Insights<\/strong>.<\/p>\n\n\n\n<p>Select the log group and run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fields @timestamp, @message\n| sort @timestamp desc\n| limit 20\n<\/code><\/pre>\n\n\n\n<p>Search for errors:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fields @timestamp, @message\n| filter @message like \/error|ERROR|failed|FAILED|Exception\/\n| sort @timestamp desc\n| limit 20\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">17. Create an Alarm on Agent Metric<\/h1>\n\n\n\n<p>Now create an alarm using a metric collected by CloudWatch Agent.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example: Memory Usage Alarm<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <strong>CloudWatch<\/strong>.<\/li>\n\n\n\n<li>Go to <strong>Alarms<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Create alarm<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Select metric<\/strong>.<\/li>\n\n\n\n<li>Choose namespace:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>CWAgent\n<\/code><\/pre>\n\n\n\n<ol start=\"6\" class=\"wp-block-list\">\n<li>Select metric:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>mem_used_percent\n<\/code><\/pre>\n\n\n\n<ol start=\"7\" class=\"wp-block-list\">\n<li>Select the instance.<\/li>\n\n\n\n<li>Click <strong>Select metric<\/strong>.<\/li>\n\n\n\n<li>Set:\n<ul class=\"wp-block-list\">\n<li>Statistic: Average<\/li>\n\n\n\n<li>Period: 5 minutes<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Condition:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Greater than 80<\/li>\n<\/ul>\n\n\n\n<ol start=\"11\" class=\"wp-block-list\">\n<li>Click <strong>Next<\/strong>.<\/li>\n\n\n\n<li>Configure notification if allowed.<\/li>\n\n\n\n<li>Name:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>Lab-EC2-Memory-High-CloudWatch-Agent\n<\/code><\/pre>\n\n\n\n<ol start=\"14\" class=\"wp-block-list\">\n<li>Create alarm.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">18. Create a Dashboard for Agent Metrics<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Steps<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open <strong>CloudWatch<\/strong>.<\/li>\n\n\n\n<li>Go to <strong>Dashboards<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Create dashboard<\/strong>.<\/li>\n\n\n\n<li>Name:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>CloudWatch-Agent-Lab-Dashboard\n<\/code><\/pre>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>Add a <strong>Line<\/strong> widget.<\/li>\n\n\n\n<li>Choose metrics from namespace:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>CWAgent\n<\/code><\/pre>\n\n\n\n<ol start=\"7\" class=\"wp-block-list\">\n<li>Add:\n<ul class=\"wp-block-list\">\n<li>mem_used_percent<\/li>\n\n\n\n<li>disk_used_percent<\/li>\n\n\n\n<li>cpu_usage_user<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Save widget.<\/li>\n\n\n\n<li>Add alarm widget.<\/li>\n\n\n\n<li>Select the memory alarm.<\/li>\n\n\n\n<li>Save dashboard.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">19. Important Configuration Sections Explained<\/h1>\n\n\n\n<p>A CloudWatch Agent configuration usually contains these sections.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">agent<\/h2>\n\n\n\n<p>Controls agent behavior.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"agent\": {\n  \"metrics_collection_interval\": 60,\n  \"run_as_user\": \"root\"\n}\n<\/code><\/pre>\n\n\n\n<p>Meaning:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Field<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td>metrics_collection_interval<\/td><td>How often metrics are collected<\/td><\/tr><tr><td>run_as_user<\/td><td>User used to run the agent<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">metrics<\/h2>\n\n\n\n<p>Defines what metrics to collect.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"metrics\": {\n  \"namespace\": \"CWAgent\",\n  \"metrics_collected\": {\n    \"mem\": {\n      \"measurement\": &#91;\n        \"mem_used_percent\"\n      ]\n    }\n  }\n}\n<\/code><\/pre>\n\n\n\n<p>Meaning:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Field<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td>namespace<\/td><td>CloudWatch namespace where metrics appear<\/td><\/tr><tr><td>metrics_collected<\/td><td>List of metric plugins<\/td><\/tr><tr><td>measurement<\/td><td>Specific metrics to collect<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">append_dimensions<\/h2>\n\n\n\n<p>Adds useful identifying dimensions.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"append_dimensions\": {\n  \"InstanceId\": \"${aws:InstanceId}\",\n  \"InstanceType\": \"${aws:InstanceType}\"\n}\n<\/code><\/pre>\n\n\n\n<p>This makes it easier to filter metrics by EC2 instance.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">logs<\/h2>\n\n\n\n<p>Defines which log files to collect.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"logs\": {\n  \"logs_collected\": {\n    \"files\": {\n      \"collect_list\": &#91;\n        {\n          \"file_path\": \"\/var\/log\/messages\",\n          \"log_group_name\": \"\/aws\/ec2\/system\/messages\",\n          \"log_stream_name\": \"{instance_id}\"\n        }\n      ]\n    }\n  }\n}\n<\/code><\/pre>\n\n\n\n<p>Meaning:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Field<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td>file_path<\/td><td>Local log file path<\/td><\/tr><tr><td>log_group_name<\/td><td>CloudWatch Logs group name<\/td><\/tr><tr><td>log_stream_name<\/td><td>Stream name inside the log group<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">20. Best Practices<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Use Clear Log Group Names<\/h2>\n\n\n\n<p>Good:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/aws\/ec2\/prod\/web\/system\n\/aws\/ec2\/prod\/web\/nginx-access\n\/aws\/ec2\/prod\/app\/application\n<\/code><\/pre>\n\n\n\n<p>Bad:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>testlog1\nmylog\nabc\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Use a Consistent Namespace<\/h2>\n\n\n\n<p>Default namespace is often:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CWAgent\n<\/code><\/pre>\n\n\n\n<p>For teams, you can use:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CompanyName\/EC2\nApplicationName\/Infrastructure\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Avoid Collecting Too Much Data<\/h2>\n\n\n\n<p>Every metric and log has cost impact.<\/p>\n\n\n\n<p>Be careful with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Very short collection intervals<\/li>\n\n\n\n<li>Too many disk mount points<\/li>\n\n\n\n<li>Too many log files<\/li>\n\n\n\n<li>Debug logs<\/li>\n\n\n\n<li>High-cardinality custom metrics<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Set Log Retention<\/h2>\n\n\n\n<p>After log groups are created:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to <strong>CloudWatch \u2192 Logs \u2192 Log groups<\/strong>.<\/li>\n\n\n\n<li>Select log group.<\/li>\n\n\n\n<li>Choose <strong>Retention settings<\/strong>.<\/li>\n\n\n\n<li>Set retention, such as:\n<ul class=\"wp-block-list\">\n<li>7 days<\/li>\n\n\n\n<li>14 days<\/li>\n\n\n\n<li>30 days<\/li>\n\n\n\n<li>90 days<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Do not leave unnecessary logs with indefinite retention.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Use Separate Configurations<\/h2>\n\n\n\n<p>Use different configs for different server types.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Server Type<\/th><th>Config<\/th><\/tr><\/thead><tbody><tr><td>Web server<\/td><td>Nginx logs + system metrics<\/td><\/tr><tr><td>App server<\/td><td>Application logs + memory\/disk<\/td><\/tr><tr><td>Database client server<\/td><td>App logs + process metrics<\/td><\/tr><tr><td>Windows server<\/td><td>Windows Event Logs + performance counters<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">21. Common Troubleshooting<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Problem: CWAgent Namespace Not Visible<\/h2>\n\n\n\n<p>Possible causes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Agent not installed.<\/li>\n\n\n\n<li>Agent not started.<\/li>\n\n\n\n<li>Wrong Region selected.<\/li>\n\n\n\n<li>IAM role missing CloudWatchAgentServerPolicy.<\/li>\n\n\n\n<li>Configuration was not applied.<\/li>\n\n\n\n<li>No metrics collected yet.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Problem: Logs Not Appearing<\/h2>\n\n\n\n<p>Possible causes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Wrong file path.<\/li>\n\n\n\n<li>Agent does not have permission to read log file.<\/li>\n\n\n\n<li>Log file does not exist.<\/li>\n\n\n\n<li>IAM role missing permissions.<\/li>\n\n\n\n<li>Wrong Region.<\/li>\n\n\n\n<li>Agent not restarted after config change.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Problem: Systems Manager Cannot Find Instance<\/h2>\n\n\n\n<p>Possible causes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Instance does not have AmazonSSMManagedInstanceCore policy.<\/li>\n\n\n\n<li>SSM Agent not installed.<\/li>\n\n\n\n<li>Instance cannot reach Systems Manager endpoint.<\/li>\n\n\n\n<li>Wrong AWS Region.<\/li>\n\n\n\n<li>Instance is stopped.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Problem: Memory Metrics Missing<\/h2>\n\n\n\n<p>Possible causes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Agent not configured to collect memory.<\/li>\n\n\n\n<li>Agent config only collects logs.<\/li>\n\n\n\n<li>Agent not restarted.<\/li>\n\n\n\n<li>Wrong namespace or dimension selected.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">22. Beginner Lab Flow<\/h1>\n\n\n\n<p>Use this flow for students:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1. Open EC2 and confirm instance exists.\n2. Attach IAM role with SSM and CloudWatch Agent permissions.\n3. Open Systems Manager and confirm instance is managed.\n4. Install CloudWatch Agent using Run Command.\n5. Create configuration in Parameter Store.\n6. Apply configuration using AmazonCloudWatch-ManageAgent.\n7. Open CloudWatch Metrics.\n8. Find CWAgent namespace.\n9. Graph memory and disk metrics.\n10. Open CloudWatch Logs.\n11. Verify log groups.\n12. Run Logs Insights query.\n13. Create memory alarm.\n14. Create dashboard.\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">23. Final Summary<\/h1>\n\n\n\n<p>AWS CloudWatch Agent is the main way to collect deeper telemetry from EC2 instances, on-premises servers, and some containerized workloads.<\/p>\n\n\n\n<p>It is used to collect:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Memory metrics<\/li>\n\n\n\n<li>Disk usage metrics<\/li>\n\n\n\n<li>Process metrics<\/li>\n\n\n\n<li>System logs<\/li>\n\n\n\n<li>Application logs<\/li>\n\n\n\n<li>Windows Event Logs<\/li>\n\n\n\n<li>Custom metrics<\/li>\n\n\n\n<li>StatsD metrics<\/li>\n\n\n\n<li>collectd metrics<\/li>\n\n\n\n<li>OpenTelemetry metrics and traces<\/li>\n<\/ul>\n\n\n\n<p>For beginner AWS observability, CloudWatch Agent is especially important because it fills the biggest EC2 monitoring gap:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>EC2 gives you CPU and network metrics by default, but CloudWatch Agent gives you memory, disk, logs, and deeper operating-system visibility.<\/p>\n<\/blockquote>\n\n\n\n<p>The recommended console-only setup is:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>EC2 IAM role \u2192 Systems Manager \u2192 Install Agent \u2192 Store JSON config in Parameter Store \u2192 Apply config \u2192 Verify CWAgent metrics and logs in CloudWatch.<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>1. What is AWS CloudWatch Agent? AWS CloudWatch Agent is a software agent installed on servers or compute environments to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2275","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Complete Tutorial Guide: AWS CloudWatch Agent - SRE School<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Complete Tutorial Guide: AWS CloudWatch Agent - SRE School\" \/>\n<meta property=\"og:description\" content=\"1. What is AWS CloudWatch Agent? AWS CloudWatch Agent is a software agent installed on servers or compute environments to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/\" \/>\n<meta property=\"og:site_name\" content=\"SRE School\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-25T11:12:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-27T11:12:59+00:00\" \/>\n<meta name=\"author\" content=\"Rajesh Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rajesh Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/\",\"url\":\"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/\",\"name\":\"Complete Tutorial Guide: AWS CloudWatch Agent - SRE School\",\"isPartOf\":{\"@id\":\"https:\/\/sreschool.com\/blog\/#website\"},\"datePublished\":\"2026-04-25T11:12:26+00:00\",\"dateModified\":\"2026-04-27T11:12:59+00:00\",\"author\":{\"@id\":\"https:\/\/sreschool.com\/blog\/#\/schema\/person\/0ffe446f77bb2589992dbe3a7f417201\"},\"breadcrumb\":{\"@id\":\"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/#breadcrumb\"},\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/sreschool.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Complete Tutorial Guide: AWS CloudWatch Agent\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/sreschool.com\/blog\/#website\",\"url\":\"https:\/\/sreschool.com\/blog\/\",\"name\":\"SRESchool\",\"description\":\"Master SRE. Build Resilient Systems. Lead the Future of Reliability\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/sreschool.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/sreschool.com\/blog\/#\/schema\/person\/0ffe446f77bb2589992dbe3a7f417201\",\"name\":\"Rajesh Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\/\/sreschool.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f901a4f2929fa034a291a8363d589791d5a3c1f6a051c22e744acb8bfc8e022a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f901a4f2929fa034a291a8363d589791d5a3c1f6a051c22e744acb8bfc8e022a?s=96&d=mm&r=g\",\"caption\":\"Rajesh Kumar\"},\"sameAs\":[\"http:\/\/sreschool.com\/blog\"],\"url\":\"https:\/\/sreschool.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Complete Tutorial Guide: AWS CloudWatch Agent - SRE School","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/","og_locale":"en_US","og_type":"article","og_title":"Complete Tutorial Guide: AWS CloudWatch Agent - SRE School","og_description":"1. What is AWS CloudWatch Agent? AWS CloudWatch Agent is a software agent installed on servers or compute environments to [&hellip;]","og_url":"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/","og_site_name":"SRE School","article_published_time":"2026-04-25T11:12:26+00:00","article_modified_time":"2026-04-27T11:12:59+00:00","author":"Rajesh Kumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rajesh Kumar","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/","url":"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/","name":"Complete Tutorial Guide: AWS CloudWatch Agent - SRE School","isPartOf":{"@id":"https:\/\/sreschool.com\/blog\/#website"},"datePublished":"2026-04-25T11:12:26+00:00","dateModified":"2026-04-27T11:12:59+00:00","author":{"@id":"https:\/\/sreschool.com\/blog\/#\/schema\/person\/0ffe446f77bb2589992dbe3a7f417201"},"breadcrumb":{"@id":"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/sreschool.com\/blog\/complete-tutorial-guide-aws-cloudwatch-agent\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sreschool.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Complete Tutorial Guide: AWS CloudWatch Agent"}]},{"@type":"WebSite","@id":"https:\/\/sreschool.com\/blog\/#website","url":"https:\/\/sreschool.com\/blog\/","name":"SRESchool","description":"Master SRE. Build Resilient Systems. Lead the Future of Reliability","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sreschool.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Person","@id":"https:\/\/sreschool.com\/blog\/#\/schema\/person\/0ffe446f77bb2589992dbe3a7f417201","name":"Rajesh Kumar","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/sreschool.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f901a4f2929fa034a291a8363d589791d5a3c1f6a051c22e744acb8bfc8e022a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f901a4f2929fa034a291a8363d589791d5a3c1f6a051c22e744acb8bfc8e022a?s=96&d=mm&r=g","caption":"Rajesh Kumar"},"sameAs":["http:\/\/sreschool.com\/blog"],"url":"https:\/\/sreschool.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/posts\/2275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/comments?post=2275"}],"version-history":[{"count":1,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/posts\/2275\/revisions"}],"predecessor-version":[{"id":2276,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/posts\/2275\/revisions\/2276"}],"wp:attachment":[{"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/media?parent=2275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/categories?post=2275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sreschool.com\/blog\/wp-json\/wp\/v2\/tags?post=2275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}