Amazon CloudWatch is a monitoring and observability service used to monitor applications and infrastructure. It helps DevOps engineers, developers, SREs, and IT teams track system performance using metrics, logs, and events. CloudWatch also helps detect issues, respond to changes, and optimize resource utilization through a unified monitoring dashboard.

Core Architecture
CloudWatch is built around three main components:
Metrics
Metrics are numerical values collected over time to monitor resources and applications.
- Example: CPU Utilization is 85% at 10:00 AM.
- AWS services like EC2, RDS, and Lambda automatically send metrics to CloudWatch.
- Users can also create custom metrics from their own applications.
Logs
Logs are text records that store detailed information about events and activities.
- Example: Lambda function errors or web server access logs.
- Logs are stored in Log Groups and Log Streams for better organization.
Events (now EventBridge)
Events track changes that happen in AWS resources and services.
- Example: An EC2 instance changing from running to stopped state.
- These events can trigger automated actions and workflows.
Features
Metrics
- Metrics are time-ordered data points published to CloudWatch.
- Each data point is associated with a timestamp.
- Metrics help monitor the performance of AWS resources and applications over time.
- AWS services automatically send metrics to CloudWatch, and users can also create custom metrics.
- Metric Math allows users to combine multiple metrics and create new calculations or time series.
Dimensions
- Dimensions are name/value pairs used to uniquely identify a metric.
- Adding a new dimension creates a different variation of the metric.
- They help filter and organize monitoring data.
Statistics
- Statistics are aggregated metric values calculated over a period of time.
- The few available statistics on CloudWatch are maximum, minimum, sum, average, and sample count.
Alarm
- It is used to automatically initiate actions on our behalf.
- It watches a single metric over a specified time period and performs one or more specified actions based on the value of the metric.
- The estimated AWS charges can also be monitored using the alarm.
Percentiles
- It represents the relative weightage of the data in a dataset.
- It helps the user to get a better understanding of the distribution of metric data.
CloudWatch dashboard
- A user-friendly CloudWatch console is available which is used for monitoring resources in a single view.
- There is no limit on the number of CloudWatch dashboards you can create.
- These dashboards are global and not region-specific.
CloudWatch agent
- The CloudWatch Agent is required only for collecting system-level metrics and custom logs that are not available by default.
- It collects logs and system-level metrics from EC2 instances and on-premises servers.
EventBridge (formerly CloudWatch Events)
- Amazon EventBridge monitors events generated by AWS services.
- Events include changes like an EC2 instance moving from running to stopped state.
- Rules are created to match specific event patterns.
- This helps automate notifications, workflows, and serverless actions.
CloudWatch logs
- Amazon CloudWatch logs enable you to store, monitor, and access files from AWS resources like Amazon EC2 instances, Route53, etc.
- It also helps you to troubleshoot your system errors and maintain the logs in highly durable storage.
- It also creates log of information about the DNS queries that Route 53 receives.
Getting started with Amazon CloudWatch
Notifying gfg website management team when the instance on which gfg website is hosted stops Whenever the CPU utilization of instance (on which GeeksForGeeks website is hosted ) goes above 80%, CloudWatch event is triggered. This CloudWatch event then activates the SNS topic which sends the alert email to the attached gfg subscribers.
Create an SNS Topic
Step 1: launch an instance with the name tag 'instance'.

Step 2: Go to SNS topic dashboard and click on create a topic.

Step 3: You will be redirected to the dashboard. Enter the topic name and display name, then scroll down and click on Create topic.

Step 4: The SNS topic is created successfully.

Add Subscribers
Step 1: Go to the SNS Topics dashboard, click on the gfgtopic link, and under the Subscriptions section, click on Create subscription.

Step 2: Select Email as protocol and specify the email address of subscribers in Endpoint. Click on create the subscription. Now Go to the mailbox of the specified email id and click on Subscription confirmed.

Craft the CloudWatch Alarm
Step 1: Go to the CloudWatch dashboard on the AWS management console. Click on Metrics in the left pane.

Step 2: In All metrics section click on EC2

Step 3: Click on Per-instance metrics.

Step 4: Select the instance you launched with Metric name CPUUtilization.

Step 5: Go to Graphed metrics, click on the bell icon.

Step 6: This dashboard shows the components of Amazon CloudWatch such as Namespace, Metric Name, Statistics, etc.

Set the Threshold
Step 1: Select the greater threshold. Also, specify the amount( i.e. 80 ) of the threshold value. Click on Next.

Connecting
Step 1: Click on Select an existing SNS topic, also mention the name of the SNS topic you created now.

Step 2: Specify the name of alarm and description which is completely optional. Click on Next and then click on Create alarm.

Step 3: The alarm is successfully created.

Step 4: You can see the graph which notifies whenever CPU utilization goes above 80%.

Creating a dashboard in Amazon CloudWatch
Creating a dashboard in Amazon CloudWatch is a straightforward process that allows you to visualize and monitor metrics and logs in a centralized and customizable view. Here's a step-by-step guide on how to create a dashboard in Amazon CloudWatch:
Step 1: Access Amazon CloudWatch Console
- Open the Amazon CloudWatch Console.
Step 2: Navigate to Dashboards
- In the CloudWatch Console, locate the "Dashboards" section in the left navigation pane.

Step 3: Click "Create Dashboard"
- Click the "Create dashboard" button to start the dashboard creation process.

Step 4: Enter Dashboard Details
- Provide a name for your dashboard in the "Dashboard name" field. Optionally, you can also add a description.
Step 5: Add a Number Widget for CPU Utilization
- Click on Add widget.
- Select the Number widget type.
- Enter the widget name as CPU Utilization.
- Choose EC2 under Namespace.
- Select Per-Instance Metrics.
- Choose CPUUtilization as the metric.
- Configure additional settings if needed and save the widget.

Step 6: Save the Dashboard
- Once you've configured the widget, click the "Create dashboard" or "Save dashboard" button to save your changes.
Step 7: View the Dashboard
- Your dashboard is now created with a Number widget displaying the CPU utilization of your EC2 instances. You can view it in the CloudWatch Console.
CloudWatch vs. CloudTrail
These two services are often confused, but they serve very different purposes.
| Feature | Amazon CloudWatch | AWS CloudTrail |
|---|---|---|
| Focus | Performance & Monitoring. | Auditing & Compliance. |
Purpose | Monitors applications and infrastructure performance | Tracks user activity and API calls in AWS |
| Data Type | Metrics & Logs. | API Activity History. |
| Example | 90% CPU Utilization. | User Samar called "TerminateInstance" at 2:00 PM. |
Benefits
- Provides a centralized dashboard to monitor application and infrastructure data.
- Helps reduce operational costs by using alarms and automated actions.
- Optimizes applications and AWS resources using metrics and logs analysis.
- Gives detailed insights such as CPU usage, memory utilization, and capacity utilization.
- Makes it easy to compare monitoring data across different AWS services.
Drawbacks
- Can become expensive for large-scale monitoring and logging.
- Handling very large amounts of log data during high traffic can be difficult.
- Monitoring and logging activities may consume additional system resources.
- Integration with other AWS services and third-party tools can sometimes be complex.
- Setup and management may be challenging for beginners or users unfamiliar with cloud systems.
Pricing Model
Amazon CloudWatch offers a Free Tier, but costs can increase depending on usage.
- Free Tier: Includes 10 custom metrics, 10 alarms, and 5 GB of log ingestion.
- Metrics: Around $0.30 per metric each month for the first 10,000 metrics.
- Log Ingestion: Around $0.50 per GB of logs ingested.
- Log Storage: Around $0.03 per GB of stored logs.
- Alarms: Around $0.10 per alarm each month.
- Dashboards: Around $3.00 per dashboard each month.
Cost Tip: Be careful with Detailed Monitoring on EC2 (1-minute intervals) and high-resolution custom metrics, as they cost extra.