Muhammed Suhail · Follow
9 min read · Jul 3
The Amazon CloudWatch Agent is a lightweight monitoring agent that helps you collect system-level metrics, custom logs, and application logs from your Amazon EC2 instances and on-premises servers. It enables you to gain valuable insights into the performance and operational health of your infrastructure. This document will guide you through the process of configuring the CloudWatch Agent on a Windows EC2 instance using the powerful capabilities of AWS Systems Manager.
The purpose of this document is to provide a detailed step-by-step guide on how to configure the Amazon CloudWatch Agent on a Windows EC2 instance through Systems Manager. By following this guide, you will be able to seamlessly set up the agent and start monitoring various metrics and logs from your EC2 instances, allowing you to make data-driven decisions and effectively manage your infrastructure.
This guide will covers the configuration process specifically for Windows EC2 instances and focuses on using AWS Systems Manager to deploy and manage the CloudWatch Agent. It outlines the necessary steps to ensure a successful setup, including how to configure the CloudWatch Agent to collect and send metrics and logs to CloudWatch.
Before proceeding with the configuration of the CloudWatch Agent on a Windows EC2 instance, ensure that you have the following prerequisites in place:
- An active AWS account: To access the necessary AWS services and resources.
- Connect to your Windows EC2 instance using Remote Desktop Protocol (RDP).
2. Launch amazon-cloudwatch-agent-config-wizard.exe
by running the following code snippet. The executable program is menu-driven and will provide configurable options within command prompt.
3. Choose the options that you would like to apply to the configuration file.
C:\Program Files\Amazon\AmazonCloudWatchAgent>amazon-cloudwatch-agent-config-wizard.exe
================================================================
= Welcome to the Amazon CloudWatch Agent Configuration Manager =
= =
= CloudWatch Agent allows you to collect metrics and logs from =
= your host and send them to CloudWatch. Additional CloudWatch =
= charges may apply. =
================================================================
On which OS are you planning to use the agent?
1. linux
2. windows
3. darwin
default choice: [2]:
2Trying to fetch the default region based on ec2 metadata...
Are you using EC2 or On-Premises hosts?
1. EC2
2. On-Premises
default choice: [1]:
1
Do you want to turn on StatsD daemon?
1. yes
2. no
default choice: [1]:
2
Do you have any existing CloudWatch Log Agent configuration file to import for migration?
1. yes
2. no
default choice: [2]:
2
Do you want to monitor any host metrics? e.g. CPU, memory, etc.
1. yes
2. no
default choice: [1]:
1
Do you want to monitor cpu metrics per core?
1. yes
2. no
default choice: [1]:
1
Do you want to add ec2 dimensions (ImageId, InstanceId, InstanceType, AutoScalingGroupName) into all of your metrics if the info is available?
1. yes
2. no
default choice: [1]:
1
Do you want to aggregate ec2 dimensions (InstanceId)?
1. yes
2. no
default choice: [1]:
1
Would you like to collect your metrics at high resolution (sub-minute resolution)? This enables sub-minute resolution for all metrics, but you can customize for specific metrics in the output json file.
1. 1s
2. 10s
3. 30s
4. 60s
default choice: [4]:
4
Which default metrics config do you want?
1. Basic
2. Standard
3. Advanced
4. None
default choice: [1]:
2
Current config as follows:
{
"metrics": {
"aggregation_dimensions": [
[
"InstanceId"
]
],
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"LogicalDisk": {
"measurement": [
"% Free Space"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"Memory": {
"measurement": [
"% Committed Bytes In Use"
],
"metrics_collection_interval": 60
},
"Paging File": {
"measurement": [
"% Usage"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"PhysicalDisk": {
"measurement": [
"% Disk Time"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"Processor": {
"measurement": [
"% User Time",
"% Idle Time",
"% Interrupt Time"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
}
}
}
}
Are you satisfied with the above config? Note: it can be manually customized after the wizard completes to add additional items.
1. yes
2. no
default choice: [1]:
1
Do you want to monitor any customized log files?
1. yes
2. no
default choice: [1]:
2 # if you are selecting 'yes', you can provide log file path accordingly.
Do you want to monitor any Windows event log?
1. yes
2. no
default choice: [1]:
2 # select '1' incase of enabling System Event Log for Windows
Saved config file to config.json successfully.
Current config as follows:
{
"metrics": {
"aggregation_dimensions": [
[
"InstanceId"
]
],
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"LogicalDisk": {
"measurement": [
"% Free Space"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"Memory": {
"measurement": [
"% Committed Bytes In Use"
],
"metrics_collection_interval": 60
},
"Paging File": {
"measurement": [
"% Usage"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"PhysicalDisk": {
"measurement": [
"% Disk Time"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"Processor": {
"measurement": [
"% User Time",
"% Idle Time",
"% Interrupt Time"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
}
}
}
}
Please check the above content of the config.
The config file is also located at config.json.
Edit it manually if needed.
Do you want to store the config in the SSM parameter store?
1. yes
2. no
default choice: [1]:
1 # Storing configuration in SSM is a good practice for centralized access
What parameter store name do you want to use to store your config? (Use 'AmazonCloudWatch-' prefix if you use our managed AWS policy)
default choice: [AmazonCloudWatch-windows]
AmazonCloudWatch-windows
Trying to fetch the default region based on ec2 metadata...
Which region do you want to store the config in the parameter store?
default choice: [us-east-1]
us-east-1
Which AWS credential should be used to send json config to parameter store?
1. ASIA3W4JV3G7WI4SM3D3(From SDK)
2. Other
default choice: [1]:
ASIA3W4JV3G7WI4SM3D3
Successfully put config to parameter store AmazonCloudWatch-windows.
Please press Enter to exit...
Program exits now.
4. Verify the configurations by opening the parameter store (AmazonCloudWatch-windows) from SSM (AWS Systems Manager > Parameter Store).
- Log into the Windows Server
- Use the powershell session to execute the following commands and verify the CloudWatch Agent configuration:
To check if the CloudWatch Agent is running, execute the command:
Get-Service -Name "AmazonCloudWatchAgent"
3. Ensure the CloudWatch Agent service is in the “Running” state.
4. To verify if metrics are being collected, execute the command:
Get-WinEvent -LogName AmazonCloudWatch-*
This command lists the CloudWatch metrics collected by the agent. You should see a list of events indicating that the metrics collection is working.
5. To validate the logs collection, execute the command:
Get-Content -Path "C:\Program Files\Amazon\AmazonCloudWatchAgent\Logs\amazon-cloudwatch-agent.log"
This command displays the content of the CloudWatch Agent log file. Check for any errors or warnings related to log collection.
6. Access the Amazon CloudWatch console from the AWS Management Console.
7. Navigate to the “Metrics” and “Logs” sections to verify that the collected metrics and logs are visible.
8. Ensure that the expected metrics and log groups appear in the CloudWatch console.
By following these verification steps, you can ensure that the CloudWatch Agent is properly configured and successfully collecting metrics and logs from your Windows EC2 instance. If you encounter any issues or do not see the expected results, review the configuration steps and refer to the official AWS documentation for troubleshooting guidance.
In conclusion, this document provided a comprehensive guide on configuring the Amazon CloudWatch Agent on a Windows EC2 instance using AWS Systems Manager. By following the steps outlined in this document, you have successfully set up the CloudWatch Agent to collect system-level metrics, custom logs, and application logs from your Windows EC2 instances.
The CloudWatch Agent configuration process involved prerequisites such as an active AWS account, a running Windows EC2 instance, appropriate IAM permissions, and internet connectivity. By ensuring these prerequisites are met, you can proceed with confidence.
The document covered an introduction that highlighted the significance of the CloudWatch Agent in monitoring infrastructure, the purpose of the document in guiding you through the configuration process, the scope that focused on Windows EC2 instances and Systems Manager, and the necessary prerequisites to ensure a smooth configuration experience.
Additionally, the document provided verification steps to confirm the successful configuration of the CloudWatch Agent. These steps involved checking the status of the CloudWatch Agent service, validating metric collection, inspecting log collection, and verifying the visibility of metrics and logs in the Amazon CloudWatch console.
By leveraging the power of Amazon CloudWatch and AWS Systems Manager, you now have the ability to monitor and gain valuable insights into the performance and operational health of your Windows EC2 instances. This monitoring capability empowers you to make data-driven decisions, troubleshoot issues, and optimize your infrastructure for enhanced efficiency and reliability.
Remember to refer to the official AWS documentation for additional information, troubleshooting guidance, and advanced configurations. Stay proactive in monitoring your infrastructure with Amazon CloudWatch and ensure the ongoing success of your Windows EC2 instances.
Should you have any questions or encounter any difficulties during the configuration process, don’t hesitate to reach out to the AWS support team for further assistance.
Congratulations on successfully configuring Amazon CloudWatch Agent on your Windows EC2 instance through Systems Manager!