Getting the CloudWatch Tools
Amazon RDS makes DB Instance metrics available via the Amazon AWS CloudWatch service. You can access your metrics using the Amazon CloudWatch API Tools or via the API itself. The examples in this guide use the API Tools (the API Tools are the Command Line Interface for CloudWatch). Follow the links above to find out more about the CloudWatch service and API Tools.
Once you've downloaded and installed the API Tools, you can use the mon-get-stats command to access your Amazon RDS DB Instance metrics.
How to Retrieve Amazon RDS DB Instance Metrics from CloudWatch
In order to retrieve metrics from Cloudwatch, you need to know the namespace, measure names, and dimensions of the metrics. The namespace for Amazon RDS is "AWS/RDS". Other Amazon Web Services use different CloudWatch namespaces, so it's easy to distinguish between Amazon RDS metrics and metrics from other services. The measure names are "CPUUtilization", "DatabaseConnections", and "FreeStorageSpace", corresponding to the metrics for percent CPU utilization, number of database connections, and amount of free disk storage space respectively. This information is summarized below.
The DBInstanceId is the name you provided for the DB Instance when it was created. You can obtain a list of your DBInstanceIds with the rds-describe-db-instances command.
Note to Amazon EC2 customers: Amazon RDS provides different metrics than EC2. If you have monitored EC2 instances as well as Amazon RDS DB Instances, you'll notice that the metrics available from the EC2 service are not the same as the metrics provided by Amazon RDS. You can distinguish EC2 from Amazon RDS metrics by examining the namespace. EC2 metrics are in the namespace "AWS/EC2" whereas Amazon RDS metrics use the "AWS/RDS" namespace.
Each of the examples uses "acme" as the DBInstanceId. Substitute your DBInstanceId wherever you see "acme" before running the examples on your system.
Display average CPU utilization for the DB Instance "acme" for the past 60 minutes. Note that if you do not specify a start or end time, CloudWatch displays metrics for the last 60 minutes.
mon-get-stats CPUUtilization --dimensions="DBInstanceIdentifier=acme" \ --statistics= Average --namespace="AWS/RDS"
Display the minimum, maximum, and average number of database connections at 10 minute intervals for the past hour.
mon-get-stats DatabaseConnections --namespace=AWS/RDS \ --dimensions="DBInstanceIdentifier=acme" \ --statistics=Minimum,Maximum,Average --period=600
Free Storage Space
Display the minimum available free storage space for the past week at one hour intervals and output as CSV data suitable for loading into a spreadsheet or database.
mon-get-stats FreeStorageSpace --namespace=AWS/RDS \ --dimensions="DBInstanceIdentifier=acme" \ --statistics=Minimum --period=3600 --show-long \ --start-time=`date --date="1 week ago" +%FT%T`