Show RDS metrics for multiple instances

I would like to highlight RDS Cloudwatch Metrics using Boto for multiple databases at the same time.

So far, I have managed to get metrics for only one instance at a time using this approach:

botoRDS = boto.connect_cloudwatch(aws_access_key_id=Key, aws_secret_access_key=OtherKey)

instanceStats = botoRDS.get_metric_statistics(period=60, 
                start_time=self.startTime,
                end_time=self.endTime, 
                namespace="AWS/RDS", 
                metric_name='CPUUtilization', 
                statistics=["Average"],
                dimensions={'DBInstanceIdentifier':['DB1','DB2']})

This is what I get:

[
{
    u'Timestamp': datetime.datetime(2034,1,14,21,2),
    u'Average': 45.1,
    u'Unit': u'Percent'
}]

What I would like to return is the average value for both databases separately. Something like that:

[
{
    u'Timestamp': datetime.datetime(2034,1,14,21,2),
    u'DBInstanceID':'DB1',
    u'Average': 33.02,
    u'Unit': u'Percent'
},
{
   u'Timestamp': datetime.datetime(2034,1,14,21,2),
   u'DBInstanceID':'DB2',
    u'Average': 45.1,
    u'Unit': u'Percent'
}

]

Is it possible to form the size indicated to obtain such results. I would really like to not have to retrieve data for each database.

+4
source share
1 answer

, , . DBInstanceIndentifier DBInstance, DBInstanceIdentifiers , , , API. , .

+2

Source: https://habr.com/ru/post/1528869/


All Articles