Sandip Patel

Let's move from "Have to" to "Want to"

Menu
  • Home
  • TECH CORNER
    • AWS
    • Networking
  • Videos
  • Expert Talk Delivered
  • Projects
  • Publications
  • About Me
Menu

Install Cloudwatch agent on on-premises Windows server

Posted on March 24, 2020December 3, 2020 by Sandipkumar Patel

First create an IAM user with programmatic access and attach below mentioned policy:

  1. CloudWatchAgentAdminPolicy
  2. AmazonSSMManagedInstanceCore

Now, create credentials file as per below image:


Now download and install Amazon Cloudwatch agent from the below link:

https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi

Update the common-config.toml file:

  1. File is located at C:\ProgramData\Amazon\AmazonCloudWatchAgent
  2. Open file in any editor and change the credentials file as you see below.
  3. Here I created credentials file on desktop.

Now, configure aws cli from the cmd:

  1. If you don’t have aws cli in windows then download and install from the below link:

https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html

  1. Now in cmd enter aws configure command and enter access key and secret key which you created earlier.

Now, In AWS console create IAM role:

  1. In IAM console click create role.
  2. Then click on EC2.
  1. Click on next and add permission below mentioned.
  • CloudWatchAgentServerPolicy
  • AmazonSSMManagedInstanceCore
  • AmazonSSMDirectoryServiceAccess
  1. click on next and name to the role ‘ SSMInstanceProfile ‘.
  2. create role.

Now, create EC2 instance and attach the the above mention role.

Note: Please give the name to the instance in Tag like “Name: cloud-watch”

Now create hybrid activation using following command run this command in cmd:

aws ssm create-activation –default-instance-name cloud-watch –iam-role SSMInstanceProfile –registration-limit 5 –region us-east-1

You will see below output:

Now, Install SSM Agent for a Hybrid Environment (Windows)

Open Powershell in Administrator mode and enter following command:

  1. $code = “activation-code”
  2. $id = “activation-id”
  3. $region = “region”
  4. $dir = $env:TEMP + “\ssm”
  5. New-Item -ItemType directory -Path $dir -Force
  6. cd $dir
  7. (New-Object System.Net.WebClient).DownloadFile(“https://amazon-ssm-$region.s3.amazonaws.com/latest/windows_amd64/AmazonSSMAgentSetup.exe”, $dir + “\AmazonSSMAgentSetup.exe”)
  8. Start-Process .\AmazonSSMAgentSetup.exe -ArgumentList @(“/q”, “/log”, “install.log”, “CODE=$code”, “ID=$id”, “REGION=$region”) -Wait
  9. Get-Content ($env:ProgramData + “\Amazon\SSM\InstanceData\registration”)
  10. Get-Service -Name “AmazonSSMAgent”

Now, In powershell configure the config-wizard script:

change the path to the C:\Program Files\Amazon\AmazonCloudWatchAgent> and run

.\amazon-cloudwatch-agent-config-wizard.exe

Give the input of generated questions

Starting the CloudWatch Agent

To use SSM Agent to start the CloudWatch agent on an on-premises server

  1. Open the Systems Manager console at https://console.aws.amazon.com/systems-manager/.
  2. In the navigation pane, choose Run Command.-or-If the AWS Systems Manager home page opens, scroll down and choose Explore Run Command.
  3. Choose Run command.
  4. In the Command document list, select the button next to AmazonCloudWatch-ManageAgent.
  5. In the Targets area, select the instance where you installed the agent.
  6. In the Action list, choose configure.
  7. In the Mode list, choose onPremise.
  8. In the Optional Configuration Location box, enter the name of the agent configuration file that you created with the wizard and stored in the Parameter Store. (you get this from the parameter store in aws system manager parameter store)
  9. Choose Run.

After successfully run this command you can see the metrics in Cloudwatch console.

OUTPUT:

Follow Me

              

AWS Re: invent 2021 at Las Vegas

Achievements & Events

Faculty- Ambassador
Best Paper Presentation Award
AWS Academy Success Story on AWS official Blog
AWS Expert Talk 2020
USA-Conference
Paper Presentation
Conference-Team
AWS Expert Talk by IEEE 2020

RSS Recent Announcements

  • AWS Fargate for Amazon Elastic Kubernetes Service is now available in the Amazon Web Services China Beijing and Ningxia Regions June 24, 2022
  • Amazon EC2 Auto Scaling announces increased Auto Scaling group default limit per account June 24, 2022
  • Amazon EC2 G5 instances now available in additional regions June 23, 2022
  • Amazon EC2 C7g instances powered by AWS Graviton3 processors now available in US East (Ohio) and Europe (Ireland) June 23, 2022
  • Amazon Connect Wisdom now enables you to integrate agent assistance capabilities into custom agent applications June 23, 2022

Recent Posts

  • Deployment of Website Using AWS CICD pipeline & Fargate
  • Install terraform on ubuntu and Create EC2 instance on AWS using terraform script
  • Install Cloudwatch agent on on-premises Windows server
  • Install Cloudwatch agent on on-premises Linux server
  • Deploy Flask website using AWS CLI with AWS Lambda, AWS API Gateway and Zappa
March 2020
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031  
« Feb   Mar »
web counter
©2022 Sandip Patel | WordPress Theme by SuperbThemes