I have set "root-disk-space-utilization" and "data-disk-space-utilization" for my ec2 instance. The code to set "root-disk-space-utilization":
aws cloudwatch put-metric-alarm
--alarm-name root-disk-space-utilization
--alarm-description "Alarm when root disk space exceeds $ROOT_DISK_THRESHOLD percent"
--metric-name DiskSpaceUtilization
--namespace System/Linux
--statistic Average
--period $period
--threshold $ROOT_DISK_THRESHOLD
--treat-missing-data notBreaching
--comparison-operator GreaterThanThreshold
--dimensions Name=Filesystem,Value=$ROOT_DEVICE Name=InstanceId,Value=$val Name=MountPath,Value=$ROOT_PATH
--evaluation-periods 1
--alarm-actions $arn
--ok-actions $arn
--unit Percent
Here, ROOT_DEVICE=/dev/sda1 ; DATA_DEVICE=/dev/sdf ; ROOT_PATH=/ ; DATA_PATH=/data .
To set "data-disk-space-utilization":
aws cloudwatch put-metric-alarm
--alarm-name data-disk-space-utilization
--alarm-description "Alarm when data disk space exceeds $DATA_DISK_THRESHOLD percent"
--metric-name DiskSpaceUtilization
--namespace System/Linux
--statistic Average
--period $period
--threshold $DATA_DISK_THRESHOLD
--treat-missing-data notBreaching
--comparison-operator GreaterThanThreshold
--dimensions Name=Filesystem,Value=$DATA_DEVICE Name=InstanceId,Value=$val Name=MountPath,Value=$DATA_PATH
--evaluation-periods 1
--alarm-actions $arn
--ok-actions $arn
--unit Percent
With the help of above code, I am able to set the cloudwatch metrics but none is getting in "Alarm State". I have also tried and changed the threshold to 1, just to check if it goes in the "Alarm State" but still it did not changed.
I am a bit unsure if my above code is correct or not and how will it trigger Alarm?
question from:
https://stackoverflow.com/questions/65618107/how-to-test-diskspaceutilization-alarm-for-my-ec2-instance 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…