Created
September 27, 2012 21:07
-
-
Save bradgignac/3796480 to your computer and use it in GitHub Desktop.
CloudWatch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
commented
Sep 27, 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