You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::CloudWatch::CompositeAlarm

Inherits:
Resources::Resource show all
Defined in:
(unknown)

Instance Attribute Summary collapse

Attributes inherited from Resources::Resource

#client, #identifiers

Instance Method Summary collapse

Methods inherited from Resources::Resource

add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #load, #wait_until

Methods included from Resources::OperationMethods

#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations

Constructor Details

#initialize(name, options = {}) ⇒ Object #initialize(options = {}) ⇒ Object

Overloads:

  • #initialize(name, options = {}) ⇒ Object

    Parameters:

    • name (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ Object

    Options Hash (options):

    • :name (required, String)
    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Aws::CloudWatch::Client object.

Instance Attribute Details

#actions_enabledBoolean (readonly)

Indicates whether actions should be executed during any changes to the alarm state.

Returns:

  • (Boolean)

    Indicates whether actions should be executed during any changes to the alarm state.

#alarm_actionsArray<String> (readonly)

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).

Returns:

  • (Array<String>)

    The actions to execute when this alarm transitions to the ALARM state from any other state.

#alarm_arnString (readonly)

The Amazon Resource Name (ARN) of the alarm.

Returns:

  • (String)

    The Amazon Resource Name (ARN) of the alarm.

#alarm_configuration_updated_timestampTime (readonly)

The time stamp of the last update to the alarm configuration.

Returns:

  • (Time)

    The time stamp of the last update to the alarm configuration.

#alarm_descriptionString (readonly)

The description of the alarm.

Returns:

  • (String)

    The description of the alarm.

#alarm_nameString (readonly)

The name of the alarm.

Returns:

  • (String)

    The name of the alarm.

#alarm_ruleString (readonly)

The rule that this alarm uses to evaluate its alarm state.

Returns:

  • (String)

    The rule that this alarm uses to evaluate its alarm state.

#insufficient_data_actionsArray<String> (readonly)

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).

Returns:

  • (Array<String>)

    The actions to execute when this alarm transitions to the INSUFFICIENT_DATA state from any other state.

#nameString (readonly)

Returns:

  • (String)

#ok_actionsArray<String> (readonly)

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).

Returns:

  • (Array<String>)

    The actions to execute when this alarm transitions to the OK state from any other state.

#state_reasonString (readonly)

An explanation for the alarm state, in text format.

Returns:

  • (String)

    An explanation for the alarm state, in text format.

#state_reason_dataString (readonly)

An explanation for the alarm state, in JSON format.

Returns:

  • (String)

    An explanation for the alarm state, in JSON format.

#state_updated_timestampTime (readonly)

The time stamp of the last update to the alarm state.

Returns:

  • (Time)

    The time stamp of the last update to the alarm state.

#state_valueString (readonly)

The state value for the alarm.

Possible values:

  • OK
  • ALARM
  • INSUFFICIENT_DATA

Returns:

  • (String)

    The state value for the alarm.

Instance Method Details

#deleteStruct

Deletes the specified alarms. You can delete up to 100 alarms in one operation. However, this total can include no more than one composite alarm. For example, you could delete 99 metric alarms and one composite alarms with one operation, but you can't delete two composite alarms with one operation.

In the event of an error, no alarms are deleted.

It is possible to create a loop or cycle of composite alarms, where composite alarm A depends on composite alarm B, and composite alarm B also depends on composite alarm A. In this scenario, you can't delete any composite alarm that is part of the cycle because there is always still a composite alarm that depends on that alarm that you want to delete.

To get out of such a situation, you must break the cycle by changing the rule of one of the composite alarms in the cycle to remove a dependency that creates the cycle. The simplest change to make to break a cycle is to change the AlarmRule of one of the alarms to False.

Additionally, the evaluation of composite alarms stops if CloudWatch detects a cycle in the evaluation path.

Examples:

Request syntax example with placeholder values


compositealarm.delete()

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#describe_history(options = {}) ⇒ Types::DescribeAlarmHistoryOutput

Retrieves the history for the specified alarm. You can filter the results by date range or item type. If an alarm name is not specified, the histories for either all metric alarms or all composite alarms are returned.

CloudWatch retains the history of an alarm even if you delete the alarm.

Examples:

Request syntax example with placeholder values


compositealarm.describe_history({
  alarm_types: ["CompositeAlarm"], # accepts CompositeAlarm, MetricAlarm
  history_item_type: "ConfigurationUpdate", # accepts ConfigurationUpdate, StateUpdate, Action
  start_date: Time.now,
  end_date: Time.now,
  max_records: 1,
  next_token: "NextToken",
  scan_by: "TimestampDescending", # accepts TimestampDescending, TimestampAscending
})

Options Hash (options):

  • :alarm_types (Array<String>)

    Use this parameter to specify whether you want the operation to return metric alarms or composite alarms. If you omit this parameter, only metric alarms are returned.

  • :history_item_type (String)

    The type of alarm histories to retrieve.

  • :start_date (Time)

    The starting date to retrieve alarm history.

  • :end_date (Time)

    The ending date to retrieve alarm history.

  • :max_records (Integer)

    The maximum number of alarm history records to retrieve.

  • :next_token (String)

    The token returned by a previous call to indicate that there is more data available.

  • :scan_by (String)

    Specified whether to return the newest or oldest alarm history first. Specify TimestampDescending to have the newest event history returned first, and specify TimestampAscending to have the oldest history returned first.

Returns:

See Also:

#disable_actionsStruct

Disables the actions for the specified alarms. When an alarm's actions are disabled, the alarm actions do not execute when the alarm state changes.

Examples:

Request syntax example with placeholder values


compositealarm.disable_actions()

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#enable_actionsStruct

Enables the actions for the specified alarms.

Examples:

Request syntax example with placeholder values


compositealarm.enable_actions()

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#exists?Boolean

Returns true if this CompositeAlarm exists. Returns false otherwise.

Returns:

  • (Boolean)

    Returns true if this CompositeAlarm exists. Returns false otherwise.

#set_state(options = {}) ⇒ Struct

Temporarily sets the state of an alarm for testing purposes. When the updated state differs from the previous value, the action configured for the appropriate state is invoked. For example, if your alarm is configured to send an Amazon SNS message when an alarm is triggered, temporarily changing the alarm state to ALARM sends an SNS message.

Metric alarms returns to their actual state quickly, often within seconds. Because the metric alarm state change happens quickly, it is typically only visible in the alarm's History tab in the Amazon CloudWatch console or through DescribeAlarmHistory.

If you use SetAlarmState on a composite alarm, the composite alarm is not guaranteed to return to its actual state. It returns to its actual state only once any of its children alarms change state. It is also reevaluated if you update its configuration.

If an alarm triggers EC2 Auto Scaling policies or application Auto Scaling policies, you must include information in the StateReasonData parameter to enable the policy to take the correct action.

Examples:

Request syntax example with placeholder values


compositealarm.set_state({
  state_value: "OK", # required, accepts OK, ALARM, INSUFFICIENT_DATA
  state_reason: "StateReason", # required
  state_reason_data: "StateReasonData",
})

Options Hash (options):

  • :state_value (required, String)

    The value of the state.

  • :state_reason (required, String)

    The reason that this alarm is set to this specific state, in text format.

  • :state_reason_data (String)

    The reason that this alarm is set to this specific state, in JSON format.

    For SNS or EC2 alarm actions, this is just informational. But for EC2 Auto Scaling or application Auto Scaling alarm actions, the Auto Scaling policy uses the information in this field to take the correct action.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#wait_until_exists {|waiter| ... } ⇒ CompositeAlarm

Waits until this CompositeAlarm is exists. This method waits by polling Aws::CloudWatch::Client#describe_alarms until successful. An error is raised after a configurable number of failed checks.

This waiter uses the following defaults:

Configuration Default
#delay 5
#max_attempts 40

You can modify defaults and register callbacks by passing a block argument.

Examples:

Basic usage

compositealarm.wait_until_exists

Yield Parameters:

Returns:

  • (CompositeAlarm)

    Returns a copy of this CompositeAlarm that is not loaded.

Raises:

See Also: