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

Class: Aws::CloudWatch::Resource

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

Overview

This class provides a resource oriented interface for CloudWatch. To create a resource object:

resource = Aws::CloudWatch::Resource.new

You can supply a client object with custom configuration that will be used for all resource operations. If you do not pass :client, a default client will be constructed.

client = Aws::CloudWatch::Client.new(region: 'us-west-2')
resource = Aws::CloudWatch::Resource.new(client: client)

Resource Resource Classes

Aws::CloudWatch::Resource has the following resource classes:

Instance Attribute Summary

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(options = {}) ⇒ Object #initialize(options = {}) ⇒ Object

Overloads:

  • #initialize(options = {}) ⇒ Object

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

    • :client (Client)

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

Instance Method Details

#alarm(name) ⇒ Alarm

Parameters:

Returns:

See Also:

#alarms(options = {}) ⇒ Collection<Alarm>

Returns a Collection of Alarm resources. No API requests are made until you call an enumerable method on the collection. Client#describe_alarms will be called multiple times until every Alarm has been yielded.

Examples:

Request syntax example with placeholder values


cloudwatch.alarms({
  alarm_names: ["AlarmName"],
  alarm_name_prefix: "AlarmNamePrefix",
  state_value: "OK", # accepts OK, ALARM, INSUFFICIENT_DATA
  action_prefix: "ActionPrefix",
  max_records: 1,
  next_token: "NextToken",
})

Enumerating Alarm resources.

cloudwatch.alarms.each do |alarm|
  # yields each alarm
end

Enumerating Alarm resources with a limit.

cloudwatch.alarms.limit(10).each do |alarm|
  # yields at most 10 alarms
end

Batch operations callable on the returned collection


# calls Client#delete_alarms on each batch
cloudwatch.alarms.batch_delete!

# calls Client#disable_alarm_actions on each batch
cloudwatch.alarms.batch_disable_actions

# calls Client#enable_alarm_actions on each batch
cloudwatch.alarms.batch_enable_actions

Options Hash (options):

  • :alarm_names (Array<String>)

    The names of the alarms.

  • :alarm_name_prefix (String)

    The alarm name prefix. If this parameter is specified, you cannot specify AlarmNames.

  • :state_value (String)

    The state value to be used in matching alarms.

  • :action_prefix (String)

    The action name prefix.

  • :max_records (Integer)

    The maximum number of alarm descriptions to retrieve.

  • :next_token (String)

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

Returns:

See Also:

#metric(namespace, name) ⇒ Metric

Parameters:

Returns:

See Also:

#metrics(options = {}) ⇒ Collection<Metric>

Returns a Collection of Metric resources. No API requests are made until you call an enumerable method on the collection. Client#list_metrics will be called multiple times until every Metric has been yielded.

Examples:

Request syntax example with placeholder values


cloudwatch.metrics({
  namespace: "Namespace",
  metric_name: "MetricName",
  dimensions: [
    {
      name: "DimensionName", # required
      value: "DimensionValue",
    },
  ],
  next_token: "NextToken",
})

Enumerating Metric resources.

cloudwatch.metrics.each do |metric|
  # yields each metric
end

Enumerating Metric resources with a limit.

cloudwatch.metrics.limit(10).each do |metric|
  # yields at most 10 metrics
end

Options Hash (options):

  • :namespace (String)

    The namespace to filter against.

  • :metric_name (String)

    The name of the metric to filter against.

  • :dimensions (Array<Types::DimensionFilter>)

    The dimensions to filter against.

  • :next_token (String)

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

Returns:

See Also: