O'Reilly logo

Python and AWS Cookbook by Mitch Garnaat

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Monitoring the Performance of Your Instance

Problem

Now that your instance is up and running, you want to monitor its performance and load.

Solution

Use CloudWatch to get detailed data about your instance.

Discussion

Monitoring the health and performance of your instances is an important part of operating any website or service. The CloudWatch service provides the ability to get detailed monitoring data about your EC2 instances and other AWS resources.

Example 2-13 illustrates how to enable monitoring on an EC2 instance and then retrieve various types of monitoring data for that instance.

First, we will find our existing instance and enable CloudWatch monitoring. A free tier of CloudWatch monitoring includes a limited set of metrics measured on a five-minute interval. There is an additional hourly charge for monitoring your instance if you want access to more metrics or finer-grained measurements. See http://aws.amazon.com/cloudwatch/ for details.

Example 2-13. Enable Monitoring Your Instance

>>> import boto
>>> ec2 = boto.connect_ec2()	  
>>> reservations = ec2.get_all_instances(filters={'paws' : None})
>>> instance = reservations[0].instances[0] 1
>>> instance.monitor()
1

Find the instance we want to start monitoring. This example assumes it is the instance we started in an earlier recipe and is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required