Skip to content

Instantly share code, notes, and snippets.

@bradgignac
Created September 27, 2012 21:07
Show Gist options
  • Save bradgignac/3796480 to your computer and use it in GitHub Desktop.
Save bradgignac/3796480 to your computer and use it in GitHub Desktop.
CloudWatch
cloudwatch = Fog::AWS::CloudWatch.new(:aws_access_key_id => 'id', :aws_secret_access_key => 'key')
conditions = {
'Namespace' => "#{options[:namespace]}",
'Dimensions' => "#{options[:dimension]}",
'MetricName' => "#{options[:metric]}",
'Unit' => "#{options[:unit]}",
'Period' => "#{options[:period]}",
'Statistics' => "#{options[:stats]}",
'StartTime' => startTime,
'EndTime' => endTime
}
stats = cloudwatch.metric_statistics.all(conditions)
stats.each do |s|
s.minimum
s.maximum
s.sum
s.average
s.sample_count
s.timestamp
s.unit
s.metric_name
s.namespace
s.dimensions
s.value
end
@cjs226
Copy link

cjs226 commented Sep 28, 2012

aws = Fog::AWS::CloudWatch.new(:aws_access_key_id => 'id', :aws_secret_access_key => 'key')
response = aws.get_metric_statistics({
'Namespace' => "#{options[:namespace]}",
'Dimensions' => "#{options[:dimension]}",
'MetricName' => "#{options[:metric]}",
'Unit' => "#{options[:unit]}",
'Period' => "#{options[:period]}",
'Statistics' => "#{options[:stats]}",
'StartTime' => startTime,
'EndTime' => endTime,
}).body['GetMetricStatisticsResult']['Datapoints']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment