How to install and configure AWS CloudWatch agent on Ubuntu?
I will assume that you want to install the CloudWatch agent on an EC2
instance (as opposed to an on-premise server). I took the example of
sending Apache logs to CloudWatch Logs.
First, make sure your EC2 instance has an IAM role attached with the
SSH to your EC2 instance running Ubuntu 18.04 and running the
NB: Do not modify any installed files, especially the ones in
If you run Amazon Linux rather then Ubuntu, the download link is:
You can run the configuration wizard
or edit the configuration file manually which gives you more control.
The documentation is available
An example for me (comments added, JSON does not support comments):
To start the CloudWatch agent, run the following:
Please note this will convert the JSON config file into a TOML file
which is actually used by the CloudWatch Agent; the original JSON file
will be deleted.
The CloudWatch agent is integrated with systemd. It will start
automatically after a reboot, and you can restart it like so:
Restarting the agent using systemd will use the existing TOML file and
will ignore any new JSON file. If you create a new configuration JSON
file, you will need to use the amazon-cloudwatch-agent-ctl command.