Class: AWS::CloudWatch::Alarm
- Inherits:
-
AWS::Core::Resource
- Object
- AWS::Core::Resource
- AWS::CloudWatch::Alarm
- Defined in:
- lib/aws/cloud_watch/alarm.rb
Instance Attribute Summary collapse
-
#alarm_actions ⇒ Array<String>
(also: #actions)
readonly
The list of actions to execute when this alarm transitions into an ALARM state from any other state.
- #alarm_name ⇒ String (also: #name) readonly
-
#comparison_operator ⇒ String
readonly
The arithmetic operation to use when comparing the specified Statistic and Threshold.
-
#dimensions ⇒ Array<Hash>
readonly
The current value of dimensions.
-
#evaluation_periods ⇒ Integer
readonly
The number of periods over which data is compared to the specified threshold.
-
#insufficient_data_actions ⇒ Array<Hash>
readonly
The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state.
-
#metric_name ⇒ String
readonly
The current value of metric_name.
-
#namespace ⇒ String
readonly
The current value of namespace.
-
#ok_actions ⇒ Array<Hash>
readonly
The list of actions to execute when this alarm transitions into an OK state.
-
#period ⇒ Integer
readonly
The period in seconds over which the statistic is applied.
-
#state_reason ⇒ String
readonly
A human-readable explanation for the alarm's state.
-
#state_reason_data ⇒ String
readonly
An explanation for the alarm's state in machine-readable JSON format.
-
#state_updated_timestamp ⇒ Time
readonly
When the alarm's state last updated.
-
#state_value ⇒ String
readonly
The state value for the alarm.
-
#threshold ⇒ Float
readonly
The value against which the specified statistic is compared.
-
#unit ⇒ String
readonly
The unit of the alarm's associated metric.
Instance Method Summary collapse
-
#delete ⇒ nil
Deletes the current alarm.
-
#disable ⇒ nil
Disable the current alarm actions.
-
#enable ⇒ nil
Enable the current alarm actions.
-
#exists? ⇒ Boolean
Returns true if this alarm exists.
-
#history_items(options = {}) ⇒ AlarmHistoryItemCollection
(also: #history, #histories)
Returns a collection of the history items for current alarm.
- #metric ⇒ Metric
-
#set_state(reason, value, options = {}) ⇒ nil
Temporarily sets the state of current alarm.
-
#update(options = {}) ⇒ nil
Updates the metric alarm.
Instance Attribute Details
#alarm_actions ⇒ Array<String> (readonly) Also known as: actions
The list of actions to execute when this alarm transitions into an ALARM state from any other state.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def alarm_actions @alarm_actions end |
#alarm_name ⇒ String (readonly) Also known as: name
79 80 81 |
# File 'lib/aws/cloud_watch/alarm.rb', line 79 def alarm_name @alarm_name end |
#comparison_operator ⇒ String (readonly)
The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def comparison_operator @comparison_operator end |
#dimensions ⇒ Array<Hash> (readonly)
Returns the current value of dimensions.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def dimensions @dimensions end |
#evaluation_periods ⇒ Integer (readonly)
The number of periods over which data is compared to the specified threshold.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def evaluation_periods @evaluation_periods end |
#insufficient_data_actions ⇒ Array<Hash> (readonly)
The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def insufficient_data_actions @insufficient_data_actions end |
#metric_name ⇒ String (readonly)
Returns the current value of metric_name.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def metric_name @metric_name end |
#namespace ⇒ String (readonly)
Returns the current value of namespace.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def namespace @namespace end |
#ok_actions ⇒ Array<Hash> (readonly)
The list of actions to execute when this alarm transitions into an OK state.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def ok_actions @ok_actions end |
#period ⇒ Integer (readonly)
The period in seconds over which the statistic is applied.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def period @period end |
#state_reason ⇒ String (readonly)
A human-readable explanation for the alarm's state.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def state_reason @state_reason end |
#state_reason_data ⇒ String (readonly)
An explanation for the alarm's state in machine-readable JSON format.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def state_reason_data @state_reason_data end |
#state_updated_timestamp ⇒ Time (readonly)
When the alarm's state last updated.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def @state_updated_timestamp end |
#state_value ⇒ String (readonly)
The state value for the alarm.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def state_value @state_value end |
#threshold ⇒ Float (readonly)
The value against which the specified statistic is compared.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def threshold @threshold end |
#unit ⇒ String (readonly)
The unit of the alarm's associated metric.
70 71 72 |
# File 'lib/aws/cloud_watch/alarm.rb', line 70 def unit @unit end |
Instance Method Details
#delete ⇒ nil
Deletes the current alarm.
221 222 223 224 |
# File 'lib/aws/cloud_watch/alarm.rb', line 221 def delete client.delete_alarms(:alarm_names => [ alarm_name ]) nil end |
#disable ⇒ nil
Disable the current alarm actions.
228 229 230 231 |
# File 'lib/aws/cloud_watch/alarm.rb', line 228 def disable client.disable_alarm_actions(:alarm_names => [ alarm_name ]) nil end |
#enable ⇒ nil
Enable the current alarm actions.
235 236 237 238 |
# File 'lib/aws/cloud_watch/alarm.rb', line 235 def enable client.enable_alarm_actions(:alarm_names => [ alarm_name ]) nil end |
#exists? ⇒ Boolean
Returns true if this alarm exists.
241 242 243 |
# File 'lib/aws/cloud_watch/alarm.rb', line 241 def exists? !get_resource.data[:metric_alarms].empty? end |
#history_items(options = {}) ⇒ AlarmHistoryItemCollection Also known as: history, histories
Returns a collection of the history items for current alarm.
247 248 249 |
# File 'lib/aws/cloud_watch/alarm.rb', line 247 def history_items = {} AlarmHistoryItemCollection.new(:config => config).with_alarm_name(name) end |
#metric ⇒ Metric
145 146 147 148 149 150 |
# File 'lib/aws/cloud_watch/alarm.rb', line 145 def metric = {} [:dimensions] = dimensions unless dimensions.empty? [:config] = config Metric.new(namespace, metric_name, ) end |
#set_state(reason, value, options = {}) ⇒ nil
Temporarily sets the state of current alarm.
270 271 272 273 274 275 276 |
# File 'lib/aws/cloud_watch/alarm.rb', line 270 def set_state reason, value, = {} [:alarm_name] = alarm_name [:state_reason] = reason [:state_value] = value client.set_alarm_state() nil end |
#update(options = {}) ⇒ nil
Updates the metric alarm.
213 214 215 216 217 |
# File 'lib/aws/cloud_watch/alarm.rb', line 213 def update = {} [:alarm_name] = alarm_name client.put_metric_alarm() nil end |