Python and AWS Cookbook by Mitch Garnaat

Python and AWS Cookbook by Mitch Garnaat

Author:Mitch Garnaat [Mitch Garnaat]
Language: eng
Format: epub, pdf
Tags: COMPUTERS / Programming Languages / Python
ISBN: 9781449305437
Publisher: O'Reilly Media
Published: 2011-10-23T16:00:00+00:00


This will return a list of all of the available CloudWatch metrics. Each will be represented by a Metric object. The contents of this list will vary for each user, depending on the number of instances you have running and the number of other monitorable resources (SQS queues, SNS topics, etc.) that the account has created.

This code will loop through all available metrics and create a list, called my_metrics, consisting of only the metrics that are relevant to this particular EC2 instance.

In order to query CloudWatch for data, we need to specify the timeframe that we are interested in by providing a start_time and an end_time. For this example, we are going to use the launch time of the instance as our start time and the current time as our end time. The Instance object has a launch_time attribute, but it is a string representation of the timestamp, and we need a Python datetime object. We can use the boto utility function parse_ts to convert the string to a datetime object.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.