If you're storing the configuration file locally, then you need to replace ssm with file in the command and specify the file path, e.g., file:'C:\Program Files\Amazon\AmazonCloudWatchAgent\config.json' Windows: & 'C:\\Program Files\\Amazon\\AmazonCloudWatchAgent\\amazon-cloudwatch-agent-ctl.ps1' -a fetch-config -m ec2 -s -c ssm: Linux: sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c ssm: To run it locally, use the following commands: You can do so by either running this command on the instance or using the Run Command feature of AWS Systems Manager. Once the agent is created, you can use it to configure the CloudWatch agent.
If you're storing the configuration file locally, the configuration file config.json is stored in /opt/aws/amazon-cloudwatch-agent/bin/ on Linux servers and in C:\Program Files\Amazon\AmazonCloudWatchAgent on Windows Servers.
If you use the wizard to write the configuration file to the SSM parameter store, ensure that the IAM role attached to the EC2 instance includes CloudWatchAgentAdminPolicy instead of CloudWatchAgentServerPolicy. Specify a Name for the parameter, copy the content of the configuration file, paste in a Value, and you can keep the rest of the options as defaults.On the Parameter Store console, click Create Parameter.Under the Application Management section, choose Parameter Store.If you're creating the configuration file manually, you can store it as a parameter in SSM by following these steps: However, if you're creating it manually, you can just store it right away as a parameter in the Systems Manager Parameter Store. Just ensure you answer Yes when prompted whether to store the file in Systems Manager Parameter Store. If you're following the wizard to generate the configuration file, you have the option to store it on SSM. It's recommended to store the configuration file as an SSM parameter store in AWS Systems Manager because it provides version control for your stored parameter therefore, if you modified the value of the parameter, it would create a new version of the parameter while retaining a history of the previous versions. Otherwise, you can create the configuration file manually by following this guide:
Windows: cd "C:\\Program Files\\Amazon\\AmazonCloudWatchAgent" amazon-cloudwatch-agent-config-wizard.exeĪll you need to do is answer the wizard questions to generate a customized configuration file for the server you would like to monitor. Linux sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard You can create it by running the CloudWatch Agent Configuration Wizard, which you can start by entering the following command: To configure the CloudWatch agent, you need to create a configuration file. Once the agent is installed, the next step is to configure it to push the logs and metrics to CloudWatch. So you don't have to worry about segregating the different platforms while provisioning the agent.
The command document we used to install the CloudWatch agent is suitable for Linux, Windows, and MacOS. Using this method for installing the CloudWatch agent is highly recommended for instances on scale, where you can install the agent on all the instances at once.