Class AWS::Cloudwatch::Base
In: lib/AWS/Cloudwatch.rb
lib/AWS/Cloudwatch/monitoring.rb
Parent: AWS::Base
Error InvalidClientTokenId InsufficientAddressCapacity InternalError InvalidVolumeIDDuplicate InvalidReservedInstancesOfferingId InvalidReservationIDNotFound InvalidParameterValue InvalidInstanceIDMalformed InvalidInstance SnapshotLimitExceeded InvalidReservationIDMalformed InvalidInstanceIDNotFound InvalidAttachmentNotFound ArgumentError SignatureDoesNotMatch InvalidPermissionMalformed InvalidGroupNotFound IncorrectState TooManyLoadBalancers LoadBalancerNotFound ReservedInstancesLimitExceeded InsufficientReservedInstancesCapacity InvalidAMIIDMalformed AuthFailure AttachmentLimitExceeded AddressLimitExceeded InvalidConfigurationRequest Unavailable InvalidGroupReserved InvalidGroupDuplicate InstanceLimitExceeded ValidationError InsufficientReservedInstanceCapacity InvalidVolumeIDMalformed InvalidVolumeIDNotFound InvalidPermissionDuplicate InvalidAMIIDNotFound PendingSnapshotLimitExceeded NonEBSInstance InvalidVolumeIDZoneMismatch InvalidReservedInstancesId InvalidManifest InvalidGroupInUse InvalidKeyPairNotFound InvalidAMIIDUnavailable DuplicateLoadBalancerName InsufficientInstanceCapacity VolumeLimitExceeded UnknownParameter InvalidZoneNotFound InvalidSnapshotIDNotFound InvalidSnapshotIDMalformed InvalidParameterCombination InvalidKeyPairDuplicate InvalidUserIDMalformed InvalidDeviceInUse InvalidAMIAttributeItemValue RuntimeError Base Base\n[lib/AWS/RDS.rb\nlib/AWS/RDS/rds.rb] Base\n[lib/AWS/Cloudwatch.rb\nlib/AWS/Cloudwatch/monitoring.rb] Base\n[lib/AWS/ELB.rb\nlib/AWS/ELB/load_balancers.rb] Base\n[lib/AWS/Autoscaling.rb\nlib/AWS/Autoscaling/autoscaling.rb] Base\n[lib/AWS/EC2.rb\nlib/AWS/EC2/availability_zones.rb\nlib/AWS/EC2/console.rb\nlib/AWS/EC2/devpay.rb\nlib/AWS/EC2/elastic_ips.rb\nlib/AWS/EC2/image_attributes.rb\nlib/AWS/EC2/images.rb\nlib/AWS/EC2/instances.rb\nlib/AWS/EC2/keypairs.rb\nlib/AWS/EC2/products.rb\nlib/AWS/EC2/security_groups.rb\nlib/AWS/EC2/snapshots.rb\nlib/AWS/EC2/spot_instance_requests.rb\nlib/AWS/EC2/spot_prices.rb\nlib/AWS/EC2/subnets.rb\nlib/AWS/EC2/volumes.rb] Response lib/AWS.rb lib/AWS/responses.rb lib/AWS/exceptions.rb lib/AWS/RDS/rds.rb RDS lib/AWS/Cloudwatch/monitoring.rb Cloudwatch lib/AWS/ELB/load_balancers.rb ELB lib/AWS/Autoscaling/autoscaling.rb Autoscaling lib/AWS/EC2/volumes.rb Instance EC2 AWS dot/m_26_0.png

Methods

Public Instance methods

[Source]

    # File lib/AWS/Cloudwatch.rb, line 22
22:       def api_version
23:         API_VERSION
24:       end

[Source]

    # File lib/AWS/Cloudwatch.rb, line 26
26:       def default_host
27:         DEFAULT_HOST
28:       end

get_metric_statistics pulls a hashed array from Cloudwatch with the stats of your requested metric. Once you get the data out, if you assign the results into an object like: res = @mon.get_metric_statistics(:measure_name => ‘RequestCount’, # :statistics => ‘Average’, :namespace => ‘AWS/ELB’)

This call gets the average request count against your ELB at each sampling period for the last 24 hours. You can then attach a block to the following iterator to do whatever you need to: res[‘GetMetricStatisticsResult’][‘Datapoints’][‘member’].each

@option options [String] :custom_unit (nil) not currently available, placeholder @option options [String] :dimensions (nil) Option to filter your data on. Check the developer guide @option options [Time] :end_time (Time.now()) Outer bound of the date range you want to view @option options [String] :measure_name (nil) The measure you want to check. Must correspond to

> provided options

@option options [String] :namespace (‘AWS/EC2’) The namespace of your measure_name. Currently, ‘AWS/EC2’ and ‘AWS/ELB’ are available @option options [Integer] :period (60) Granularity in seconds of the returned datapoints. Multiples of 60 only @option options [String] :statistics (nil) The statistics to be returned for your metric. See the developer guide for valid options. Required. @option options [Time] :start_time (Time.now() - 86400) Inner bound of the date range you want to view. Defaults to 24 hours ago @option options [String] :unit (nil) Standard unit for a given Measure. See the developer guide for valid options.

[Source]

    # File lib/AWS/Cloudwatch/monitoring.rb, line 39
39:       def get_metric_statistics ( options ={} )
40:         options = { :custom_unit => nil,
41:                     :dimensions => nil,
42:                     :end_time => Time.now(),      #req
43:                     :measure_name => "",          #req
44:                     :namespace => "AWS/EC2",
45:                     :period => 60,
46:                     :statistics => "",            # req
47:                     :start_time => (Time.now() - 86400), # Default to yesterday
48:                     :unit => "" }.merge(options)
49: 
50:         raise ArgumentError, ":end_time must be provided" if options[:end_time].nil?
51:         raise ArgumentError, ":end_time must be a Time object" if options[:end_time].class != Time
52:         raise ArgumentError, ":start_time must be provided" if options[:start_time].nil?
53:         raise ArgumentError, ":start_time must be a Time object" if options[:start_time].class != Time
54:         raise ArgumentError, "Server must be monitoring.amazonaws.com" if server != 'monitoring.amazonaws.com'
55:         raise ArgumentError, ":start_time must be before :end_time" if options[:start_time] > options[:end_time]
56:         raise ArgumentError, ":measure_name must be provided" if options[:measure_name].nil? || options[:measure_name].empty?
57:         raise ArgumentError, ":statistics must be provided" if options[:statistics].nil? || options[:statistics].empty?
58: 
59:         params = {
60:                     "CustomUnit" => options[:custom_unit],
61:                     "Dimensions" => options[:dimensions],
62:                     "EndTime" => options[:end_time].iso8601,
63:                     "MeasureName" => options[:measure_name],
64:                     "Namespace" => options[:namespace],
65:                     "Period" => options[:period].to_s,
66:                     "Statistics.member.1" => options[:statistics],
67:                     "StartTime" => options[:start_time].iso8601,
68:                     "Unit" => options[:unit]
69:         }
70: 
71:         return response_generator(:action => 'GetMetricStatistics', :params => params)
72: 
73:       end

This method call lists available Cloudwatch metrics attached to your EC2 account. To get further information from the metrics, you‘ll then need to call get_metric_statistics.

there are no options available to this method.

[Source]

    # File lib/AWS/Cloudwatch/monitoring.rb, line 11
11:       def list_metrics
12:         raise ArgumentError, "Server must be monitoring.amazonaws.com" if server != 'monitoring.amazonaws.com'
13:         return response_generator(:action => 'ListMetrics', :params => {})
14:       end

[Validate]