The article shows how to install and configure unified Cloudwatch agent on Amazon Linux
1. Create role with a policy which will allow EC2 instance to put metrics and logs to Cloudwatch and to create configuration in SSM Parameter Store (optionally if you plan to store configuration in SSM)
2. Install unified Cloudwatch agent on EC2 instance:
sudo yum install amazon-cloudwatch-agent
3. Run the configuration wizard to create configuration file. At the end it is possible to upload configuration to SSM.
4. Start agent and get configuration from SSM Parameter Store:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a start -m ec2 -c ssm:AmazonCloudWatch-linux
Unified Cloudwatch agent can be used for both EC2 and on-premises.