def _get_metric(self, metric, tablename, index_name=None):
end = time.time()<EOL>begin = end - <NUM_LIT:3> * <NUM_LIT>  <EOL>dimensions = [{"<STR_LIT:Name>": "<STR_LIT>", "<STR_LIT>": tablename}]<EOL>if index_name is not None:<EOL><INDENT>dimensions.append({"<STR_LIT:Name>": "<STR_LIT>", "<STR_LIT>": index_name})<EOL><DEDENT>period = <NUM_LIT><EOL>data = self.cloudwatch_connection.get_metric_statistics(<EOL>Period=period,<EOL>StartTime=begin,<EOL>EndTime=end,<EOL>MetricName=metric,<EOL>Namespace="<STR_LIT>",<EOL>Statistics=["<STR_LIT>"],<EOL>Dimensions=dimensions,<EOL>)<EOL>points = data["<STR_LIT>"]<EOL>if not points:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>points.sort(key=lambda r: r["<STR_LIT>"])<EOL>return float(points[-<NUM_LIT:1>]["<STR_LIT>"]) / period<EOL><DEDENT>
Fetch a read/write capacity metric