EC2 instance setup
Using ECS ContainerInsights?
This section may not be required for your setup. For instance, if you plan to monitor ECS containers that report the metrics with ECS ContainerInsights.
In order to use the tool a CloudWatchAgent
process must be running on the EC2 instance to be monitored.
Please refer to this page to learn how to install and start the CloudWatchAgent
on an EC2 instance.
Configuration
CloudWatchAgent
is a powerful tool and can be configured to report variety of metrics.
Here is an example of the configuration file:
cloudwatch_agent_cfg.json | |
---|---|
The above configuration file is used to colect 3 memory metrics every second:
mem_used
mem_cached
mem_total
EC2 userdata
The tool can be configured to be launched automatically by the EC2 instance userdata. Here are the steps to configure the tool to be launched automatically:
- Download
CloudWatchAgent
appropriate for your EC2 instance type; learn more here. - Install
CloudWatchAgent
on the EC2 instance. - Create/copy a
CloudWatchAgent
configuration file. - Start the
CloudWatchAgent
service pointing to the created configuration file.
For a Debian EC2 instance, the steps can be achieved by executing the following commands: