def _getMetricsFromDynamodb(verbose): """Retrieve metrics from dynamodb :param bool verbose: True for verbose mode :returns: sequence of metric records as dicts """ # Connect to DynamoDB and create a proxy of the metric table metricTable = boto.dynamodb2.table.Table( table_name=MetricDynamoDBDefinition().tableName, connection=dynamodb_service.DynamoDBService.connectDynamoDB()) if verbose: g_log.info("Accessing metrics in DynamodDB from %s via %r", metricTable.table_name, metricTable.connection) resultSet = retryOnTransientDynamoDBError(g_log)(metricTable.scan)() return tuple(resultSet)
def _getMetricsFromDynamodb(verbose): """Retrieve metrics from dynamodb :param bool verbose: True for verbose mode :returns: sequence of metric records as dicts """ # Connect to DynamoDB and create a proxy of the metric table metricTable = boto.dynamodb2.table.Table( table_name=MetricDynamoDBDefinition().tableName, connection = dynamodb_service.DynamoDBService.connectDynamoDB() ) if verbose: g_log.info("Accessing metrics in DynamodDB from %s via %r", metricTable.table_name, metricTable.connection) resultSet = retryOnTransientDynamoDBError(g_log)(metricTable.scan)() return tuple(resultSet)
def getMetricData(self, metricUid): """ Retrieve and return metric data from dynamodb :param str metricUid: Metric uid :param str timestamp: Timestamp representing the lower bounds for metric data samples to retrieve :returns: DynamoDB ResultSet (see http://boto.readthedocs.org/en/latest/dynamodb2_tut.html#the-resultset) """ # Query recent DynamoDB metric data for each model now = datetime.datetime.now(_UTC_TZ) then = now - datetime.timedelta(days=self.days, microseconds=now.microsecond) conn = self._connectDynamoDB() metricDataTable = Table(self.metricDataTable, connection=conn) return retryOnTransientDynamoDBError(g_logger)(metricDataTable.query_2)( uid__eq=metricUid, timestamp__gte=then.strftime("%Y-%m-%d %H:%M:%S"))
def getMetricData(self, metricUid): """ Retrieve and return metric data from dynamodb :param str metricUid: Metric uid :param str timestamp: Timestamp representing the lower bounds for metric data samples to retrieve :returns: DynamoDB ResultSet (see http://boto.readthedocs.org/en/latest/dynamodb2_tut.html#the-resultset) """ # Query recent DynamoDB metric data for each model now = datetime.datetime.now(_UTC_TZ) then = now - datetime.timedelta(days=self.days, microseconds=now.microsecond) conn = self._connectDynamoDB() metricDataTable = Table(self.metricDataTable, connection=conn) return retryOnTransientDynamoDBError(g_logger)(metricDataTable.query_2)( uid__eq=metricUid, timestamp__gte=then.strftime("%Y-%m-%d %H:%M:%S") )