01 Run describe-clusters command (OSX/Linux/UNIX) using custom query filters to list the identifiers of all Redshift clusters currently available in the selected region:
aws redshift describe-clusters
--region us-east-1
--output table
--query 'Clusters[*].ClusterIdentifier'
02 The command output should return a table with the requested cluster names:
------------------------
| DescribeClusters |
+----------------------+
| cc-sandbox-cluster |
| cc-staging-cluster |
| cc-prod-cluster |
+----------------------+
03 Run get-metric-statistics command (OSX/Linux/UNIX) to get the statistics recorded by AWS CloudWatch for the DatabaseConnections metric, representing the number of Redshift database connections in use. Change the --start-time (start recording date) and --end-time (stop recording date) parameters value to choose your own time frame for recording the DatabaseConnections usage. Also, set the --period parameter value to define the granularity - in seconds - of the returned datapoints, based on your requirements. A period can be as short as one minute (60 seconds) or as long as one day (86400 seconds). The following command example returns the average database connections usage of an AWS Redshift cluster identified by the name cc-sandbox-cluster, usage data captured during a 7 days period (set by the --start-time and --end-time command parameters), using 1 hour period as the granularity of the returned datapoints (set by the --period parameter):
aws cloudwatch get-metric-statistics
--region us-east-1
--metric-name DatabaseConnections
--start-time 2016-10-04T18:22:45
--end-time 2016-10-11T18:22:45
--period 3600
--namespace AWS/Redshift
--statistics Average
--dimensions Name=ClusterIdentifier,Value=cc-sandbox-cluster
04 The command output should return the DatabaseConnections usage details requested:
{
"Datapoints": [
{
"Timestamp": "2016-10-04T18:22:45Z",
"Average": 0.0,
"Unit": "Count"
},
{
"Timestamp": "2016-10-04T18:22:45Z",
"Average": 0.0,
"Unit": "Count"
},
{
"Timestamp": "2016-10-04T18:22:45Z",
"Average": 0.0,
"Unit": "Count"
},
...
{
"Timestamp": "2016-10-11T18:22:45Z",
"Average": 0.0,
"Unit": "Count"
},
{
"Timestamp": "2016-10-11T18:22:45Z",
"Average": 0.0,
"Unit": "Count"
},
{
"Timestamp": "2016-10-11T18:22:45Z",
"Average": 0.0,
"Unit": "Count"
}
],
"Label": "DatabaseConnections"
}
If the average number of database connections has been less than 1 for the last 7 days, the selected Redshift cluster qualifies as candidate for the idle cluster.
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 Redshift cluster identified by the name cc-sandbox-cluster, IOPS usage data captured during a 7 days period (set by the --start-time and --end-time command parameters), using 1 hour period as the granularity of the returned datapoints (set by the --period parameter):
aws cloudwatch get-metric-statistics
--region us-east-1
--metric-name ReadIOPS
--start-time 2016-10-04T18:22:57
--end-time 2016-10-11T18:22:57
--period 3600
--namespace AWS/Redshift
--statistics Sum
--dimensions Name=ClusterIdentifier,Value=cc-sandbox-cluster
06 The command output should return the ReadIOPS usage details requested:
{
"Datapoints": [
{
"Timestamp": "2016-10-04T18:22:57Z",
"Sum": 3.0000539505765276,
"Unit": "Count/Second"
},
{
"Timestamp": "2016-10-04T18:22:57Z",
"Sum": 1.2000329652228976,
"Unit": "Count/Second"
},
{
"Timestamp": "2016-10-04T18:22:57Z",
"Sum": 1.9001483344299335,
"Unit": "Count/Second"
},
...
{
"Timestamp": "2016-10-11T18:22:57Z",
"Sum": 3.0000557761644715,
"Unit": "Count/Second"
},
{
"Timestamp": "2016-10-11T18:22:57Z",
"Sum": 3.133804686450845,
"Unit": "Count/Second"
},
{
"Timestamp": "2016-10-11T18:22:57Z",
"Sum": 4.087927411198773,
"Unit": "Count/Second"
}
],
"Label": "ReadIOPS"
}
If the total number of ReadIOPS has been less than 20 for the last 7 days, the selected Redshift cluster qualifies as candidate for the idle cluster.
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 Redshift cluster identified by the name cc-sandbox-cluster, IOPS usage data captured during a 7 days period (set by the --start-time and --end-time command parameters), using 1 hour period as the granularity of the returned datapoints (set by the --period parameter):
aws cloudwatch get-metric-statistics
--region us-east-1
--metric-name WriteIOPS
--start-time 2016-10-04T18:23:10
--end-time 2016-10-11T18:23:10
--period 3600
--namespace AWS/Redshift
--statistics Sum
--dimensions Name=ClusterIdentifier,Value=cc-sandbox-cluster
08 The command output should return the WriteIOPS usage details requested:
{
"Datapoints": [
{
"Timestamp": "2016-10-04T18:23:10Z",
"Sum": 1.5608611980164495,
"Unit": "Count/Second"
},
{
"Timestamp": "2016-10-04T18:23:10Z",
"Sum": 0.0,
"Unit": "Count/Second"
},
{
"Timestamp": "2016-10-04T18:23:10Z",
"Sum": 0.0,
"Unit": "Count/Second"
},
...
{
"Timestamp": "2016-10-11T18:23:10Z",
"Sum": 2.595462486617107,
"Unit": "Count/Second"
},
{
"Timestamp": "2016-10-11T18:23:10Z",
"Sum": 0.0,
"Unit": "Count/Second"
},
{
"Timestamp": "2016-10-11T18:23:10Z",
"Sum": 1.566811457747086,
"Unit": "Count/Second"
}
],
"Label": "WriteIOPS"
}
If the total number of WriteIOPS has been less than 20 for the last 7 days, the selected Redshift cluster qualifies as candidate for the idle cluster.
09 Run describe-tags command (OSX/Linux/UNIX) to describe the tags for the selected cluster:
aws redshift describe-tags
--region us-east-1
--resource-name arn:aws:redshift:us-east-1:123456789012:cluster:cc-sandbox-cluster
10 The command output should return the tags (key-value pairs) applied to the cluster. The Role and Owner tags returned and their values (highlighted) can be used to determine the resource role within the environment and to contact its owner for more information in order to decide whether the Redshift cluster can be terminated or not:
{
"TaggedResources": [
{
"ResourceType": "cluster",
"ResourceName": "arn:aws:redshift:us-east-1:123456789012:
cluster:cc-sandbox-cluster",
"Tag": {
"Value": "redshift-test-cluster",
"Key": "Role"
}
},
{
"ResourceType": "cluster",
"ResourceName": "arn:aws:redshift:us-east-1:123456789012:
cluster:cc-sandbox-cluster",
"Tag": {
"Value": "db_ops@cloudconformity.com",
"Key": "Owner"
}
}
]
}
If the data returned for the steps no. 3 - 10 satisfy the conditions set by the conformity rule (cluster role, cluster owner, ReadIOPS + WriteIOPS, database connections), the selected cluster is considered "idle" and can be terminated in order to reduce AWS Redshift usage costs.
11 Repeat steps no. 3 - 10 to verify the role, owner, DatabaseConnections, ReadIOPS and WriteIOPS metrics usage within the specified time frame for the rest of the Redshift clusters created in the current region.
12 Change the AWS region by updating the --region command parameter value and repeat steps no. 1 - 11 to perform the audit process for other regions.