Bootstrap FreeKB - Amazon Web Services (AWS) - Delete Cloudwatch Alarms using the AWS CLI
Amazon Web Services (AWS) - Delete Cloudwatch Alarms using the AWS CLI

Updated:   |  Amazon Web Services (AWS) articles

This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.

Cloudwatch alarms can be used to alert you when some conditiion is met, such as if an EC2 instance is unavailable due to high CPU or high memory usage.

The aws cloudwatch describe-alarms command can be used to list the cloudwatch alarms you have created.

aws cloudwatch describe-alarms

 

If one of more cloudwatch alarms have been created, something like this should be returned.

{
    "MetricAlarms": [
        {
            "AlarmName": "high-cpu",
            "AlarmArn": "arn:aws:cloudwatch:us-east-1:713123474299:alarm:high-cpu",
            "AlarmDescription": "Alarm when CPU exceeds 70 percent",
            "AlarmConfigurationUpdatedTimestamp": "2023-06-21T01:53:16.629000+00:00",
            "ActionsEnabled": true,
            "OKActions": [],
            "AlarmActions": [
                "arn:aws:sns:us-east-1:713123474299:my-topic"
            ],
            "InsufficientDataActions": [],
            "StateValue": "OK",
            "StateReason": "Threshold Crossed: 2 datapoints [1.3967213114600159 (21/06/23 01:44:00), 1.234648513479913 (21/06/23 01:39:00)] were not greater than the threshold (70.0).",
            "StateReasonData": "{\"version\":\"1.0\",\"queryDate\":\"2023-06-21T01:54:00.142+0000\",\"startDate\":\"2023-06-21T01:39:00.000+0000\",\"unit\":\"Percent\",\"statistic\":\"Average\",\"period\":300,\"recentDatapoints\":[1.234648513479913,1.3967213114600159],\"threshold\":70.0,\"evaluatedDatapoints\":[{\"timestamp\":\"2023-06-21T01:44:00.000+0000\",\"sampleCount\":5.0,\"value\":1.3967213114600159}]}",
            "StateUpdatedTimestamp": "2023-06-21T01:54:00.144000+00:00",
            "MetricName": "CPUUtilization",
            "Namespace": "AWS/EC2",
            "Statistic": "Average",
            "Dimensions": [
                {
                    "Name": "InstanceId",
                    "Value": "i-0d241234f9665abcd"
                }
            ],
            "Period": 300,
            "Unit": "Percent",
            "EvaluationPeriods": 2,
            "Threshold": 70.0,
            "ComparisonOperator": "GreaterThanThreshold"
        }
    ],
    "CompositeAlarms": []
}

 

The aws cloudwatch delete-alarms command can be used to delete one or more cloudwatch alarms.

aws cloudwatch delete-alarms --alarm-names high-cpu

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 2d7e8f in the box below so that we can be sure you are a human.