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.)
Accessing CloudWatch
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.
Amazon CloudWatch Console
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 Command Line Interface (AWS CLI)
AWS CLI supports Windows, Linux, macOS, and Unix. AWS recommends periodically checking the AWS CLI Github repository to upgrade to the latest version.
AWS CLI Installation Requirements
- Python 3 version 3.3+: Technically, AWS CLI supports Python 2 version 2.6.5+, but the Python project has been split since 2007, and Python 2 will probably be deprecated in a year or so.
- pip (pip installs packages), package manager
Supported Operating Systems
- Windows, Linux, macOS, or Unix
AWS CLI Installation Guides
Python Installation for Linux/Unix
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
pip Installation for Linux/Unix
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.
AWS CLI Installation (w/ pip) for Linux
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
AWS CLI Bundled Installer for Linux, Unix, macOS
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
AWS CLI Standalone Installation for Windows
You can install AWS CLI for Windows in three easy steps. AWS CLI supports Microsoft Windows XP or later.
- Download the MSI installer(32-bit,64-bit). If you aren’t sure whether your version of Windows is 32-bit or 64-bit, you can download this AWS setup file and it will automatically install the right program for you.
- Run the MSI installer program.
- The program’s wizard will walk you through the installation process.
AWS CLI Installation (with Python, pip) on Windows
- Download the Python 3.6 Windows x86-64 executable installer from the downloads page.
- Run the executable installer.
- When prompted, choose Add Python 3.6 to PATH.
- Click Install Now.
- From the Windows Start menu, type “cmd” into the search field to open the Windows Command Processor. It’s a black window with a text prompt.
- Verify that you have Python and pip installed with the following commands:
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)
- Install the AWS CLI using pip:
C:\Windows\System32> pip install awscli
- Check to make sure that you installed AWS CLI properly.
C:\Windows\System32> aws --version
aws-cli/1.11.84 Python/3.6.2 Windows/7 botocore/1.5.47 - (For Troubleshooting) If the aws command doesn’t work, you’ll need to manually add it to your operating system’s PATH variable:
- From the Windows Start menu, type “environment variables” into the search field.
- Click on Edit environment variables for your account.
- Click on PATH. Then, select Edit.
- In the Variable value field, make sure the last character is a semi-colon.
- (64-bit) Add “%USERPROFILE%\AppData\Local\Programs\Python\Python36\Scripts;C:\Program Files\Amazon\AWSCLI;” to the end of the string, or
- (32-bit) Add “%USERPROFILE%\AppData\Local\Programs\Python\Python36\Scripts;C:\Program Files (x86)\Amazon\AWSCLI;”
- Click OK twice to apply the new settings.
- Close and re-open any running command prompts. The aws command should work now.
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.
AWS CLI Installation on macOS
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
CloudWatch API — For more information, see the Amazon CloudWatch API Reference.
Getting Started with AWS SDKs
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.
Project Resources
Node.js SDK (setup)
Create and Access AWS SDK Security Credentials
- Open the IAM console.
- Click Users in the navigation menu.
- Select your IAM user name. (Note: Don’t click the checkbox. That won’t work.)
- Select the Security credentials tab.
- Click on Create access key.
- Click Show to see your security credential key pair.
- Click Download .csv file to download the key pair.
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.
Enable Detailed Monitoring
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.
Concurrent Deployment in the Console
Enabling detailed monitoring for an instance at deployment is as easy as selecting the Monitoring check box on the Configure Instance Details page.
Concurrent Deployment Using AWS CLI
run-instances with the --monitoring flag enables detailed monitoring in the command line.
aws ec2 run-instances --image-id ami-09092360 --monitoring Enabled=true...
Enable Existing Instance in the Console
- Open the Amazon EC2 console.
- In the navigation pane, choose Instances.
- Select the instance, choose Actions, CloudWatch Monitoring, Enable Detailed Monitoring.
- In the Enable Detailed Monitoring dialog box, choose Yes, Enable.
- Choose Close.
Enable Existing Instance Using AWS CLI
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.