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`.
198 199 200 201 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 198 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
206 207 208 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 206 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
345 346 347 348 349 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 345 def delete( = {}) = Aws::Util.deep_merge(, alarm_names: [@name]) resp = @client.delete_alarms() resp.data end |
#describe_history(options = {}) ⇒ Types::DescribeAlarmHistoryOutput
384 385 386 387 388 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 384 def describe_history( = {}) = .merge(alarm_name: @name) resp = @client.describe_alarm_history() resp.data end |
#disable_actions(options = {}) ⇒ EmptyStructure
395 396 397 398 399 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 395 def disable_actions( = {}) = Aws::Util.deep_merge(, alarm_names: [@name]) resp = @client.disable_alarm_actions() resp.data end |
#enable_actions(options = {}) ⇒ EmptyStructure
406 407 408 409 410 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 406 def enable_actions( = {}) = Aws::Util.deep_merge(, alarm_names: [@name]) resp = @client.enable_alarm_actions() resp.data end |
#exists?(options = {}) ⇒ Boolean
Returns ‘true` if the CompositeAlarm exists.
213 214 215 216 217 218 219 220 221 222 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 213 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.
442 443 444 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 442 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 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 188 def load resp = @client.describe_alarms(alarm_names: [@name]) @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
434 435 436 437 438 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 434 def set_state( = {}) = .merge(alarm_name: @name) resp = @client.set_alarm_state() 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
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 321 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::Waiters::Waiter.new().wait({}) end |
#wait_until_exists(options = {}, &block) ⇒ CompositeAlarm
230 231 232 233 234 235 236 237 238 239 |
# File 'lib/aws-sdk-cloudwatch/composite_alarm.rb', line 230 def wait_until_exists( = {}, &block) , params = () waiter = Waiters::CompositeAlarmExists.new() yield_waiter_and_warn(waiter, &block) if block_given? waiter.wait(params.merge(alarm_names: [@name])) CompositeAlarm.new({ name: @name, client: @client }) end |