CloudWatch Metrics

Custom & Default Metrics Deep Dive

Metrics Overview

CloudWatch metrics are time-ordered sets of data points that represent the performance of your systems. They are the fundamental concept in CloudWatch and provide insights into resource utilization, application performance, and operational health.

Time-Series Data

Timestamped data points collected over time.

Statistical Analysis

Aggregated insights using functions like Average, Sum, Min, Max.

Alarm Triggers

Metrics are monitored by alarms to trigger automated responses.

Default AWS Metrics

Many AWS services provide free, default metrics for their resources. These are automatically collected and pushed to CloudWatch.

EC2 Instance Metrics

EC2 provides metrics at the hypervisor level.

CPUUtilization

Percentage of allocated EC2 compute units that are currently in use.

NetworkIn/Out

The number of bytes received on all network interfaces by the instance.

DiskReadOps/WriteOps

Completed read/write operations from all instance store volumes.

StatusCheckFailed

Reports whether the instance has passed both the instance status check and the system status check.

Important Note EC2 default metrics do not include memory utilization, disk space utilization, or swap utilization. Use the CloudWatch Agent for these critical OS-level metrics.

RDS Database Metrics

RDS provides metrics to monitor the health and performance of your database instances.

CPUUtilization

The percentage of CPU utilization for the database instance.

DatabaseConnections

The number of client network connections to the database instance.

FreeableMemory

The amount of available random access memory.

ReadIOPS/WriteIOPS

The average number of disk I/O operations per second.

Custom Metrics

You can publish your own custom metrics to CloudWatch using the `PutMetricData` API call. This is essential for monitoring application-level performance, business metrics, or OS-level metrics not provided by default.

Publishing Methods

AWS CLI

Use the `aws cloudwatch put-metric-data` command.

AWS SDKs

Use the `PutMetricData` API call in your application code.

CloudWatch Agent

The agent can be configured to publish custom metrics, including system-level metrics like memory usage.

Metric Components

Namespace

A container for CloudWatch metrics. Metrics from different applications or services should be in different namespaces. Custom namespaces cannot start with "AWS/".

MetricName

The name of the metric (e.g., "MemoryUtilization", "ProcessedOrders").

Dimensions

Name/value pairs that uniquely identify a metric. They are used for filtering and aggregation. You can have up to 10 dimensions per metric.

Value

The numeric value of the data point.

Unit

The unit of measurement (e.g., "Percent", "Bytes", "Count").

Custom Metric CLI Example

aws cloudwatch put-metric-data --metric-name ProcessedOrders --namespace "MyWebApp" --value 150 --unit Count --dimensions Environment=Production

High-Resolution Metrics

For applications that require faster insights, you can publish metrics at a high resolution, down to a 1-second interval. This allows for more granular monitoring and faster alarm triggering.

Resolution Options

  • Standard Resolution: Data has a granularity of 1 minute.
  • High Resolution: Data can have a granularity of 1, 5, 10, or 30 seconds.

Use Cases

  • Real-time application monitoring
  • High-frequency trading systems
  • Performance testing
Cost Consideration High-resolution metrics are priced higher than standard resolution metrics.

Key Takeaways

1
Default metrics are provided automatically by AWS services, but OS-level metrics like memory require the CloudWatch Agent.
2
Custom metrics are published using the `PutMetricData` API and are essential for application-level monitoring.
3
Metrics are defined by a Namespace, MetricName, and up to 10 Dimensions.
4
High-resolution metrics provide sub-minute granularity for real-time monitoring but come at a higher cost.