If you remember getting an Erector Set as a kid, I’m sorry. In a stocking full of toy building systems, an Erector Set is the proverbial lump of coal. The instructions are complicated, and the pieces are made of metal, connected together with tiny screws. Few children have ever completed one of these sets successfully.
See, the AWS marketing team would have you believe that CloudWatch is the LEGO of monitoring and management services. Unfortunately, it’s more like that holdover from the 1950s. To that end we’ve put together a seven-part AWS CloudWatch Configuration Guide on how to take advantage of all the advanced features—without the tears of frustration.
This first section will cover how to access CloudWatch and enable detailed monitoring. (If you need to review the basics, we recommend that you check out our CloudWatch 101 post.)
CloudWatch gives you four different ways to access your metrics and logs: Amazon CloudWatch console, AWS command line interface (AWS CLI), CloudWatch API, and AWS SDK.
The Amazon CloudWatch console is a GUI that’s designed to make CloudWatch accessible for non-technical users. It’s pretty straightforward so not much to say here. You just login using your credentials, and BAM!, you're in.
AWS CLI supports Windows, Linux, macOS, and Unix. AWS recommends periodically checking the AWS CLI Github repository to upgrade to the latest version.
Start by checking to see if you already have a compatible version of Python:.
$ python -V
If you have python installed, you see a response that looks like this:
Python 3.6.0b2+
If you don’t have Python installed, you’ll see an error that will look something like this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'python' is not defined
Below are the commands to install Python for various flavors of Unix/Linux.
Python Installation for Ubuntu:
$ sudo apt-get install python3
Python Installation for Red Hat:
$< sudo yum install python
Python Installation for SUSE:
$ sudo zypper install python3
In addition to Python, you’ll need to have pip to install
$ pip --version
Once you have a supported version of Python installed, you can use pip to install AWS CLI.
Here’s how to install Python for Red Hat:
'python' is not recognized as an internal or external command, operable program or batch file.
pip install awscli --upgrade --user
Verify that the AWS CLI installed correctly.
$ aws --version
You should get a response that looks something like this:
aws-cli/1.11.84 Python/3.6.2 Linux/4.4.0-59-generic botocore/1.5.47
If you get an error, see Troubleshooting AWS CLI Errors.
To upgrade to the latest version, run the installation command again:
$ pip install awscli --upgrade --user
With a supported version of Python installed, you can download the Bundled Installer here or download it in the command line:
$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
Next, you’ll want to unzip the downloaded package.
$ unzip awscli-bundle.zip
Finally, execute the installation script with the following command to install AWS CLI on your machine.
$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
You can install AWS CLI for Windows in three easy steps. AWS CLI supports Microsoft Windows XP or later.
C:\Windows\System32> python --version
Python 3.6.2C:\Windows\System32> pip --version
pip 9.0.1 from c:\users\myname\appdata\local\programs\python\python36\lib\site-packages (python 3.6)
C:\Windows\System32> pip install awscli
C:\Windows\System32> aws --version
aws-cli/1.11.84 Python/3.6.2 Windows/7 botocore/1.5.47
You can use the command below to update your copy of AWS CLI.
C:\Windows\System32> pip install --user --upgrade awscli
Bookmark this page or save this command for future reference.
With a supported version of Python installed, you can download the AWS CLI Bundled Installer or download it in the command line:
$ curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
Extract the installation guide:
$ unzip awscli-bundle.zip
Install AWS CLI on your Mac with the following command:
$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
CloudWatch API — For more information, see the Amazon CloudWatch API Reference.
The process to setup a AWS SDK follows the same pattern regardless of the environment language: download the SDK, create and access credentials, and run the sample project.
Node.js SDK (setup)
Your credentials will be formatted like the example key pair below:
Access key ID: AKIAIOSFODNN7EXAMPLE
Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
For additional documentation, see Tools for Amazon Web Services. There’s also a number of other AWS developer tools worth investigating.
Let’s forgo a closer look at the free tier and just say that it’s not good enough for anything but personal projects. In order to take full advantage of CloudWatch—including things like monitoring memory or finer granularity on metrics—you’ll need to enable detailed monitoring.
If you are curious about pricing, you can use the pricing calculator on the AWS website.
CloudWatch gives you the flexibility to enable detailed monitoring on an instance at deployment or after the instance is already running. You can enable detailed monitoring on a stopped instance, too.
Enabling detailed monitoring for an instance at deployment is as easy as selecting the Monitoring check box on the Configure Instance Details page.
run-instances with the --monitoring flag enables detailed monitoring in the command line.
aws ec2 run-instances --image-id ami-09092360 --monitoring Enabled=true...
monitor-instances enables detailed monitoring for the specified instance(s) in the command line.
aws ec2 monitor-instances --instance-ids i-1234567890abcdef0
We didn't cover how to disable detailed monitoring, but you can read about that here.