Object
Initialize connection to Cloudwatch
options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection
elb = CloudWatch.new( :aws_access_key_id => your_aws_access_key_id, :aws_secret_access_key => your_aws_secret_access_key )
options<~Hash> - config arguments for connection. Defaults to {}.
region<~String> - optional region to use, in [‘eu-west-1’, ‘us-east-1’, ‘us-west-1’, ‘ap-southeast-1’, ‘ap-northeast-1’]
CloudWatch object with connection to AWS.
# File lib/fog/aws/cloud_watch.rb, line 48 def initialize(options={}) @aws_access_key_id = options[:aws_access_key_id] @aws_secret_access_key = options[:aws_secret_access_key] @hmac = Fog::HMAC.new('sha256', @aws_secret_access_key) options[:region] ||= 'us-east-1' @host = options[:host] || case options[:region] when 'ap-northeast-1' 'monitoring.ap-northeast-1.amazonaws.com' when 'ap-southeast-1' 'monitoring.ap-southeast-1.amazonaws.com' when 'eu-west-1' 'monitoring.eu-west-1.amazonaws.com' when 'us-east-1' 'monitoring.us-east-1.amazonaws.com' when 'us-west-1' 'monitoring.us-west-1.amazonaws.com' else raise ArgumentError, "Unknown region: #{options[:region].inspect}" end @path = options[:path] || '/' @port = options[:port] || 443 @scheme = options[:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent]) end
Fetch datapoints for a metric. At most 1440 datapoints will be returned, the most datapoints that can be queried is 50850 StartTime is capped to 2 weeks ago
Namespace<~String>: the namespace of the metric
MetricName<~String>: the name of the metric
StartTime<~Datetime>: when to start fetching datapoints from (inclusive)
EndTime<~Datetime>: used to determine the last datapoint to fetch (exclusive)
Period<~Integer>: Granularity, in seconds of the returned datapoints. Must be a multiple of 60, and at least 60
Statistics<~Array>: An array of up to 5 strings, which name the statistics to return
Unit<~String>: The unit for the metric
Dimensions<~Array>: a list of dimensions to filter against (optional)
Name : The name of the dimension Value : The value to filter against
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html
# File lib/fog/aws/requests/cloud_watch/get_metric_statistics.rb, line 27 def get_metric_statistics(options={}) %{Statistics StartTime EndTime Period MetricName Namespace}.each do |required_parameter| raise ArgumentError, "Must prodide #{required_parameter}" unless options.has_key?(required_parameter) end statistics = options.delete 'Statistics' options.merge!(AWS.indexed_param('Statistics.member.%d', [*statistics])) if dimensions = options.delete('Dimensions') options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']})) options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']})) end request({ 'Action' => 'GetMetricStatistics', :parser => Fog::Parsers::AWS::CloudWatch::GetMetricStatistics.new }.merge(options)) end
List availabe metrics
Dimensions<~Array>: a list of dimensions to filter against,
Name : The name of the dimension Value : The value to filter against
MetricName<~String>: The name of the metric to filter against
Namespace<~String>: The namespace to filter against
NextToken<~String> The token returned by a previous call to indicate that there is more data available
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html
# File lib/fog/aws/requests/cloud_watch/list_metrics.rb, line 23 def list_metrics(options={}) if dimensions = options.delete('Dimensions') options.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']})) options.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']})) end request({ 'Action' => 'ListMetrics', :parser => Fog::Parsers::AWS::CloudWatch::ListMetrics.new }.merge(options)) end
Publishes one or more data points to CloudWatch. A new metric is created if necessary
Namespace<~String>: the namespace of the metric data
MetricData<~Array>: the datapoints to publish of the metric
* MetricName<~String>: the name of the metric
* Timestamp<~String>: the timestamp for the data point. If omitted defaults to the time at which the data is received by CloudWatch
* Unit<~String>: the unit
* Value<~Double> the value for the metric
* StatisticValues<~Hash>:
* Maximum<~Double>: the maximum value of the sample set
* Sum<~Double>: the sum of the values of the sample set
* SampleCount<~Double>: the number of samples used for the statistic set
* Minimum<~Double>: the minimum value of the sample set
* Dimensions<~Array>: the dimensions for the metric. From 0 to 10 may be included
* Name<~String>
* Value<~String>
response<~Excon::Response>:
docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_PutMetricData.html
# File lib/fog/aws/requests/cloud_watch/put_metric_data.rb, line 31 def put_metric_data(namespace, metric_data) options = {'Namespace' => namespace} #first index the dimensions for any of the datums that have dimensions metric_data.collect! do |metric_datum| if dimensions = metric_datum.delete('Dimensions') metric_datum.merge!(AWS.indexed_param('Dimensions.member.%d.Name', dimensions.collect {|dimension| dimension['Name']})) metric_datum.merge!(AWS.indexed_param('Dimensions.member.%d.Value', dimensions.collect {|dimension| dimension['Value']})) end metric_datum end #then flatten out an hashes in the metric_data array metric_data.collect! { |metric_datum| flatten_hash(metric_datum) } #then index the metric_data array options.merge!(AWS.indexed_param('MetricData.member.%d', [*metric_data])) #then finally flatten out an hashes in the overall options array options = flatten_hash(options) request({ 'Action' => 'PutMetricData', :parser => Fog::Parsers::AWS::CloudWatch::PutMetricData.new }.merge(options)) end
Generated with the Darkfish Rdoc Generator 2.