@attr_reader [String] metric_name
@attr_reader [String] namespace
@attr_reader [Array<Hash>] dimensions
@attr_reader [Boolean] enabled Indicates whether actions
should be executed during any changes to the alarm's state.
@attr_reader [Array<String>] alarm_actions The list of actions to execute
when this alarm transitions into an ALARM state from any other state.
@attr_reader [String] arn The Amazon Resource Name (ARN) of the alarm.
@attr_reader [Time] configuration_updated_timestamp
The time stamp of the last update to the alarm configuration.
@attr_reader [String] description The description for the alarm.
@attr_reader [String] comparison_operator The arithmetic operation to
use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand.
@attr_reader [Integer] evaluation_periods The number of periods over
which data is compared to the specified threshold.
@attr_reader [Array<Hash>] insufficient_data_actions The list of
actions to execute when this alarm transitions into an INSUFFICIENT_DATA state
@attr_reader [Array<Hash>] ok_actions The list of actions to execute
when this alarm transitions into an OK state.
@attr_reader [Integer] period The period in seconds over which the
statistic is applied.
@attr_reader [String] state_reason A human-readable explanation for
the alarm's state.
@attr_reader [String] state_reason_data An explanation for the alarm's
state in machine-readable JSON format.
@attr_reader [Time] state_updated_timestamp When the alarm's state
last updated.
@attr_reader [String] state_value The state value for the alarm.
@attr_reader [Float] threshold The value against which the specified
statistic is compared.
@attr_reader [String] unit The unit of the alarm's associated metric.
@return [String]
@return [String]
@private
# File lib/aws/cloud_watch/alarm.rb, line 73 def initialize alarm_name, options = {} @alarm_name = alarm_name super end
Deletes the current alarm. @return [nil]
# File lib/aws/cloud_watch/alarm.rb, line 208 def delete client.delete_alarms(:alarm_names => [ alarm_name ]) nil end
Disable the current alarm actions. @return [nil]
# File lib/aws/cloud_watch/alarm.rb, line 215 def disable client.disable_alarm_actions(:alarm_names => [ alarm_name ]) nil end
Enable the current alarm actions. @return [nil]
# File lib/aws/cloud_watch/alarm.rb, line 222 def enable client.enable_alarm_actions(:alarm_names => [ alarm_name ]) nil end
@return [Boolean] Returns true if this alarm exists.
# File lib/aws/cloud_watch/alarm.rb, line 228 def exists? !get_resource.data[:metric_alarms].empty? end
Returns a collection of the history items for current alarm. @return [AlarmHistoryItemCollection]
# File lib/aws/cloud_watch/alarm.rb, line 234 def history_items options = {} AlarmHistoryItemCollection.new(:config => config).with_alarm_name(name) end
@return [Metric]
# File lib/aws/cloud_watch/alarm.rb, line 145 def metric options = {} options[:dimensions] = dimensions unless dimensions.empty? options[:config] = config Metric.new(namespace, metric_name, options) end
Temporarily sets the state of current alarm. @param [String] reason The reason that this alarm is set to this
specific state (in human-readable text format).
@param [String] value Valid values include:
* 'OK' * 'ALARM' * 'INSUFFICIENT_DATA'
@param [Hash] options @option options [String] :state_reason_data The reason that this
alarm is set to this specific state (in machine-readable JSON format)
@return [nil]
# File lib/aws/cloud_watch/alarm.rb, line 252 def set_state reason, value, options = {} options[:alarm_name] = alarm_name options[:state_reason] = reason options[:state_value] = value client.set_alarm_state(options) nil end
Updates the metric alarm.
@option options [String,required] :comparison_operator The arithmetic
operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Valid values include: * 'GreaterThanOrEqualToThreshold' * 'GreaterThanThreshold' * 'LessThanThreshold' * 'LessThanOrEqualToThreshold'
@option options [Integer,required] :evaluation_periods The number
of periods over which data is compared to the specified threshold.
@option options [Integer,required] :period The period in seconds
over which the specified statistic is applied.
@option options [String,required] :statistic The statistic to apply
to the alarm's associated metric. Valid values include: * 'SampleCount' * 'Average' * 'Sum' * 'Minimum' * 'Maximum'
@option options [Number,required] :threshold The value against which
the specified statistic is compared.
@option options [Array<String>] :insufficient_data_actions
The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Number (ARN). Currently the only action supported is publishing to an Amazon SNS topic or an Amazon Auto Scaling policy.
@option options [Array<String>] :ok_actions The list of actions to
execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Number (ARN). Currently the only action supported is publishing to an Amazon SNS topic or an Amazon Auto Scaling policy.
@option options [Boolean] :actions_enabled Indicates whether or not
actions should be executed during any changes to the alarm's state.
@option options [Array<String>] :alarm_actions The list of actions
to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Number (ARN). Currently the only action supported is publishing to an Amazon SNS topic or an Amazon Auto Scaling policy. Maximum of 5 alarm actions.
@option options [String] :alarm_description The description for
the alarm.
@option options [String] :unit The unit for the alarm's associated
metric.
@return [nil]
# File lib/aws/cloud_watch/alarm.rb, line 200 def update options = {} options[:alarm_name] = alarm_name client.put_metric_alarm(options) nil end
# File lib/aws/cloud_watch/alarm.rb, line 266 def get_resource attr_name = nil client.describe_alarms(:alarm_names => [ alarm_name ]) end
# File lib/aws/cloud_watch/alarm.rb, line 262 def resource_identifiers [[:alarm_name, alarm_name]] end