01 Run describe-instances command (OSX/Linux/UNIX) using custom query filters to list the IDs of all the RDS database instances available in the selected region:
aws rds describe-db-instances
--region us-east-1
--output table
--query 'DBInstances[*].DBInstanceIdentifier'
02 The command output should return a table with the requested IDs:
-------------------------
| DescribeDBInstances |
+-----------------------+
| cc-mysql-staging-db |
| cc-mysql-webdev-db |
| cc-mysql-production |
+-----------------------+
03 Run get-metric-statistics command (OSX/Linux/UNIX) to get the statistics recorded by AWS CloudWatch for the CPUUtilization metric representing the CPU usage of the selected RDS instance. The following command example returns the average CPU utilization for an RDS database instance identified by the ID cc-mysql-staging-db, usage data captured during a 7-day time frame, using 1 hour time range as the granularity for the returned datapoints:
aws cloudwatch get-metric-statistics
--region us-east-1
--metric-name CPUUtilization
--start-time 2017-03-05T11:18:00
--end-time 2017-03-12T11:18:00
--period 3600
--namespace AWS/RDS
--statistics Average
--dimensions Name=DBInstanceIdentifier,Value=cc-mysql-staging-db
04 The command output should return the CPU usage details requested:
{
"Datapoints": [
{
"Timestamp": "2017-03-05T11:18:00Z",
"Average": 1.2085,
"Unit": "Percent"
},
{
"Timestamp": "2017-03-05T12:18:00Z",
"Average": 1.033499999999999995,
"Unit": "Percent"
},
{
"Timestamp": "2017-03-05T13:18:00Z",
"Average": 1.10425,
"Unit": "Percent"
},
...
{
"Timestamp": "2017-03-12T09:18:00Z",
"Average": 2.430999999999999993,
"Unit": "Percent"
},
{
"Timestamp": "2017-03-12T10:18:00Z",
"Average": 2.92833333333333333,
"Unit": "Percent"
},
{
"Timestamp": "2017-03-12T11:18:00Z",
"Average": 1.52783333333333333,
"Unit": "Percent"
}
],
"Label": "CPUUtilization"
}
If the average CPU usage data returned is less than 60%, the selected RDS instance qualifies as candidate for the underused database instance.
05 Run again get-metric-statistics command (OSX/Linux/UNIX) to get the statistics recorded by AWS CloudWatch for the ReadIOPS metric, representing the number of Read I/O operations per second. The following command example returns the total number of ReadIOPS used by an AWS RDS instance identified by the ID cc-mysql-staging-db, usage data captured during a 7-day time period, using a time interval of 1 hour as the granularity for the returned datapoints:
aws cloudwatch get-metric-statistics
--region us-east-1
--metric-name ReadIOPS
--start-time 2017-03-05T12:32:05
--end-time 2017-03-12T12:32:05
--period 3600
--namespace AWS/RDS
--statistics Sum
--dimensions Name=DBInstanceIdentifier,Value=cc-mysql-staging-db
06 The command output should return the ReadIOPS usage details requested:
{
"Datapoints": [
{
"Timestamp": "2017-03-05T12:32:05Z",
"Sum": 10.23400416762398904,
"Unit": "Count/Second"
},
{
"Timestamp": "2017-03-05T13:32:05Z",
"Sum": 11.4499758337361044,
"Unit": "Count/Second"
},
{
"Timestamp": "2017-03-05T14:32:05Z",
"Sum": 12.5666,
"Unit": "Count/Second"
},
...
{
"Timestamp": "2017-03-12T10:32:05Z",
"Sum": 13.0999,
"Unit": "Count/Second"
},
{
"Timestamp": "2017-03-12T11:32:055Z",
"Sum": 13.4499758337361044,
"Unit": "Count/Second"
},
{
"Timestamp": "2017-03-12T12:32:05Z",
"Sum": 12.2000366678889297,
"Unit": "Count/Second"
}
],
"Label": "ReadIOPS"
}
If the total number of ReadIOPS has been less than 100 in the last 7 days, the selected RDS database instance qualifies as candidate for the underutilized instance.
07 Run get-metric-statistics command (OSX/Linux/UNIX) to get the statistics recorded by AWS CloudWatch for the WriteIOPS metric, representing the number of Write I/O operations per second. The following command example returns the total number of WriteIOPS used by an AWS RDS instance identified by the ID cc-mysql-staging-db, IOPS usage data captured during a 7-day time frame, using 1 hour time range as the granularity for the returned datapoints:
aws cloudwatch get-metric-statistics
--region us-east-1
--metric-name WriteIOPS
--start-time 2017-03-05T14:10:56
--end-time 2017-03-12T14:10:56
--period 3600
--namespace AWS/RDS
--statistics Sum
--dimensions Name=DBInstanceIdentifier,Value=cc-mysql-staging-db
08 The command output should return the WriteIOPS usage details requested:
{
"Datapoints": [
{
"Timestamp": "2017-03-05T14:10:56Z",
"Sum": 0.8340,
"Unit": "Count/Second"
},
{
"Timestamp": "2017-03-05T15:10:56Z",
"Sum": 0.5499,
"Unit": "Count/Second"
},
{
"Timestamp": "2017-03-05T16:10:56Z",
"Sum": 0.7666,
"Unit": "Count/Second"
},
...
{
"Timestamp": "2017-03-12T12:10:56Z",
"Sum": 0.8534279999999999,
"Unit": "Count/Second"
},
{
"Timestamp": "2017-03-12T13:10:56Z",
"Sum": 0.84997,
"Unit": "Count/Second"
},
{
"Timestamp": "2017-03-12T14:10:56Z",
"Sum": 0.8499758337361044,
"Unit": "Count/Second"
}
],
"Label": "WriteIOPS"
}
If the total number of WriteIOPS has been less than 100 within the past 7 days, the selected RDS instance qualifies as candidate for the underused database instance.
If the usage data returned at steps no. 3 - 8 satisfy the conditions set by the conformity rule, the selected RDS database instance is considered "underutilized" and can be safely downsized in order to reduce the AWS RDS monthly usage costs.
09 Repeat steps no. 3 – 8 to verify the CPU, ReadIOPS and WriteIOPS metrics usage data recorded within the selected time frame for the rest of the RDS instances provisioned in the current region.
10 Change the AWS region by updating the --region command parameter value and repeat steps no. 1 - 9 to perform the entire audit process for other regions.