How it works...

In this recipe, we created an alarm for a metric using the aws cloudwatch put-metric-alarm command. The metric may not be available at the time of the alarm's creation, in which case the alarm will remain in the state INSUFFICIENT_DATA.

We used the following properties of the put-metric-alarm sub-command:

  • metric-name is the name of the metric with which we want to associate this alarm.
  • namespace is the namespace of the metric.
  • statistic is the statistic operation for the metric and can have one of the following values: SampleCountAverageSumMinimum, or Maximum. To find the percentile, we need to use the extended-statistic property instead.
  • period is the length, in seconds, of each time that the specified metric is evaluated. Valid values are 10, 30, and any multiple of 60. We specified 60.
  • threshold is the value that the comparison operator option value uses for calculating whether an ALARM state has been reached. We specified a value of 5.
  • comparison-operator specifies the comparison operator to use. We used GreaterThanOrEqualToThreshold.
  • evaluation-periods is the number of periods over which the data is compared to the threshold. For example, we can set an alarm that triggers when five consecutive data points are breached. We specified a value of 1 for the alarm to be triggered when only one data point is breached.
  • alarm-actions is the ARN of actions to execute when this alarm transitions to the ALARM state from any other state. 

The alarm may belong to one of the following states:

  • OK - Denotes that the alarm has not been triggered.
  • ALARM - Denotes that the alarm was triggered.
  • NOT_SUFFICIENT - Denotes that there is not enough data to determine the alarm stateā€”for example, there is no data within the time period specified by the alarm. An alarm just created will also be in this state for a little bit of time.

When an alarm goes to the INSUFFICIENT_DATA state immediately after the alarm creation, it will give a StateReason of Unchecked: Initial alarm creation. Once the alarm is in an OK or ALARM state and then goes to the INSUFFICIENT_DATA state because there is not enough data within the evaluation period, it gives a StateReason as Insufficient Data: 1 datapoint was unknown, as follows:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.212.217