Bootstrap FreeKB - Amazon Web Services (AWS) - List Cloudwatch Alarm History using the AWS CLI
Amazon Web Services (AWS) - List Cloudwatch Alarm History 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 condition is met, such as:

  • an EC2 instance has high CPU or high memory usage
  • an EC2 instance in a Load Balancer Target Group health check returns "unhealthy"
  • a Lambda Function has one or more errors

The aws cloudwatch describe-alarms command can be used to list the cloudwatch alarms you have created. Something like this should be returned.

~] aws cloudwatch describe-alarms
{
    "MetricAlarms": [
        {
            "AlarmName": "my-cloudwatch-alarm",
            "AlarmArn": "arn:aws:cloudwatch:us-east-1:123456789012:alarm:my-cloudwatch-alarm",
            "AlarmDescription": "CPU Utilization exceeds 10% in the last 5 minutes",
            "AlarmConfigurationUpdatedTimestamp": "2023-06-21T01:53:16.629000+00:00",
            "ActionsEnabled": true,
            "OKActions": [],
            "AlarmActions": [
                "arn:aws:sns:us-east-1:123456789012:my-topic"
            ],
            "InsufficientDataActions": [
                "arn:aws:sns:us-east-1:123456789012:my-topic"
            ],
            "StateValue": "OK",
            "StateReason": "Threshold Crossed: 1 datapoints [1.3967213114600159 (21/06/23 01:44:00)] was not greater than the threshold (10.0).",
            "StateReasonData": "{\"version\":\"1.0\",\"queryDate\":\"2024-01-16T06:23:48.140+0000\",\"startDate\":\"2024-01-16T06:20:00.000+0000\",\"unit\":\"Percent\",\"statistic\":\"Average\",\"period\":60,\"recentDatapoints\":[0.0015606770489069999],\"threshold\":10.0,\"evaluatedDatapoints\":[{\"timestamp\":\"2024-01-16T06:20:00.000+0000\",\"sampleCount\":1.0,\"value\":0.0015606770489069999}]}",
            "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": 1,
            "Threshold": 10.0,
            "ComparisonOperator": "GreaterThanThreshold"
        }
    ],
    "CompositeAlarms": []
}

 

 The aws cloudwatch describe-alarm-history command can be used to view the history of one or more of your Cloudwatch alarms.

~]$ aws cloudwatch describe-alarm-history --alarm-name "my-cloudwatch-alarm"
{
    "AlarmHistoryItems": [
        {
            "AlarmName": "my-cloudwatch-alarm",
            "AlarmType": "MetricAlarm",
            "Timestamp": "2025-11-06T10:39:26.248000+00:00",
            "HistoryItemType": "StateUpdate",
            "HistorySummary": "Alarm updated from ALARM to OK"
        },
        {
            "AlarmName": "my-cloudwatch-alarm",
            "AlarmType": "MetricAlarm",
            "Timestamp": "2025-11-06T11:29:29.247000+00:00",
            "HistoryItemType": "Action",
            "HistorySummary": "Successfully executed action arn:aws:sns:us-east-1:123456789012:my-topic"
        },        
        {
            "AlarmName": "my-cloudwatch-alarm",
            "AlarmType": "MetricAlarm",
            "Timestamp": "2025-11-06T10:29:26.248000+00:00",
            "HistoryItemType": "StateUpdate",
            "HistorySummary": "Alarm updated from OK to ALARM"
        }
]

 




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 97670d in the box below so that we can be sure you are a human.