Class: Aws::CloudWatch::Alarm

Inherits:
Object
  • Object
show all
Extended by:
Deprecations
Defined in:
sig/alarm.rbs,
lib/aws-sdk-cloudwatch/alarm.rb

Overview

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Associations collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Alarm.

Overloads:

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

    Parameters:

    • name (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ Alarm

    Options Hash (options):

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


13
14
15
# File 'sig/alarm.rbs', line 13

def initialize: (String name, Hash[Symbol, untyped] options) -> void
| (name: String, ?client: Client) -> void
| (Hash[Symbol, untyped] args) -> void

Instance Method Details

#actions_enabledBoolean

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

Returns:

  • (Boolean)


31
# File 'sig/alarm.rbs', line 31

def actions_enabled: () -> bool

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

Returns:

  • (Array<String>)


37
# File 'sig/alarm.rbs', line 37

def alarm_actions: () -> ::Array[::String]

#alarm_arnString

The Amazon Resource Name (ARN) of the alarm.

Returns:

  • (String)


22
# File 'sig/alarm.rbs', line 22

def alarm_arn: () -> ::String

#alarm_configuration_updated_timestampTime

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

Returns:

  • (Time)


28
# File 'sig/alarm.rbs', line 28

def alarm_configuration_updated_timestamp: () -> ::Time

#alarm_descriptionString

The description of the alarm.

Returns:

  • (String)


25
# File 'sig/alarm.rbs', line 25

def alarm_description: () -> ::String

#clientClient

Returns:



274
# File 'lib/aws-sdk-cloudwatch/alarm.rb', line 274

def client: () -> Client

#comparison_operatorString

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

Returns:

  • (String)


85
# File 'sig/alarm.rbs', line 85

def comparison_operator: () -> ("GreaterThanOrEqualToThreshold" | "GreaterThanThreshold" | "LessThanThreshold" | "LessThanOrEqualToThreshold" | "LessThanLowerOrGreaterThanUpperThreshold" | "LessThanLowerThreshold" | "GreaterThanUpperThreshold")

#dataTypes::MetricAlarm

Returns the data for this Aws::CloudWatch::Alarm. Calls Client#describe_alarms if #data_loaded? is false.

Returns:



118
# File 'sig/alarm.rbs', line 118

def data: () -> Types::MetricAlarm

#data_loaded?Boolean

Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



121
# File 'sig/alarm.rbs', line 121

def data_loaded?: () -> bool

#datapoints_to_alarmInteger

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

Returns:

  • (Integer)


79
# File 'sig/alarm.rbs', line 79

def datapoints_to_alarm: () -> ::Integer

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


alarm.delete()

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:

  • (EmptyStructure)


132
# File 'sig/alarm.rbs', line 132

def delete: (

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

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :alarm_contributor_id (String)

    The unique identifier of a specific alarm contributor to filter the alarm history results.

  • :alarm_types (Array<String>)

    Use this parameter to specify whether you want the operation to return metric alarms, composite alarms, or log 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, DateTime, Date, Integer, String)

    The starting date to retrieve alarm history.

  • :end_date (Time, DateTime, Date, Integer, String)

    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:



137
# File 'sig/alarm.rbs', line 137

def describe_history: (

#dimensionsArray<Types::Dimension>

The dimensions for the metric associated with the alarm.

Returns:



67
# File 'sig/alarm.rbs', line 67

def dimensions: () -> ::Array[Types::Dimension]

#disable_actions(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


alarm.disable_actions()

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:

  • (EmptyStructure)


150
# File 'sig/alarm.rbs', line 150

def disable_actions: (

#enable_actions(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


alarm.enable_actions()

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:

  • (EmptyStructure)


155
# File 'sig/alarm.rbs', line 155

def enable_actions: (

#evaluate_low_sample_count_percentileString

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)


91
# File 'sig/alarm.rbs', line 91

def evaluate_low_sample_count_percentile: () -> ::String

#evaluation_criteriaTypes::EvaluationCriteria

The evaluation criteria for the alarm.



106
# File 'sig/alarm.rbs', line 106

def evaluation_criteria: () -> Types::EvaluationCriteria

#evaluation_intervalInteger

The frequency, in seconds, at which the alarm is evaluated.

Returns:

  • (Integer)


109
# File 'sig/alarm.rbs', line 109

def evaluation_interval: () -> ::Integer

#evaluation_periodsInteger

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

Returns:

  • (Integer)


76
# File 'sig/alarm.rbs', line 76

def evaluation_periods: () -> ::Integer

#evaluation_stateString

If the value of this field is PARTIAL_DATA, it indicates that not all the available data was able to be retrieved due to quota limitations. For more information, see Create alarms on Metrics Insights queries.

If the value of this field is EVALUATION_ERROR, it indicates configuration errors in alarm setup that require review and correction. Refer to StateReason field of the alarm for more details.

If the value of this field is EVALUATION_FAILURE, it indicates temporary CloudWatch issues. We recommend manual monitoring until the issue is resolved

Returns:

  • (String)


100
# File 'sig/alarm.rbs', line 100

def evaluation_state: () -> ("PARTIAL_DATA" | "EVALUATION_FAILURE" | "EVALUATION_ERROR")

#exists?(options = {}) ⇒ Boolean

Returns true if the Alarm exists.

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:

  • (Boolean)

    Returns true if the Alarm exists.



124
125
# File 'sig/alarm.rbs', line 124

def exists?: (?max_attempts: Integer, ?delay: Numeric, ?before_attempt: (^(Integer attempts) -> void), ?before_wait: (^(Integer attempts, untyped response) -> void)) -> bool
| (?Hash[Symbol, untyped]) -> bool

#extended_statisticString

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

Returns:

  • (String)


64
# File 'sig/alarm.rbs', line 64

def extended_statistic: () -> ::String

#identifiersObject

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.

Deprecated.


573
574
575
# File 'lib/aws-sdk-cloudwatch/alarm.rb', line 573

def identifiers
  { name: @name }
end

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

Returns:

  • (Array<String>)


40
# File 'sig/alarm.rbs', line 40

def insufficient_data_actions: () -> ::Array[::String]

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::CloudWatch::Alarm. Returns self making it possible to chain methods.

alarm.reload.data

Returns:

  • (self)


114
# File 'sig/alarm.rbs', line 114

def load: () -> self

#metricMetric?

Returns:



168
# File 'sig/alarm.rbs', line 168

def metric: () -> Metric?

#metric_nameString

The name of the metric associated with the alarm, if this is an alarm based on a single metric.

Returns:

  • (String)


55
# File 'sig/alarm.rbs', line 55

def metric_name: () -> ::String

#metricsArray<Types::MetricDataQuery>

An array of MetricDataQuery structures, used in an alarm based on a metric math expression. Each structure either retrieves a metric or performs a math expression. One item in the Metrics array is the math expression that the alarm watches. This expression by designated by having ReturnData set to true.

Returns:



94
# File 'sig/alarm.rbs', line 94

def metrics: () -> ::Array[Types::MetricDataQuery]

#nameString Also known as: alarm_name

Returns:

  • (String)


18
# File 'sig/alarm.rbs', line 18

def name: () -> String

#namespaceString

The namespace of the metric associated with the alarm.

Returns:

  • (String)


58
# File 'sig/alarm.rbs', line 58

def namespace: () -> ::String

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

Returns:

  • (Array<String>)


34
# File 'sig/alarm.rbs', line 34

def ok_actions: () -> ::Array[::String]

#periodInteger

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

Returns:

  • (Integer)


70
# File 'sig/alarm.rbs', line 70

def period: () -> ::Integer

#set_state(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


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

Parameters:

  • options (Hash) (defaults to: {})

    ({})

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:

  • (EmptyStructure)


160
# File 'sig/alarm.rbs', line 160

def set_state: (

#state_reasonString

An explanation for the alarm state, in text format.

Returns:

  • (String)


46
# File 'sig/alarm.rbs', line 46

def state_reason: () -> ::String

#state_reason_dataString

An explanation for the alarm state, in JSON format.

Returns:

  • (String)


49
# File 'sig/alarm.rbs', line 49

def state_reason_data: () -> ::String

#state_transitioned_timestampTime

The date and time that the alarm's StateValue most recently changed.

Returns:

  • (Time)


103
# File 'sig/alarm.rbs', line 103

def state_transitioned_timestamp: () -> ::Time

#state_updated_timestampTime

The time stamp of the last update to the value of either the StateValue or EvaluationState parameters.

Returns:

  • (Time)


52
# File 'sig/alarm.rbs', line 52

def state_updated_timestamp: () -> ::Time

#state_valueString

The state value for the alarm.

Returns:

  • (String)


43
# File 'sig/alarm.rbs', line 43

def state_value: () -> ("OK" | "ALARM" | "INSUFFICIENT_DATA")

#statisticString

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

Returns:

  • (String)


61
# File 'sig/alarm.rbs', line 61

def statistic: () -> ("SampleCount" | "Average" | "Sum" | "Minimum" | "Maximum")

#thresholdFloat

The value to compare with the specified statistic.

Returns:

  • (Float)


82
# File 'sig/alarm.rbs', line 82

def threshold: () -> ::Float

#threshold_metric_idString

In an alarm based on an anomaly detection model, this is the ID of the ANOMALY_DETECTION_BAND function used as the threshold for the alarm.

Returns:

  • (String)


97
# File 'sig/alarm.rbs', line 97

def threshold_metric_id: () -> ::String

#treat_missing_dataString

Sets how this alarm is to handle missing data points. The valid values are breaching, notBreaching, ignore, and missing. For more information, see Configuring how CloudWatch alarms treat missing data.

If this parameter is omitted, the default behavior of missing is used.

This parameter is not applicable to PromQL alarms.

Returns:

  • (String)


88
# File 'sig/alarm.rbs', line 88

def treat_missing_data: () -> ::String

#unitString

The unit of the metric associated with the alarm.

Returns:

  • (String)


73
# File 'sig/alarm.rbs', line 73

def unit: () -> ("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")

#wait_until(options = {}) {|resource| ... } ⇒ Resource

Deprecated.

Use [Aws::CloudWatch::Client] #wait_until instead

Note:

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(options) {|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

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :max_attempts (Integer) — default: 10

    Maximum number of

  • :delay (Integer) — default: 10

    Delay between each

  • :before_attempt (Proc) — default: nil

    Callback

  • :before_wait (Proc) — default: nil

    Callback

Yield Parameters:

  • resource (Resource)

    to be used in the waiting condition.

Returns:

  • (Resource)

    if the waiter was successful

Raises:

  • (Aws::Waiters::Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

    yet successful.

  • (Aws::Waiters::Errors::UnexpectedError)

    Raised when an error is encountered while polling for a resource that is not expected.

  • (NotImplementedError)

    Raised when the resource does not



421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/aws-sdk-cloudwatch/alarm.rb', line 421

def wait_until(options = {}, &block)
  self_copy = self.dup
  attempts = 0
  options[:max_attempts] = 10 unless options.key?(:max_attempts)
  options[:delay] ||= 10
  options[:poller] = Proc.new do
    attempts += 1
    if block.call(self_copy)
      [:success, self_copy]
    else
      self_copy.reload unless attempts == options[:max_attempts]
      :retry
    end
  end
  Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
    Aws::Waiters::Waiter.new(options).wait({})
  end
end

#wait_until_exists(options = {}, &block) ⇒ Alarm

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Options Hash (options):

  • :max_attempts (Integer) — default: 40
  • :delay (Float) — default: 5
  • :before_attempt (Proc)
  • :before_wait (Proc)

Returns:



128
129
# File 'sig/alarm.rbs', line 128

def wait_until_exists: (?max_attempts: Integer, ?delay: Numeric, ?before_attempt: (^(Integer attempts) -> void), ?before_wait: (^(Integer attempts, untyped response) -> void)) ?{ (untyped waiter) -> void } -> Alarm
| (?Hash[Symbol, untyped]) ?{ (untyped waiter) -> void } -> Alarm