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

Class: Aws::CloudWatch::Alarm

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

    • :client (Client)

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

  • #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 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.

#comparison_operatorString (readonly)

The arithmetic operation to use when comparing the specified statistic and threshold. The specified statistic value is used as the first operand.

Possible values:

  • GreaterThanOrEqualToThreshold
  • GreaterThanThreshold
  • LessThanThreshold
  • LessThanOrEqualToThreshold

Returns:

  • (String)

    The arithmetic operation to use when comparing the specified statistic and threshold.

#datapoints_to_alarmInteger (readonly)

The number of datapoints that must be breaching to trigger the alarm.

Returns:

  • (Integer)

    The number of datapoints that must be breaching to trigger the alarm.

#dimensionsArray<Types::Dimension> (readonly)

The dimensions for the metric associated with the alarm.

Returns:

  • (Array<Types::Dimension>)

    The dimensions for the metric associated with the alarm.

#evaluate_low_sample_count_percentileString (readonly)

Used only for alarms based on percentiles. If ignore, the alarm state does not change during periods with too few data points to be statistically significant. If evaluate or this parameter is not used, the alarm is always evaluated and possibly changes state no matter how many data points are available.

Returns:

  • (String)

    Used only for alarms based on percentiles.

#evaluation_periodsInteger (readonly)

The number of periods over which data is compared to the specified threshold.

Returns:

  • (Integer)

    The number of periods over which data is compared to the specified threshold.

#extended_statisticString (readonly)

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

Returns:

  • (String)

    The percentile statistic for the metric associated with the alarm.

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

#metric_nameString (readonly)

The name of the metric associated with the alarm.

Returns:

  • (String)

    The name of the metric associated with the alarm.

#nameString (readonly)

Returns:

  • (String)

#namespaceString (readonly)

The namespace of the metric associated with the alarm.

Returns:

  • (String)

    The namespace of the metric associated with the alarm.

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

#periodInteger (readonly)

The period, in seconds, over which the statistic is applied.

Returns:

  • (Integer)

    The period, in seconds, over which the statistic is applied.

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

#statisticString (readonly)

The statistic for the metric associated with the alarm, other than percentile. For percentile statistics, use ExtendedStatistic.

Possible values:

  • SampleCount
  • Average
  • Sum
  • Minimum
  • Maximum

Returns:

  • (String)

    The statistic for the metric associated with the alarm, other than percentile.

#thresholdFloat (readonly)

The value to compare with the specified statistic.

Returns:

  • (Float)

    The value to compare with the specified statistic.

#treat_missing_dataString (readonly)

Sets how this alarm is to handle missing data points. If this parameter is omitted, the default behavior of missing is used.

Returns:

  • (String)

    Sets how this alarm is to handle missing data points.

#unitString (readonly)

The unit of the metric associated with the alarm.

Possible values:

  • Seconds
  • Microseconds
  • Milliseconds
  • Bytes
  • Kilobytes
  • Megabytes
  • Gigabytes
  • Terabytes
  • Bits
  • Kilobits
  • Megabits
  • Gigabits
  • Terabits
  • Percent
  • Count
  • Bytes/Second
  • Kilobytes/Second
  • Megabytes/Second
  • Gigabytes/Second
  • Terabytes/Second
  • Bits/Second
  • Kilobits/Second
  • Megabits/Second
  • Gigabits/Second
  • Terabits/Second
  • Count/Second
  • None

Returns:

  • (String)

    The unit of the metric associated with the alarm.

Instance Method Details

#deleteStruct

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

Examples:

Request syntax example with placeholder values


alarm.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 all alarms are returned.

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

Examples:

Request syntax example with placeholder values


alarm.describe_history({
  history_item_type: "ConfigurationUpdate", # accepts ConfigurationUpdate, StateUpdate, Action
  start_date: Time.now,
  end_date: Time.now,
  max_records: 1,
  next_token: "NextToken",
})

Options Hash (options):

  • :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.

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


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


alarm.enable_actions()

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#exists?Boolean

Returns true if this Alarm exists. Returns false otherwise.

Returns:

  • (Boolean)

    Returns true if this Alarm exists. Returns false otherwise.

#metricMetric?

Returns:

#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. The alarm returns to its actual state (often within seconds). Because the alarm state change happens quickly, it is typically only visible in the alarm's History tab in the Amazon CloudWatch console or through DescribeAlarmHistory.

Examples:

Request syntax example with placeholder values


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

Returns:

  • (Struct)

    Returns an empty response.

See Also:

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

Waits until this Alarm is exists. This method waits by polling 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

alarm.wait_until_exists

Yield Parameters:

Returns:

  • (Alarm)

    Returns a copy of this Alarm that is not loaded.

Raises:

See Also: