user1654528
user1654528

Reputation: 395

How to get AWS Status Checks for an Instance

I am trying to retrieve, via AMAZON CLI tools, the 'Status Checks' information, which is displayed for an EC2 Instance in the console. For example 'Pending' or '2/2 checks passed'. I have used the following command:

  ec2-describe-instances [instance_id ...]

However, it only returns Instance State info such as 'Running', 'Stopping' etc. I want the more granular information as displayed in the Status Checks column in the AWS Console. Does anyone know the command to retrieve this information for an instance?

Upvotes: 3

Views: 2347

Answers (1)

Anthony Neace
Anthony Neace

Reputation: 26003

You're looking for describe-instance-status. This will return, among other things, both the System Status and Instance Status as displayed on the 'Status Check' tab in the EC2 web console.

Example Request as made for a running, healthy instance:

aws ec2 describe-instance-status --instance-ids i-abcd1234

Example Output as made for a running, healthy instance:

{
    "InstanceStatuses": [
        {
            "InstanceId": "i-abcd1234",
            "InstanceState": {
                "Code": 16,
                "Name": "running"
            },
            "AvailabilityZone": "us-east-1a",
            "SystemStatus": {
                "Status": "ok",
                "Details": [
                    {
                        "Status": "passed",
                        "Name": "reachability"
                    }
                ]
            },
            "InstanceStatus": {
                "Status": "ok",
                "Details": [
                    {
                        "Status": "passed",
                        "Name": "reachability"
                    }
                ]
            }
        }
    ]
}

If you want to review historical status checks, you can do so via CloudWatch (linked documentation) by reviewing the following EC2 metrics:

  • StatusCheckFailed_Instance
  • StatusCheckFailed_System

Upvotes: 5

Related Questions