Table of Contents

What is Amazon CloudWatch

Amazon CloudWatch is a powerful monitoring service designed to track the performance and health of your AWS resources and applications in real time. It collects data in the form of logs and metrics, giving you a detailed view of how your infrastructure is performing. With CloudWatch, you can create custom dashboards to visualize this data, set alarms to automatically respond to threshold breaches, and optimize resource usage by monitoring key indicators like CPU usage or network traffic. This proactive approach helps businesses improve efficiency, enhance performance, and reduce operational costs within their AWS environments.

AWS CloudWatch, amazon CloudWatch metrics,
Source: AWS

What are AWS CloudWatch Metrics

AWS CloudWatch Metrics are vital performance indicators that provide real-time insights into the health and efficiency of AWS resources and applications. These metrics are generated automatically for a wide range of AWS services like EC2, Amazon S3, RDS, and Lambda. Each metric is organized into a namespace, grouping related metrics for easy monitoring. For instance, all EC2 metrics are in the “AWS/EC2” namespace, making it simple to track specific performance data.

aws cloudwatch metrics, amazon cloudwatch, cloudwatch custom metrics
Source: AWS

CloudWatch Metrics delivers detailed information on CPU utilization, disk I/O, network traffic, memory usage, error rates, and more. By continuously monitoring these parameters, CloudWatch helps identify bottlenecks, troubleshoot issues, and optimize resource usage. You can customize metrics for specific applications, set alarms for threshold breaches, and automate responses to anomalies, ensuring efficient and cost-effective operations.


Types of AWS CloudWatch Metrics

Amazon CloudWatch Metrics serves as vital indicators, providing insights into system performance, operational efficiency, and potential issues. Let us now explore the types of Amazon CloudWatch metrics, how they are organized, and how you can use them to optimize your AWS environment. There are two types of CloudWatch Metrics:

  • Default metrics
  • Custom metrics

Amazon CloudWatch Built-in Metrics

Amazon CloudWatch built-in metrics are predefined metrics automatically tracked across multiple AWS services such as Amazon EC2, Amazon S3, RDS, and ECS. These metrics give users real-time data on various performance indicators, helping them monitor resource utilization, system health, and operational efficiency. They are a core component of AWS monitoring, ensuring that cloud environments remain efficient and stable.

The metrics are free for basic monitoring, though more advanced features may incur additional costs, such as detailed monitoring with higher frequency data collection intervals.

Some of the built-in metrics available in CloudWatch are:

  • Amazon EC2: CPU usage, disk activity, and network traffic 
  • Amazon ECS:ย CPU and memory reservation, CPU, memory, and EBS filesystem utilization
  • Amazon RDS: DatabaseConnections, ReadIOPS/WriteIOPS
  • AWS Lambda: Invocations, duration and throttles

Amazon CloudWatch Custom Metrics

While CloudWatch automatically tracks a wide range of built-in metrics for AWS services, custom metrics enable you to define and publish your own data points using the AWS CLI or CloudWatch API. These metrics can be granular, with data points recorded down to one second (high resolution), or they can follow a standard resolution with one-minute intervals. Custom metrics are stored in CloudWatch as a series of data points, each with an associated timestamp, allowing for detailed trend analysis over time.

cloudwatch metrics pricing, cloudwatch agent metrics, aws cloudwatch custom metrics
Source: AWS

AWS CloudWatch Custom metrics provide better flexibility and allow you to track operational metrics beyond those automatically provided by AWS. You can publish either single data points or aggregate statistics called “statistic sets” for more efficient data transmission. Dimensions can be added to custom metrics to provide additional context, such as specifying the instance ID or resource type being measured. CloudWatch also offers options to create alarms for custom metrics, including high-resolution alarms that trigger actions in near real-time.

However, it’s important to note that while custom metrics offer powerful insights, each PutMetricData call incurs charges, and the frequency of data submissions can affect your CloudWatch costs.


How to Publish Custom Metrics in AWS CloudWatch

There are several methods you can choose from to implement custom metrics in AWS CloudWatch, depending on your specific use case and setup.

Using the PutMetricData API

The PutMetricData API allows you to publish custom metric data directly into CloudWatch. You can send individual data points, high-resolution metrics, or statistical sets, and CloudWatch will create the metric if it doesn’t exist. This method works well for one-off or low-frequency submissions but is less efficient for continuous or high-frequency data due to API rate limits, latency, and data retention policies. Here’s an example command using the AWS CLI to submit a custom metric:

aws cloudwatch put-metric-data --metric-name PageViewCount --namespace MyService --statistic-values Sum=11,Minimum=2,Maximum=5,SampleCount=3 --timestamp 2016-10-14T12:00:00.000Z

Using AWS SDKs

AWS SDKs, available for multiple programming languages like Python, Java, and Node.js, allow you to publish custom metrics programmatically. By using SDK methods, you can define custom namespaces, dimensions, and metric data points. For instance, in Java, you can use the putMetricData method in the AmazonCloudWatchClient to submit metrics. This method provides flexibility to automate metric publishing from within your application code.

CloudWatch Agent for EC2

If your application runs on EC2 instances, you can use the CloudWatch Agent to collect and publish custom metrics. The agent can be configured to collect logs and specific metrics from Amazon EC2 instances and on-premises servers, running either Linux or Windows Server. You can also add custom dimensions, such as tagging metrics with specific identifiers. For example, by configuring the CloudWatch Agent, you can monitor CPU and disk usage along with additional tags like “stackName” to group and filter metrics more effectively.

Embedded Metric Format

The Embedded Metric Format is a JSON-based approach that lets you publish custom metrics directly within your application logs. EMF allows your application to generate structured log events, and CloudWatch automatically extracts and transforms this log data into metrics. This method is particularly useful for applications that generate high-cardinality data, as it allows for up to 100 metrics and 20 dimensions per call without relying on traditional API requests.

Each of these methods serves different use cases, from publishing one-off metrics to automating continuous metric monitoring. Depending on your application’s needs, you can pick the appropriate method to track performance, gain insights, and optimize AWS resource usage.


Essential Components that Support AWS CloudWatch Metrics Monitoring

AWS offers a powerful set of tools within AWS CloudWatch to help you monitor and optimize your cloud environment. Key among these tools are Metrics Explorer, Metrics Insights Queries, and Metric Streams. Each of these features plays a vital role in enhancing your ability to track, analyze, and respond to performance data. 

Metrics Explorer

CloudWatch Metrics Explorer is an AWS tool that improves metric monitoring by allowing you to filter, aggregate, and visualize data based on tags and resource properties. It updates automatically to include resources matching your criteria, keeping your views current. Metrics can be aggregated in single or multiple graphs using templates or customized views.

Metrics Explorer supports AWS and EC2 metrics from the CloudWatch Agent but may require configuration updates for compatibility. It provides a real-time view, excluding terminated or unmatched resources from visualizations.

aws cloudwatch custom metrics, AWs cloudwatch metrics explorer, AWS CloudWatch Agent
Source: AWS

CloudWatch Metrics Insights

CloudWatch Metrics Insights is a high-performance SQL query engine for analyzing CloudWatch metrics at scale. It supports real-time, complex queries to gain insights and create dynamic alarms that adjust as resources change. Metrics Insights includes a manual query editor and an AI-driven feature for generating queries from natural language prompts.

This tool excels at grouping and sorting data, perfect for “Top N” queries, like pinpointing top instances using the most CPU. You can run queries via the AWS console, CLI, or SDK, with no extra cost for the query editor.

Amazon CloudWatch Metrics Insights, cloudwatch logs
Source: AWS

Metric Streams

CloudWatch Metric Streams allow you to continuously stream CloudWatch metrics to various destinations with near-real-time delivery and low latency. You can configure metric streams to direct data to Amazon S3, through Amazon Kinesis Data Firehose for more customized setups, or to other third-party services.

Metric Streams support formats including JSON and OpenTelemetry, and can include up to 1000 filters to specify which metrics to include or exclude. New metrics matching your filters are automatically added to the stream, with no limits on the number of streams or metric updates. This feature helps you integrate and analyze metrics data efficiently, combining it with other data sources for deeper insights and cost optimization.

Amazon Metric Streams, aws cloudwatch metric streams, cloudwatch metric streams pricing, cloudwatch expenses
Source: AWS

AWS CloudWatch Metrics Pricing Explained

Amazon CloudWatch offers a scalable pricing model for monitoring your AWS resources, designed to accommodate a range of usage needs. Hereโ€™s a breakdown of how CloudWatch Metrics are priced:

Metrics Pricing

Custom metrics and Detailed Monitoring charges are prorated by the hour and apply only when metrics are actively sent to CloudWatch. Each unique combination of dimensions is considered a separate metric, even if they share the same name. Detailed Monitoring pricing depends on the number of custom metrics, with no additional API charges for sending metrics. For example, monitoring 12 extra metrics on an EC2 instance could cost between $0.24 to $3.60 per month, depending on the pricing tier.

Metric TierCost (per 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
AWS CloudWatch Metrics Pricing

API Costs

You can request up to five statistics for a metric in a single GetMetricData API call. Additional statistics incur extra charges. Metrics Insights queries that analyze your metrics also factor into costs, with charges based on the number of metrics analyzed. However, querying through the CloudWatch console does not incur extra costs.

API NameCost
GetMetricData, GetInsightRuleReport$0.01 per 1,000 metrics requested
GetMetricWidgetImage$0.02 per 1,000 metrics requested
GetMetricStatistics, ListMetrics, PutMetricData, GetDashboard, ListDashboards, PutDashboard, DeleteDashboards$0.01 per 1,000 requests
AWS CloudWatch Metrics Pricing – API Cost

Metric Streams Pricing

Metric Streams allow for continuous streaming of metrics with near-real-time updates. Pricing is based on the number of metric updates, with each update including four default statistics (Minimum, Maximum, Sample Count, and Sum). Additional statistics beyond these four are billed as extra metric updates. Additional charges may apply for data ingestion through Amazon Kinesis Data Firehose and for any data transfer or format conversions.

Metric StreamsCost
Metric Streams$0.003 per 1,000 metric updates
AWS CloudWatch Metrics Streams Pricing

Apart from this, charges for data transfer out and format conversions depend on your specific setup, including the destination and any additional transformations applied to the data. Overall, Amazon CloudWatchโ€™s pricing is designed to be flexible and scalable, allowing you to effectively monitor and analyze your AWS environment while managing costs based on your usage patterns.


Conclusion

Exploring the full capabilities of Amazon CloudWatch will help you optimize your AWS infrastructure effectively. CloudWatchโ€™s diverse features, including Metrics Explorer, Metrics Insights, and Metric Streams, provide invaluable real-time insights and advanced analytics. By comprehending CloudWatch metrics and its pricing framework, you can make strategic choices that optimize both cost efficiency and performance. Implementing CloudWatch effectively will enhance your ability to monitor, troubleshoot, and also drive greater efficiency and cost savings within your AWS environment.


FAQs:

Q. What are the 3 states of the CloudWatch metric alarm?

A. The three states of a CloudWatch metric alarm are:

OK when the metric is within the defined threshold;

ALARM when the metric breaches the threshold;

INSUFFICIENT_DATA when there is not enough data to determine the state.

Q. How do I collect AWS metrics?

A. You can collect AWS metrics automatically through Amazon CloudWatch, which gathers default metrics for various AWS services like EC2, S3, and Lambda. For custom metrics, you can use the CloudWatch Agent, AWS SDKs, or the PutMetricData API to publish your application’s specific data.

Q. Which command is used to list CloudWatch metrics?

A. The command used to list CloudWatch metrics is aws cloudwatch list-metrics. It retrieves available metrics, optionally filtered by namespace, metric name, or dimensions.


Looking to Optimize your Cloud Costs?

Ready to transform your cloud economics? Don’t let runaway costs hold your business back. With Economize, you can effortlessly slash your cloud expenditures by up to 30%. Book a free demo with us today and discover how we can help you start saving in as little as 10 minutes.

Heera Ravindran

Content Marketer at Economize. An avid writer and a zealous reader who specializes in technical content and has a passion for all things Cloud and FinOps.