Articles → AWS → Install Cloudwatch Agent In The AWS Windows EC2 Instance

Install Cloudwatch Agent In The AWS Windows EC2 Instance






Steps




  1. Create a role
  2. Launch an EC2 instance
  3. Install and configure SSM agent on EC2 instance
  4. Assign role to EC2 instance
  5. Run AWS-ConfigurePackage command in system manager
  6. Execute amazon-cloudwatch-agent-config-wizard in command prompt
  7. Run AmazonCloudWatch-ManageAgent command in system manager
  8. Output



Create A Role




Picture showing the AmazonEC2Role role created in AWS console
Click to Enlarge


Launch An EC2 Instance





Install And Configure SSM Agent On EC2 Instance




https://amazon-ssm-us-east-2.s3.us-east-2.amazonaws.com/latest/windows_amd64/AmazonSSMAgentSetup.exe




$serviceKey = "HKLM:\SYSTEM\CurrentControlSet\Services\AmazonSSMAgent"$keyInfo = (Get-Item -Path $serviceKey).GetValue("Environment")$proxyVariables = @("http_proxy=<EC2 hostname>:<Port_number>", "https_proxy=<EC2 hostname>:<Port_number>", "no_proxy=169.254.169.254")if ($keyInfo -eq $null) {    New-ItemProperty -Path $serviceKey -Name Environment -Value $proxyVariables -PropertyType MultiString -Force} else {    Set-ItemProperty -Path $serviceKey -Name Environment -Value $proxyVariables}Restart-Service AmazonSSMAgent




  1. Replace EC2 hostname with the EC2 instance hostname
  2. Replace Port_number with 9999

Assign Role To EC2 Instance




Picture showing assigning the role AmazonEC2Role to the EC2 instance
Click to Enlarge


Run AWS-Configurepackage Command In System Manager




Picture showing running the AWS-ConfigurePackage command in the system manager
Click to Enlarge



Picture showing adding the Name in the Command Parameters section
Click to Enlarge



Picture showing the section to select the instance
Click to Enlarge



Picture showing the command got executed successfully
Click to Enlarge


Execute Amazon-Cloudwatch-Agent-Config-Wizard In Command Prompt




Picture showing the AmazonCloudWatchAgent folder created in the EC2 instance
Click to Enlarge



amazon-cloudwatch-agent-config-wizard.exe


Picture showing the amazon-cloudwatch-agent-config-wizard.exe executed in the command prompt
Click to Enlarge



Picture showing the list of questions when amazon-cloudwatch-agent-config-wizard.exe is executed
Click to Enlarge

Picture showing the list of questions when amazon-cloudwatch-agent-config-wizard.exe is executed
Click to Enlarge

Picture showing the list of questions when amazon-cloudwatch-agent-config-wizard.exe is executed
Click to Enlarge

Picture showing the list of questions when amazon-cloudwatch-agent-config-wizard.exe is executed
Click to Enlarge

Picture showing the list of questions when amazon-cloudwatch-agent-config-wizard.exe is executed
Click to Enlarge


Run Amazoncloudwatch-Manageagent Command In System Manager




Picture showing the execution of AmazonCloudWatch-ManageAgent command in system manager
Click to Enlarge



Picture showing the output of the AmazonCloudWatch-ManageAgent command execution
Click to Enlarge


Output




Picture showing the metrics started capturing in CloudWatch
Click to Enlarge




Posted By  -  Karan Gupta
 
Posted On  -  Monday, May 15, 2023

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250