How do I get the most recent Cloudwatch metric data for an instance using Boto?

前端 未结 3 1635
野性不改
野性不改 2021-02-02 17:17

I\'m trying to get the most recent data for CPU utilization for an instance (actually, several instances, but just one to start with), however the following call doesn\'t return

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-02 18:07

    I was also seeing no data returned when setting units to "Megabytes", while setting units to "Bytes" returned data.

    Both are allowed in the API reference.

    data = conn.get_metric_statistics(period=60,start_time=start,end_time=end,metric_name="NetworkOut",namespace="AWS/EC2",statistics="Average",unit="Megabytes",dimensions={'InstanceId':'XXXXXX'})
    print "data length: %d"%len(data)
        # data length: 0
    
    
    data = conn.get_metric_statistics(period=60,start_time=start,end_time=end,metric_name="NetworkOut",namespace="AWS/EC2",statistics="Average",unit="Bytes",dimensions={'InstanceId':'XXXXXX'})
    print "data length: %d"%len(data)
        # data length: 59
    

提交回复
热议问题