LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

aws-cloudwatch

Monitor resources with metrics, alarms, and dashboards.

TLDR

Put custom metric data to CloudWatch
$ aws cloudwatch put-metric-data --namespace [MyApp] --metric-name [RequestCount] --value [1] --unit Count
copy
Get metric statistics for an EC2 instance CPU
$ aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --dimensions Name=InstanceId,Value=[i-1234567890abcdef0] --start-time [2024-01-01T00:00:00Z] --end-time [2024-01-02T00:00:00Z] --period 3600 --statistics Average
copy
Create an alarm for high CPU usage
$ aws cloudwatch put-metric-alarm --alarm-name [high-cpu] --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold 80 --comparison-operator GreaterThanThreshold --evaluation-periods 2 --alarm-actions [arn:aws:sns:us-east-1:123456789012:my-topic] --dimensions Name=InstanceId,Value=[i-1234567890abcdef0]
copy
List all alarms in the account
$ aws cloudwatch describe-alarms
copy
List available metrics for a namespace
$ aws cloudwatch list-metrics --namespace [AWS/EC2]
copy
Delete specific alarms
$ aws cloudwatch delete-alarms --alarm-names [high-cpu] [low-disk]
copy
Disable actions on an alarm
$ aws cloudwatch disable-alarm-actions --alarm-names [high-cpu]
copy
Enable actions on an alarm
$ aws cloudwatch enable-alarm-actions --alarm-names [high-cpu]
copy

SYNOPSIS

aws cloudwatch command [options]

DESCRIPTION

aws cloudwatch is the AWS CLI interface for Amazon CloudWatch, a monitoring and observability service for AWS resources and applications. CloudWatch collects metrics, logs, and events, providing visibility into resource utilization, application performance, and operational health.CloudWatch enables setting alarms that trigger notifications or automated actions based on metric thresholds. It supports both built-in AWS service metrics and custom application metrics.

COMMANDS

put-metric-data

Publish custom metric data points
get-metric-data
Retrieve metric values using queries
get-metric-statistics
Get statistics for a specific metric
list-metrics
List available metrics by namespace
put-metric-alarm
Create or update a metric alarm
describe-alarms
List configured alarms and their states
set-alarm-state
Manually set alarm state for testing
put-dashboard
Create or update a CloudWatch dashboard
delete-alarms
Delete one or more alarms
enable-alarm-actions
Enable actions for specified alarms
disable-alarm-actions
Disable actions for specified alarms
describe-alarms-for-metric
List alarms associated with a specific metric
list-tags-for-resource
List tags for a CloudWatch resource
put-anomaly-detector
Create an anomaly detection model for a metric

CAVEATS

Metric data older than 15 months is automatically deleted. High-resolution metrics (1-second granularity) incur additional costs. Custom metrics are charged per metric per month. Alarm evaluations may be delayed during service disruptions.

HISTORY

Amazon CloudWatch launched in May 2009 alongside EC2 monitoring. Custom metrics were added in 2011, dashboards in 2015, and anomaly detection in 2019. The service has evolved to become the central monitoring hub for all AWS services and is now integrated with CloudWatch Logs and EventBridge.

SEE ALSO

aws(1), aws-logs(1), aws-events(1), aws-ec2(1), aws-sns(1)

Copied to clipboard
Kai