Reputation: 5927
Suppose I access an existing DynamoDB
import boto
conn = boto.connect_dynamodb(...)
table = conn.get_table(tableName)
or a DynamoDB2
import boto
from boto.dynamodb2.layer1 import DynamoDBConnection
from boto.dynamodb2.table import Table
conn = DynamoDBConnection(...)
table = Table(tableName, connection=conn)
table. I want to know how much data was written to it right before I accessed it. So I don't want the provisioned write throughput value but the actual throughput. How can I get this info?
Upvotes: 3
Views: 1500
Reputation: 45916
Something like this should work:
import boto.ec2.cloudwatch
import datetime
end = datetime.datetime.utcnow()
start = end - datetime.timedelta(minutes=5)
c = boto.ec2.cloudwatch.connect_to_region('us-east-1')
data = c.get_metric_statistics(period=60, start_time=start, end_time=end,
metric_name='ConsumedWriteCapacityUnits', namespace='AWS/DynamoDB',
statistics=['Sum'],dimensions={'TableName': 'mytable'})
This should a list of data points. You should average all of the sums in the list and then divide that number by 300, the period.
Upvotes: 4