Vali Craciun
2013-11-27 16:25:56 UTC
Hi,
Look at the entire response:
resp = cw.get_metric_statistics({
'Statistics' => statisticTypes,
'StartTime' => startTime,
'EndTime' => endTime,
'Period' => period,
'Unit' => unit,
'MetricName' => metricName,
'Namespace' => namespace,
'Dimensions' => [{
'Name' => 'InstanceId',
'Value' => instanceId
}]
})
you will have something like this:
#<Excon::Response:0x9fabfc8
@data={:body=>{"GetMetricStatisticsResult"=>{"Datapoints"=>[],
"Label"=>"CPUUtilization"},
"ResponseMetadata"=>{"RequestId"=>"2b7be628-577f-11e3-9463-63483966fa6a"}},
:headers=>{"x-amzn-RequestId"=>"2b7be628-577f-11e3-9463-63483966fa6a",
"Content-Type"=>"text/xml", "Content-Length"=>"337", "Date"=>"Wed, 27 Nov
2013 16:15:45 GMT"}, :status=>200, :remote_ip=>"176.32.101.117"}, @body="",
@headers={"x-amzn-RequestId"=>"2b7be628-577f-11e3-9463-63483966fa6a",
"Content-Type"=>"text/xml", "Content-Length"=>"337", "Date"=>"Wed, 27 Nov
2013 16:15:45 GMT"}, @status=200, @remote_ip="176.32.101.117">
from @headers you can find the correct EC2 time.
so you need to query with this values:
'StartTime' => @headers['Date']
'EndTime' => @headers['Date'] - x
Best,
Vali
Look at the entire response:
resp = cw.get_metric_statistics({
'Statistics' => statisticTypes,
'StartTime' => startTime,
'EndTime' => endTime,
'Period' => period,
'Unit' => unit,
'MetricName' => metricName,
'Namespace' => namespace,
'Dimensions' => [{
'Name' => 'InstanceId',
'Value' => instanceId
}]
})
you will have something like this:
#<Excon::Response:0x9fabfc8
@data={:body=>{"GetMetricStatisticsResult"=>{"Datapoints"=>[],
"Label"=>"CPUUtilization"},
"ResponseMetadata"=>{"RequestId"=>"2b7be628-577f-11e3-9463-63483966fa6a"}},
:headers=>{"x-amzn-RequestId"=>"2b7be628-577f-11e3-9463-63483966fa6a",
"Content-Type"=>"text/xml", "Content-Length"=>"337", "Date"=>"Wed, 27 Nov
2013 16:15:45 GMT"}, :status=>200, :remote_ip=>"176.32.101.117"}, @body="",
@headers={"x-amzn-RequestId"=>"2b7be628-577f-11e3-9463-63483966fa6a",
"Content-Type"=>"text/xml", "Content-Length"=>"337", "Date"=>"Wed, 27 Nov
2013 16:15:45 GMT"}, @status=200, @remote_ip="176.32.101.117">
from @headers you can find the correct EC2 time.
so you need to query with this values:
'StartTime' => @headers['Date']
'EndTime' => @headers['Date'] - x
Best,
Vali
Hi,
I have started using fog recently and have noticed inconsistencies in
responses to AWS Cloud Watch requests. I am trying to get the maximum CPU instance
of an Amazon instance over the last minute using get_metric_statistics and
I repeat this every 60s. The function only intermittently returns a
response.
cw = Fog::AWS::CloudWatch.new(credentials)
instanceId = server.id
metricName = 'CPUUtilization'
namespace = 'AWS/EC2'
period = 60
unit = 'Percent'
statisticTypes = 'Maximum
for index in (0..30)
startTime = (Time.now.gmtime-60).iso8601
endTime = Time.now.gmtime.iso8601
puts "Start time #{startTime}"
puts "End time #{endTime}"
resp = cw.get_metric_statistics({
'Statistics' => statisticTypes,
'StartTime' => startTime,
'EndTime' => endTime,
'Period' => period,
'Unit' => unit,
'MetricName' => metricName,
'Namespace' => namespace,
'Dimensions' => [{
'Name' => 'InstanceId',
'Value' => instanceId
}]
}).body['GetMetricStatisticsResult']['Datapoints']
puts resp
sleep(60)
end
Start time 2012-01-12T06:38:03Z
End time 2012-01-12T06:39:03Z
Start time 2012-01-12T06:39:05Z
End time 2012-01-12T06:40:05Z
Start time 2012-01-12T06:40:07Z
End time 2012-01-12T06:41:07Z
Start time 2012-01-12T06:41:09Z
End time 2012-01-12T06:42:09Z
Start time 2012-01-12T06:42:11Z
End time 2012-01-12T06:43:11Z
Start time 2012-01-12T06:43:13Z
End time 2012-01-12T06:44:13Z
Start time 2012-01-12T06:44:15Z
End time 2012-01-12T06:45:15Z
Start time 2012-01-12T06:45:18Z
End time 2012-01-12T06:46:18Z
Start time 2012-01-12T06:46:21Z
End time 2012-01-12T06:47:21Z
Start time 2012-01-12T06:47:23Z
End time 2012-01-12T06:48:23Z
Start time 2012-01-12T06:48:25Z
End time 2012-01-12T06:49:25Z
Start time 2012-01-12T06:49:27Z
End time 2012-01-12T06:50:27Z
Start time 2012-01-12T06:50:29Z
End time 2012-01-12T06:51:29Z
Start time 2012-01-12T06:51:31Z
End time 2012-01-12T06:52:31Z
Start time 2012-01-12T06:52:33Z
End time 2012-01-12T06:53:33Z
Start time 2012-01-12T06:53:35Z
End time 2012-01-12T06:54:35Z
Start time 2012-01-12T06:54:37Z
End time 2012-01-12T06:55:37Z
Start time 2012-01-12T06:55:39Z
End time 2012-01-12T06:56:39Z
Start time 2012-01-12T06:56:41Z
End time 2012-01-12T06:57:41Z
Start time 2012-01-12T06:57:43Z
End time 2012-01-12T06:58:43Z
{"Timestamp"=>2012-01-12 06:57:00 UTC, "Unit"=>"Percent", "Maximum"=>13.2}
I see a valid response after ~20mins. Occasionally I do not see this
issue. I initially suspected a UTC time synch issue... I must be doing
something wrong but just can't seem to put my finger on it. Any help in
debugging the issue will be greatly appreciated.
Regards,
Roshan
I have started using fog recently and have noticed inconsistencies in
responses to AWS Cloud Watch requests. I am trying to get the maximum CPU instance
of an Amazon instance over the last minute using get_metric_statistics and
I repeat this every 60s. The function only intermittently returns a
response.
cw = Fog::AWS::CloudWatch.new(credentials)
instanceId = server.id
metricName = 'CPUUtilization'
namespace = 'AWS/EC2'
period = 60
unit = 'Percent'
statisticTypes = 'Maximum
for index in (0..30)
startTime = (Time.now.gmtime-60).iso8601
endTime = Time.now.gmtime.iso8601
puts "Start time #{startTime}"
puts "End time #{endTime}"
resp = cw.get_metric_statistics({
'Statistics' => statisticTypes,
'StartTime' => startTime,
'EndTime' => endTime,
'Period' => period,
'Unit' => unit,
'MetricName' => metricName,
'Namespace' => namespace,
'Dimensions' => [{
'Name' => 'InstanceId',
'Value' => instanceId
}]
}).body['GetMetricStatisticsResult']['Datapoints']
puts resp
sleep(60)
end
Start time 2012-01-12T06:38:03Z
End time 2012-01-12T06:39:03Z
Start time 2012-01-12T06:39:05Z
End time 2012-01-12T06:40:05Z
Start time 2012-01-12T06:40:07Z
End time 2012-01-12T06:41:07Z
Start time 2012-01-12T06:41:09Z
End time 2012-01-12T06:42:09Z
Start time 2012-01-12T06:42:11Z
End time 2012-01-12T06:43:11Z
Start time 2012-01-12T06:43:13Z
End time 2012-01-12T06:44:13Z
Start time 2012-01-12T06:44:15Z
End time 2012-01-12T06:45:15Z
Start time 2012-01-12T06:45:18Z
End time 2012-01-12T06:46:18Z
Start time 2012-01-12T06:46:21Z
End time 2012-01-12T06:47:21Z
Start time 2012-01-12T06:47:23Z
End time 2012-01-12T06:48:23Z
Start time 2012-01-12T06:48:25Z
End time 2012-01-12T06:49:25Z
Start time 2012-01-12T06:49:27Z
End time 2012-01-12T06:50:27Z
Start time 2012-01-12T06:50:29Z
End time 2012-01-12T06:51:29Z
Start time 2012-01-12T06:51:31Z
End time 2012-01-12T06:52:31Z
Start time 2012-01-12T06:52:33Z
End time 2012-01-12T06:53:33Z
Start time 2012-01-12T06:53:35Z
End time 2012-01-12T06:54:35Z
Start time 2012-01-12T06:54:37Z
End time 2012-01-12T06:55:37Z
Start time 2012-01-12T06:55:39Z
End time 2012-01-12T06:56:39Z
Start time 2012-01-12T06:56:41Z
End time 2012-01-12T06:57:41Z
Start time 2012-01-12T06:57:43Z
End time 2012-01-12T06:58:43Z
{"Timestamp"=>2012-01-12 06:57:00 UTC, "Unit"=>"Percent", "Maximum"=>13.2}
I see a valid response after ~20mins. Occasionally I do not see this
issue. I initially suspected a UTC time synch issue... I must be doing
something wrong but just can't seem to put my finger on it. Any help in
debugging the issue will be greatly appreciated.
Regards,
Roshan
--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.