Getting Started with AWS CloudWatch: A Beginner's Guide

September 24, 2024
8
min read

Introduction

Monitoring in AWS is crucial for maintaining the health, performance, and security of your cloud infrastructure. AWS CloudWatch helps track operational data, ensuring your applications and services are running efficiently. This blog will explore what AWS CloudWatch offers, its features, integration with other AWS services, best practices, and pricing.

What is AWS CloudWatch?

Source: CloudWatch alarms and dashboards

Amazon CloudWatch is an AWS service that helps you monitor and track the performance of your applications and resources. It collects and tracks metrics, monitors log files, sets alarms, and triggers automated actions in response to changes in your AWS environment. With CloudWatch, you can easily keep an eye on your infrastructure’s health, performance, and resource usage.

CloudWatch Features

CloudWatch comes with an extensive set of features, offering a complete monitoring solution for AWS environments. It includes metrics to track resource performance, logs for detailed operational insights and alarms for timely alerts. Beyond these, CloudWatch offers even more capabilities, ensuring users have all the tools they need for robust cloud observability and management. Let's break down these key features in detail.

CloudWatch Logs

Source: Understanding AWS Lambda behavior using Amazon CloudWatch Logs Insights

CloudWatch Logs allows users to collect, store, and manage logs from a wide range of sources, including vended services, specific AWS services like AWS CloudTrail, AWS Lambda, Amazon API Gateway, and Amazon SNS, as well as custom applications and on-premises resources. With CloudWatch Logs Insights, users can quickly run queries and visualize log data, enabling faster analysis and troubleshooting across their infrastructure.

CloudWatch Metrics

Source: Logging and metrics with Amazon CloudWatch

Metrics Collection in CloudWatch enables users to gather default metrics from over 70 AWS services, all accessible from a centralized dashboard. In addition to AWS-provided metrics, users can also define custom metrics from their own applications or on-premises resources, tailoring the monitoring experience to fit their specific needs. This flexibility allows for comprehensive visibility into both cloud and on-premises environments.

CloudWatch Alarms

Source: Alarms, incident management, and remediation in the cloud with Amazon CloudWatch

Alarms in Amazon CloudWatch allow you to monitor the state of your metrics and trigger automated actions when thresholds are breached. They help ensure your AWS resources are operating within defined limits, making it easier to detect issues and respond quickly.

You can set up two types of alarms: metric alarms and composite alarms.

A metric alarm tracks a single CloudWatch metric or a calculated value from multiple metrics. When a metric crosses the specified threshold for a set time period, the alarm initiates actions like sending notifications via Amazon SNS, triggering Amazon EC2 or Auto Scaling actions, or creating incidents in Systems Manager.

Composite alarms use a rule-based approach, combining the states of multiple alarms, both metric and composite. The composite alarm enters an ALARM state only when all conditions in the rule are met, helping reduce unnecessary alerts. For example, you can set individual metric alarms and then use a composite alarm to trigger only when all the underlying alarms are active, minimizing alarm noise and simplifying alert management.

CloudWatch Container Insights

Source: Introducing Amazon CloudWatch Container Insights for Amazon ECS

Container Insights collects, aggregates, and monitors both metrics and logs for containerized applications and microservices. It also helps troubleshoot issues in Amazon Elastic Kubernetes Service (EKS) and Amazon Elastic Container Service (ECS), offering valuable insights for managing and optimizing container environments.

CloudWatch Synthetic monitoring (canaries)

Source: Monitor your private internal endpoints 24×7 using CloudWatch Synthetics

Canaries are automated scripts that simulate customer actions on your application, running on a schedule to continuously monitor your endpoints and APIs. By using Amazon CloudWatch Synthetics, you can create canaries that mimic user behavior, following the same paths and actions as a real customer. This enables you to verify the customer experience even when there's no actual traffic, allowing you to identify and fix issues before they impact users.

Source: Use CloudWatch Synthetics to Monitor Sites, API Endpoints, Web Workflows, and More

Canaries are written in Node.js or Python and are deployed as Lambda functions in your AWS account. They operate over both HTTP and HTTPS protocols, using Lambda layers that include the CloudWatch Synthetics library for the respective language. Importantly, these libraries do not transmit or store customer data—all data is kept securely within your AWS account.

With canaries, you gain programmatic access to a headless Google Chrome browser via Puppeteer or Selenium WebDriver, making it easy to test website performance and detect unauthorized changes, such as phishing, code injections, or cross-site scripting. Canaries also track the availability and latency of your endpoints, storing load time data and capturing screenshots for analysis.

EventBridge (CloudWatch Events)

Source: Building Serverless Pipelines with Amazon CloudWatch Events

EventBridge (previously known as CloudWatch Events) enables you to create rules that react to changes in your AWS environment, such as the stopping of an EC2 instance. These rules can automatically route events to various targets, including AWS Lambda functions, Amazon SNS topics, Amazon SQS queues, and other supported services.

By continuously monitoring operational events, EventBridge detects changes in the state of your AWS resources and triggers actions based on predefined rules. When an event occurs, such as a change in resource status, it can initiate notifications, invoke Lambda functions, or take other automated actions.

Each event reflects a change in your AWS environment, and the system uses rules to match these events and direct them to specified targets. The targets, which include services like EC2 instances and Lambda functions, process the event data in JSON format, enabling seamless automation and integration across your AWS infrastructure.

CloudWatch Dashboards

Source: Getting started with Amazon CloudWatch

Amazon CloudWatch Dashboards provide customizable home pages in the CloudWatch console, allowing you to monitor your AWS resources across multiple regions in one unified view. With these dashboards, you can create personalized displays of metrics and alarms to better track the performance of your infrastructure.

Key benefits of CloudWatch dashboards include:

  • Unified Monitoring: Create a single view to monitor selected metrics and alarms, offering a clear snapshot of the health of your resources and applications across regions. You can also customize the color for each metric, making it easier to track key metrics across different graphs.
  • Operational Playbooks: Use dashboards to create operational playbooks, offering guidance to team members on how to respond to incidents during operational events.
  • Shared Views for Faster Response: Dashboards provide a common view of critical resource measurements, helping teams collaborate more effectively during operational events by sharing real-time data.

CloudWatch RUM

Source: New – Real-User Monitoring for Amazon CloudWatch

CloudWatch RUM (Real User Monitoring) allows you to track the performance of your web applications by collecting and analyzing client-side data from real user sessions, almost in real time. This data includes critical metrics such as page load times, client-side errors, and user behavior, all aggregated into a single view. You can also break down the data by browsers and devices, offering deeper insights into user experience across different platforms.

By using CloudWatch RUM, you can quickly identify and debug client-side performance issues. It provides visualizations of performance anomalies and relevant debugging information like error messages, stack traces, and user session data. Additionally, RUM helps you assess the impact on your users by showing how many are affected, where they are located, and which browsers they are using.

Amazon CloudWatch Agent

Source: Getting Started with CloudWatch agent and collectd

The unified CloudWatch agent enhances monitoring by collecting a wide range of metrics and logs, including those not available by default in CloudWatch. It captures system-level metrics from Amazon EC2 instances and on-premises servers, whether in hybrid environments or standalone setups. For custom metrics, it supports StatsD (Linux/Windows) and collectd (Linux). The agent also collects logs from both EC2 instances and on-premises servers, making it a crucial tool for gaining deeper insights beyond CloudWatch’s default metrics.

CloudTrail vs CloudWatch

It’s common for users to confuse CloudWatch and CloudTrail, as both are monitoring services within AWS. However, they serve distinct purposes.

AWS CloudWatch focuses on monitoring system performance for AWS applications and resources. It tracks metrics like CPU usage, memory utilization, and application performance, giving you insights into the operational health of your infrastructure.

On the other hand, AWS CloudTrail is a service designed to monitor and log activity within your AWS environment by tracking API calls. It provides a detailed record of all actions, allowing you to trace user activity and changes across your resources. CloudTrail answers the "who, what, where, and when" of events within your AWS account, offering a clear trail of activity for security and auditing purposes.

CloudWatch Pricing

In this section, we focus on the Free Tier offerings of Amazon CloudWatch. For a more detailed breakdown of CloudWatch pricing beyond the Free Tier, you can refer to the official pricing page.

With Amazon CloudWatch, there’s no upfront commitment or minimum fee; you only pay for what you use, billed at the end of each month. However, CloudWatch also offers a Free Tier, which covers most basic monitoring needs, especially for smaller-scale applications.

Free Tier

  • Metrics: Basic monitoring metrics from AWS services like EC2, S3, and Kinesis are sent to CloudWatch for free. You also get:
    • 10 custom metrics or detailed monitoring metrics.
    • 1 million API requests (excluding specific operations like GetMetricData).
  • Dashboards: Up to 3 custom dashboards with up to 50 metrics each, plus automatic dashboards are free.
  • Alarms: 10 standard-resolution alarms (for metrics directly).
  • Logs:
    • 5 GB of data (including ingestion, archive storage, and data scanned by Log Insights queries).
    • 1,800 minutes (about 1 hour per day) of Live Tail usage.
  • Contributor Insights for CloudWatch Logs: 1 Contributor Insights rule and the first 1 million log events per month.
  • Application Signals: First 100 million signals or 3 months of free usage.
  • Synthetics: 100 canary runs per month.
  • Evidently: 3 million Evidently events and 10 million Evidently analysis units.
  • RUM (Real User Monitoring): 1 million RUM events.
  • Cross-Account Observability: First trace copy sent from source account to monitoring account.

Conclusion

Amazon CloudWatch offers a robust and flexible solution for monitoring and observability across your AWS infrastructure. With its wide range of features—including metrics, logs, alarms, dashboards, and real user monitoring (RUM)—it provides deep insights into the operational health and performance of your resources. From tracking application performance to identifying and troubleshooting client-side issues, CloudWatch empowers you to maintain and optimize your cloud environment efficiently.

Its integrations with other AWS services, such as Lambda and SNS, enable seamless automation and quicker responses to events.

Share this article:
Subscribe to our newsletter to get our latest updates!
Thank you!
Your submission has been received!
Oops! Something went wrong while submitting the form.