LinuxCommandLibrary

aws-cloudwatch

Manage and monitor AWS CloudWatch resources

TLDR

List dashboards for your account

$ aws cloudwatch list-dashboards
copy

Display details for the specified dashboard
$ aws cloudwatch get-dashboard --dashboard-name [dashboard_name]
copy

List metrics
$ aws cloudwatch list-metrics
copy

List alarms
$ aws cloudwatch describe-alarms
copy

Create or update an alarm and associate it with a metric
$ aws cloudwatch put-metric-alarm --alarm-name [alarm_name] --evaluation-periods [evaluation_periods] --comparison-operator [comparison_operator]
copy

Delete the specified alarms
$ aws cloudwatch delete-alarms --alarm-names [alarm_names]
copy

Delete the specified dashboards
$ aws cloudwatch delete-dashboards --dashboard-names [dashboard_names]
copy

SYNOPSIS

aws cloudwatch <subcommand> [options] [--generate-cli-skeleton]

PARAMETERS

--debug
    Turn on debug logging

--endpoint-url
    Override default endpoint URL

--no-verify-ssl
    Disable SSL certificate verification

--cli-read-timeout
    Max CLI runtime in seconds

--cli-connect-timeout
    Max socket connect time in seconds

--output
    Output format: json|text|table

--query
    JMESPath query for output filtering

--profile
    Use specific profile from credentials file

--region
    AWS region (e.g., us-east-1)

--version
    Show version and exit

--color
    Color output: on|off|auto

--no-cli-pager
    Disable cli pager for output

--cli-binary-format
    Binary format: raw-in-base64-out|base64|raw-in

DESCRIPTION

The aws cloudwatch command is part of the AWS Command Line Interface (CLI), enabling interaction with Amazon CloudWatch, a monitoring and observability service. It allows users to manage metrics, alarms, logs, events, and dashboards from the Linux terminal.

Key functionalities include putting custom metric data, listing alarms, describing metric statistics, and querying logs via CloudWatch Logs Insights. For example, monitor CPU usage on EC2 instances or set alarms for high latency.

Requires AWS CLI installed (pip install awscli or package manager) and configured with credentials (aws configure). Supports JSON output for scripting. Ideal for automation in CI/CD pipelines, serverless apps, or infrastructure as code with tools like Terraform.

Subcommands handle specific operations: alarms for notifications, metrics for data retrieval, logs for log groups/streams. Integrates with other AWS services like Lambda, ECS, and EKS for comprehensive observability. Usage scales from simple queries to complex dashboards exported as JSON.

CAVEATS

Requires AWS credentials with CloudWatch permissions; high-volume metric puts may incur costs; IAM policies must allow cloudwatch:* actions; not for real-time dashboards (use Console).

COMMON SUBCOMMANDS

list-metrics: List available metrics.
put-metric-data: Publish custom metrics.
describe-alarms: View alarm states.
get-metric-statistics: Retrieve data points.

EXAMPLE USAGE

aws cloudwatch put-metric-data --namespace AWS/EC2 --metric-name CPUUtilization --value 80 --unit Percent
aws cloudwatch describe-alarms --state-value ALARM

HISTORY

Introduced in AWS CLI v1 (2013); enhanced in v2 (2020) with faster execution and broader subcommands. CloudWatch CLI evolved with service features like Contributor Insights (2019) and Logs Insights (2018).

SEE ALSO

aws(1), aws-ec2(1), aws-lambda(1), jq(1)

Copied to clipboard