Class: Aws::CloudWatch::CompositeAlarm
- Inherits:
-
Object
- Object
- Aws::CloudWatch::CompositeAlarm
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-cloudwatch/composite_alarm.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#actions_enabled ⇒ Boolean
Indicates whether actions should be executed during any changes to the alarm state.
-
#actions_suppressed_by ⇒ String
When the value is ‘ALARM`, it means that the actions are suppressed because the suppressor alarm is in `ALARM` When the value is `WaitPeriod`, it means that the actions are suppressed because the composite alarm is waiting for the suppressor alarm to go into into the `ALARM` state.
-
#actions_suppressed_reason ⇒ String
Captures the reason for action suppression.
-
#actions_suppressor ⇒ String
Actions will be suppressed if the suppressor alarm is in the ‘ALARM` state.
-
#actions_suppressor_extension_period ⇒ Integer
The maximum time in seconds that the composite alarm waits after suppressor alarm goes out of the ‘ALARM` state.
-
#actions_suppressor_wait_period ⇒ Integer
The maximum time in seconds that the composite alarm waits for the suppressor alarm to go into the ‘ALARM` state.
-
#alarm_actions ⇒ Array<String>
The actions to execute when this alarm transitions to the ALARM state from any other state.
-
#alarm_arn ⇒ String
The Amazon Resource Name (ARN) of the alarm.
-
#alarm_configuration_updated_timestamp ⇒ Time
The time stamp of the last update to the alarm configuration.
-
#alarm_description ⇒ String
The description of the alarm.
-
#alarm_rule ⇒ String
The rule that this alarm uses to evaluate its alarm state.
-
#insufficient_data_actions ⇒ Array<String>
The actions to execute when this alarm transitions to the INSUFFICIENT_DATA state from any other state.
- #name ⇒ String (also: #alarm_name)
-
#ok_actions ⇒ Array<String>
The actions to execute when this alarm transitions to the OK state from any other state.
-
#state_reason ⇒ String
An explanation for the alarm state, in text format.
-
#state_reason_data ⇒ String
An explanation for the alarm state, in JSON format.
-
#state_transitioned_timestamp ⇒ Time
The timestamp of the last change to the alarm’s ‘StateValue`.
-
#state_updated_timestamp ⇒ Time
Tracks the timestamp of any state update, even if ‘StateValue` doesn’t change.
-
#state_value ⇒ String
The state value for the alarm.
Actions collapse
- #delete(options = {}) ⇒ EmptyStructure
- #describe_history(options = {}) ⇒ Types::DescribeAlarmHistoryOutput
- #disable_actions(options = {}) ⇒ EmptyStructure
- #enable_actions(options = {}) ⇒ EmptyStructure
- #identifiers ⇒ Object deprecated private Deprecated.
- #set_state(options = {}) ⇒ EmptyStructure
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::CompositeAlarm
Returns the data for this CompositeAlarm.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#exists?(options = {}) ⇒ Boolean
Returns ‘true` if the CompositeAlarm exists.
-
#initialize(*args) ⇒ CompositeAlarm
constructor
A new instance of CompositeAlarm.
-
#load ⇒ self
(also: #reload)
Loads, or reloads #data for the current CompositeAlarm.
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::CloudWatch::Client] #wait_until instead
- #wait_until_exists(options = {}, &block) ⇒ CompositeAlarm
Constructor Details
#initialize(name, options = {}) ⇒ CompositeAlarm #initialize(options = {}) ⇒ CompositeAlarm
Returns a new instance of CompositeAlarm.
22 23 24 25 26 27 28 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 22 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @name = extract_name(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#actions_enabled ⇒ Boolean
Indicates whether actions should be executed during any changes to the alarm state.
41 42 43 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 41 def actions_enabled data[:actions_enabled] end |
#actions_suppressed_by ⇒ String
When the value is ‘ALARM`, it means that the actions are suppressed because the suppressor alarm is in `ALARM` When the value is `WaitPeriod`, it means that the actions are suppressed because the composite alarm is waiting for the suppressor alarm to go into into the `ALARM` state. The maximum waiting time is as specified in `ActionsSuppressorWaitPeriod`. After this time, the composite alarm performs its actions. When the value is `ExtensionPeriod`, it means that the actions are suppressed because the composite alarm is waiting after the suppressor alarm went out of the `ALARM` state. The maximum waiting time is as specified in `ActionsSuppressorExtensionPeriod`. After this time, the composite alarm performs its actions.
136 137 138 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 136 def actions_suppressed_by data[:actions_suppressed_by] end |
#actions_suppressed_reason ⇒ String
Captures the reason for action suppression.
142 143 144 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 142 def actions_suppressed_reason data[:actions_suppressed_reason] end |
#actions_suppressor ⇒ String
Actions will be suppressed if the suppressor alarm is in the ‘ALARM` state. `ActionsSuppressor` can be an AlarmName or an Amazon Resource Name (ARN) from an existing alarm.
150 151 152 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 150 def actions_suppressor data[:actions_suppressor] end |
#actions_suppressor_extension_period ⇒ Integer
The maximum time in seconds that the composite alarm waits after suppressor alarm goes out of the ‘ALARM` state. After this time, the composite alarm performs its actions.
‘ExtensionPeriod` is required only when `ActionsSuppressor` is specified.
171 172 173 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 171 def actions_suppressor_extension_period data[:actions_suppressor_extension_period] end |
#actions_suppressor_wait_period ⇒ Integer
The maximum time in seconds that the composite alarm waits for the suppressor alarm to go into the ‘ALARM` state. After this time, the composite alarm performs its actions.
‘WaitPeriod` is required only when `ActionsSuppressor` is specified.
160 161 162 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 160 def actions_suppressor_wait_period data[:actions_suppressor_wait_period] end |
#alarm_actions ⇒ Array<String>
The actions to execute when this alarm transitions to the ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
49 50 51 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 49 def alarm_actions data[:alarm_actions] end |
#alarm_arn ⇒ String
The Amazon Resource Name (ARN) of the alarm.
55 56 57 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 55 def alarm_arn data[:alarm_arn] end |
#alarm_configuration_updated_timestamp ⇒ Time
The time stamp of the last update to the alarm configuration.
61 62 63 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 61 def data[:alarm_configuration_updated_timestamp] end |
#alarm_description ⇒ String
The description of the alarm.
67 68 69 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 67 def alarm_description data[:alarm_description] end |
#alarm_rule ⇒ String
The rule that this alarm uses to evaluate its alarm state.
73 74 75 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 73 def alarm_rule data[:alarm_rule] end |
#client ⇒ Client
178 179 180 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 178 def client @client end |
#data ⇒ Types::CompositeAlarm
Returns the data for this Aws::CloudWatch::CompositeAlarm. Calls Aws::CloudWatch::Client#describe_alarms if #data_loaded? is ‘false`.
200 201 202 203 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 200 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
208 209 210 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 208 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
351 352 353 354 355 356 357 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 351 def delete( = {}) = Aws::Util.deep_merge(, alarm_names: [@name]) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.delete_alarms() end resp.data end |
#describe_history(options = {}) ⇒ Types::DescribeAlarmHistoryOutput
392 393 394 395 396 397 398 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 392 def describe_history( = {}) = .merge(alarm_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_alarm_history() end resp.data end |
#disable_actions(options = {}) ⇒ EmptyStructure
405 406 407 408 409 410 411 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 405 def disable_actions( = {}) = Aws::Util.deep_merge(, alarm_names: [@name]) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.disable_alarm_actions() end resp.data end |
#enable_actions(options = {}) ⇒ EmptyStructure
418 419 420 421 422 423 424 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 418 def enable_actions( = {}) = Aws::Util.deep_merge(, alarm_names: [@name]) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.enable_alarm_actions() end resp.data end |
#exists?(options = {}) ⇒ Boolean
Returns ‘true` if the CompositeAlarm exists.
215 216 217 218 219 220 221 222 223 224 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 215 def exists?( = {}) begin wait_until_exists(.merge(max_attempts: 1)) true rescue Aws::Waiters::Errors::UnexpectedError => e raise e.error rescue Aws::Waiters::Errors::WaiterFailed false end end |
#identifiers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
458 459 460 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 458 def identifiers { name: @name } end |
#insufficient_data_actions ⇒ Array<String>
The actions to execute when this alarm transitions to the INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
81 82 83 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 81 def insufficient_data_actions data[:insufficient_data_actions] end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::CloudWatch::CompositeAlarm. Returns ‘self` making it possible to chain methods.
composite_alarm.reload.data
188 189 190 191 192 193 194 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 188 def load resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_alarms(alarm_names: [@name]) end @data = resp.composite_alarms[0] self end |
#name ⇒ String Also known as: alarm_name
33 34 35 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 33 def name @name end |
#ok_actions ⇒ Array<String>
The actions to execute when this alarm transitions to the OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
89 90 91 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 89 def ok_actions data[:ok_actions] end |
#set_state(options = {}) ⇒ EmptyStructure
448 449 450 451 452 453 454 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 448 def set_state( = {}) = .merge(alarm_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.set_alarm_state() end resp.data end |
#state_reason ⇒ String
An explanation for the alarm state, in text format.
95 96 97 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 95 def state_reason data[:state_reason] end |
#state_reason_data ⇒ String
An explanation for the alarm state, in JSON format.
101 102 103 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 101 def state_reason_data data[:state_reason_data] end |
#state_transitioned_timestamp ⇒ Time
The timestamp of the last change to the alarm’s ‘StateValue`.
120 121 122 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 120 def data[:state_transitioned_timestamp] end |
#state_updated_timestamp ⇒ Time
Tracks the timestamp of any state update, even if ‘StateValue` doesn’t change.
108 109 110 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 108 def data[:state_updated_timestamp] end |
#state_value ⇒ String
The state value for the alarm.
114 115 116 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 114 def state_value data[:state_value] end |
#wait_until(options = {}) {|resource| ... } ⇒ Resource
Use [Aws::CloudWatch::Client] #wait_until instead
The waiting operation is performed on a copy. The original resource remains unchanged.
Waiter polls an API operation until a resource enters a desired state.
## Basic Usage
Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.
# polls in a loop until condition is true
resource.wait_until() {|resource| condition}
## Example
instance.wait_until(max_attempts:10, delay:5) do |instance|
instance.state.name == 'running'
end
## Configuration
You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:
# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}
## Callbacks
You can be notified before each polling attempt and before each delay. If you throw ‘:success` or `:failure` from these callbacks, it will terminate the waiter.
started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
throw :failure if Time.now - started_at > 3600
end
# disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}
## Handling Errors
When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.
begin
resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
# resource did not enter the desired state in time
end
attempts attempt in seconds invoked before each attempt invoked before each wait
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 325 def wait_until( = {}, &block) self_copy = self.dup attempts = 0 [:max_attempts] = 10 unless .key?(:max_attempts) [:delay] ||= 10 [:poller] = Proc.new do attempts += 1 if block.call(self_copy) [:success, self_copy] else self_copy.reload unless attempts == [:max_attempts] :retry end end Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do Aws::Waiters::Waiter.new().wait({}) end end |
#wait_until_exists(options = {}, &block) ⇒ CompositeAlarm
232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 232 def wait_until_exists( = {}, &block) , params = () waiter = Waiters::CompositeAlarmExists.new() yield_waiter_and_warn(waiter, &block) if block_given? Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do waiter.wait(params.merge(alarm_names: [@name])) end CompositeAlarm.new({ name: @name, client: @client }) end |