← 返回命令列表

Linux command

aws-cloudwatch 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Put custom metric data

aws cloudwatch put-metric-data --namespace [MyApp] --metric-name [RequestCount] --value [1] --unit Count

Get metric statistics

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

Create an alarm

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]

List all alarms

aws cloudwatch describe-alarms

List available metrics

aws cloudwatch list-metrics --namespace [AWS/EC2]

Delete specific

aws cloudwatch delete-alarms --alarm-names [high-cpu] [low-disk]

Disable actions

aws cloudwatch disable-alarm-actions --alarm-names [high-cpu]

Enable actions

aws cloudwatch enable-alarm-actions --alarm-names [high-cpu]

说明

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.

FAQ

What is the aws-cloudwatch command used for?

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.

How do I run a basic aws-cloudwatch example?

Run `aws cloudwatch put-metric-data --namespace [MyApp] --metric-name [RequestCount] --value [1] --unit Count` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more aws-cloudwatch examples?

This page includes 8 examples for aws-cloudwatch, plus related commands for nearby Linux tasks.