Installing CloudWatch on Lightsail instances provides access to a wide array of metrics.Once CloudWatch is configured, a dedicated namespace linked to the Lightsail instance becomes visible on the CloudWatch dashboard
Follow below steps to install a CloudWatch on a Lightsail instance.
1. Log in to the Lightsail instance using connect option
2. Download and Install the CloudWatch Agent.
|$ wget https://s3.amazonaws.com/amazoncloudwatch-agent/debian/amd64/latest/amazon-cloudwatch-agent.deb sudo dpkg -i -E ./amazon-cloudwatch-agent.deb|
$ sudo dpkg -i -E ./amazon-cloudwatch-agent.deb
3. Download and install the collected deamon.
|$ sudo apt-get update && sudo apt-get install collectd|
4. Now run the CloudWatch configuration wizard which generates a configuration file. Once the process is done, the configuration file will be available at /opt/aws/amazon-cloudwatch-agent/bin/config.json.
|$ sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard|
5. Create a new access key from IAM console. Once created, save the credentials.
6. Create an AWS Credentials file at /root/.aws/credentials and populate it with your Access ID and Secret Access Key.
7. Update the configuration file at the mentioned location with the path to the credentials created in the previous step.
|$ sudo vi /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml|
shared_credential_file = “/home/bitnami/.aws/credentials”
8. Start the CloudWatchAgent.
|$ sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s|
9. Check if the agent is running.
|$ sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status|
10. If the process is a success, you should see something like below.
11. Now head to the CloudWatch and click on All Metrics under Metrics.
You should now be able to see the newly created metric for the Lightsail instance.