Skip to content

Instantly share code, notes, and snippets.

@mbabineau
Created January 29, 2010 04:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbabineau/289438 to your computer and use it in GitHub Desktop.
Save mbabineau/289438 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
#
# Example code for specifying multiple dimensions in a
# query of Amazon EC2 CloudWatch using the boto library.
#
# Boto may be downloaded here: http://code.google.com/p/boto
from datetime import datetime, timedelta
from boto import connect_cloudwatch
from boto.ec2.cloudwatch.metric import Metric
end = datetime.now()
start = end - timedelta(hours=24)
statistic = 'Average'
unit = 'Count'
period = 60
m = Metric()
m.connection = connect_cloudwatch()
m.name = 'HealthyHostCount'
m.namespace = "AWS/ELB"
m.dimensions = {u'LoadBalancerName': u'example-lb-name',
u'AvailabilityZone': u'us-east-1a'}
rs = m.query(start, end, statistic, unit, period)
print rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment