Creating an alarm for an EC2 instance
As discussed, AWS provides in-built metrics for EC2 instances. Before creating an alarm, first let's find out the metrics that are provided by AWS for a specific EC2 Instance. For demonstration, I have an EC2 instance running in my account, which is running Amazon Linux. To find out all the default metrics related to the EC2 instance, you can use the cmdlet Get-CWMetricList
. It will list all the default metrics provided for the specific EC2 instance.
PS C:\> $p1 = New-Object Amazon.CloudWatch.Model.DimensionFilter PS C:\> $p1.Name = "InstanceId" PS C:\> $p1.Value = "i-09ca5e201782643e7" PS C:\> Get-CWMetricList -Namespace "AWS/EC2" -Dimension $p1

You have to use a filter, as shown preceding, to get the list for the specific instance. You can see that there are 14 different types of metrics provided for the EC2 instance. Because you know the list and the metrics provided, you can further narrow down your search for an instance for a specific...