Class | AWS::CloudWatch::MetricAlarmCollection |
In: |
lib/aws/cloud_watch/metric_alarm_collection.rb
|
Parent: | AlarmCollection |
Represents all alarms for a single metric.
## Getting an alarm by name
If you know the name of the alarm, you can get a reference using the {#[]} method.
metric.alarms['alarm-name']
## Enumerating Alarms
You can enumerate all alarms for a metric using each (or any of the methods defined in {Core::Collection}).
metric.alarms.each do |alarm| puts alarm.name end
## Filtering Alarms
Use one of the filtering methods to reduce the number of alarms returned.
metric.alarms.with_unit('Seconds').each {|alarm| ... }
metric | [R] | @return [Metric] |
Creates an alarm for this metric. @param (see AlarmCollection#create) @option (see MetricAlarm#update) @return (see AlarmCollection#create)
Returns a new collection that will filter results when enumerated.
@example Filtering by a 1 hour period
metric.alarms.filter('period', 3600)
@example Filtering by statistic
my_metric = metrics.filter('statistic', 'maximum')
@example Filtering by a unit
metrics = metrics.filter('unit', 'Megabits')
@param [String,Symbol] name @param [String,Integer] value @return [MetricAlarmCollection]
Returns a new collection that filters alarms by a period.
metric.alarms.with_period(3600).each {|alarm| ... }
@param [Integer] period @return [MetricAlarmCollection]
Returns a new collection that filters alarms by a statistic.
metric.alarms.with_statistic('Average').each {|alarm| ... }
@param [String] statistic @return [MetricAlarmCollection]
Returns a new collection that filters alarms by a unit.
metric.alarms.with_unit('Percent').each {|alarm| ... }
@param [String] unit @return [MetricAlarmCollection]