lundi 25 mai 2015

Some doubts using cloudwatch metrics for dynamodb

I created a dynamodb table.

And now Im trying to create a cloudwatch alarm to send a sns notification when tables request exceed 80% for 1 hour (as it appear when we create a dynamodb table using aws managment console).

My doubts are:

First:

I need to create two cloud watch alarms, as the code below? Or there is a way to create only 1 alarm with both metrics?

Second:

And also, for this example that Im trying to do Sum is the correct metric right?

Third:

when we create a table with aws managment console and it appears to create a cloud watch alarm when tables request exceed 80%, also appears that the sns notification will bet sent when:

Read Capacity Units consumed > 1 or Write Capacity Units consumed > 1

Im bit confused with this part, the sns notification will be send when read capacity units consumed and write capacity units consumed > 1 or when table request exceeds 80% for 1 hour? Or it is the same thing?

def createCW(topicArn, tableName):
    cloudwatch = boto.ec2.cloudwatch.connect_to_region("us-east-1")
    t = time.localtime(time.time())

    alarmName1 = "ConsumedReadCapacityUnits" 
    alarmName2 = "ConsumedWriteCapacityUnits"
    metric1 = cloudwatch.list_metrics(dimensions={'TableName':tableName},
                    metric_name="ConsumedReadCapacityUnits")[0]
    metric1.create_alarm(name=alarmName1, comparison='>=', threshold=0.8, period=60,
                    evaluation_periods=1, statistic='Sum', alarm_actions=[topicArn])    
    metric2 = cloudwatch.list_metrics(dimensions={'TableName':tableName},
                    metric_name="ConsumedReadCapacityUnits")[0]
    metric2.create_alarm(name=alarmName2, comparison='>=', threshold=0.8, period=60,
                    evaluation_periods=1, statistic='Sum', alarm_actions=[topicArn])    




Aucun commentaire:

Enregistrer un commentaire