Secondly, your timestamps should be UTC. So, instead of doing this:
On Tue, Oct 23, 2012 at 1:35 AM, samuelololol <samuel.c
...@gmail.com> wrote:
> I have the same question,
> I have instance in region: 'ap-northeast-1'
> and it goes with the detailed monitering enabled.
> But I got nothing return
> here is my ez-testing code
> <code>
> import boto.ec2.cloudwatch
> import datetime
> cw = boto.ec2.cloudwatch.connect_to_region('ap-northeast-1')
> metrics = cw.list_metrics(metric_name = 'CPUUtilization')
> x = 0
> z = int()
> for i in metrics:
> for j in i.__dict__['dimensions'].values():
> if j[0] == <instance name>:
> z = x
> x = x + 1
> end = datetime.datetime.now()
> start = end - datetime.timedelta(minutes=30)
> my = ['Average', 'Sum', 'Maximum', 'Minimum']
> data = metrics[z].query(start_time=start, end_time=end,
> statistics=my, unit='Percent',
> period=60)
> print len(data)
> </code>
> my output
> <output>
> 0
> </output>
> On Saturday, September 29, 2012 7:36:04 AM UTC+8, Belred wrote:
>> I have some instances, auto scaling groups, elastic load balances, SQS,
>> DynamoDB, S3, etc. In the AWS Console, I can view many metrics. such as
>> CPUUtilization, etc. According to the boto documentation, list_metrics()
>> will only return a metric for which there is data. I then printed each
>> metric (which there was at least 100), and then queried for each metric
>> statistics. In every case, the data result that came back was emply. I
>> also tried calling get_metric_statistics() and got the same empty data
>> results. Am I missing a step?
>> import boto.ec2.cloudwatch as cw
>> cw_conn = cw.connect_to_region(AWS_**REGION, aws_access_key_id=**
>> AWSAccessKeyId,
>> aws_secret_access_key=**AWSSecretKey)
>> metrics = cw_conn.list_metrics()
>> end = datetime.datetime.now()
>> start = end - datetime.timedelta(days=1)
>> for m in metrics:
>> data = m.query(start, end, m.Statistics)
>> print m.name, m.dimensions, m.namespace
>> print data
>> print '---------'
>> --
> You received this message because you are subscribed to the Google Groups
> "boto-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/boto-users/-/ijwjhTJZJVoJ.
> To post to this group, send email to boto-users@googlegroups.com.
> To unsubscribe from this group, send email to
> boto-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/boto-users?hl=en.