How can I use the CloudWatch agent to view metrics for Performance Monitor on a Windows server?
I want to use the Amazon CloudWatch agent on a Windows server to get the metrics that are collected for Performance Monitor. How can I do this?
"I want to use the Amazon CloudWatch agent on a Windows server to get the metrics that are collected for Performance Monitor. How can I do this?Short descriptionTo use the CloudWatch agent to get metrics for Performance Monitor on a Windows server, you need:An Amazon Elastic Compute Cloud (Amazon EC2) instance on a public subnet (with access to internet). Or, an EC2 instance on a private subnet (with access to VPC endpoints).An AWS Identity and Access Management (IAM) profile and role for the instanceSSM agentThe CloudWatch agentFollow the steps in this article to install and configure the CloudWatch agent on your Windows server, and then view the metrics for Performance Monitor.ResolutionStart your instance1.    Start your EC2 Instance with Windows Server 2019.2.    After your EC2 instance has started, use a remote desktop protocol (RDP) to log in to your instance.Install the CloudWatch agentInstall the CloudWatch agent using one of these two methods:Use the SSM document AWS-ConfigureAWSPackageDownload the CloudWatch package manuallyUse the SSM document AWS-ConfigureAWSPackageTo use the AWS-ConfigureAWS package to install the agent, see Installing the CloudWatch agent on EC2 instances using your agent configuration.Download CloudWatch agent manuallyRun this command to download the installer package:Invoke-WebRequest -Uri https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi -OutFile $env:USERPROFILE\Downloads\amazon-cloudwatch-agent.msi -UseBasicParsingInvoke-Item $env:USERPROFILE\Downloads\amazon-cloudwatch-agent.msiAfter you download the .msi file, create the JSON configuration file using one of these methods:Use the agent configuration file wizardCreate the configuration file manuallyCreate the CloudWatch agent configuration file with the wizard1.    Follow the steps in Create the CloudWatch agent configuration file with the wizard. This is an example of the file that the wizard generates:{  "logs": {    "logs_collected": {      "files": {        "collect_list": [          {            "file_path": "C:\\Users\\Administrator\\Desktop\\CWMetricsLogs",            "log_group_name": "CWMetricsLogs",            "log_stream_name": "{instance_id}",            "retention_in_days": -1          }        ]      },      "windows_events": {        "collect_list": [          {            "event_format": "xml",            "event_levels": [              "VERBOSE",              "INFORMATION",              "WARNING",              "ERROR",              "CRITICAL"            ],            "event_name": "CloudWatchAgent",            "log_group_name": "CloudWatchAgent",            "log_stream_name": "{instance_id}",            "retention_in_days": -1          }        ]      }    }  },  "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": 30,        "resources": [          "*"        ]      },      "Memory": {        "measurement": [          "% Committed Bytes In Use"        ],        "metrics_collection_interval": 30      },      "Paging File": {        "measurement": [          "% Usage"        ],        "metrics_collection_interval": 30,        "resources": [          "*"        ]      },      "PhysicalDisk": {        "measurement": [          "% Disk Time",          "Disk Write Bytes/sec",          "Disk Read Bytes/sec",          "Disk Writes/sec",          "Disk Reads/sec"        ],        "metrics_collection_interval": 30,        "resources": [          "*"        ]      },      "Processor": {        "measurement": [          "% User Time",          "% Idle Time",          "% Interrupt Time"        ],        "metrics_collection_interval": 30,        "resources": [          "*"        ]      },      "TCPv4": {        "measurement": [          "Connections Established"        ],        "metrics_collection_interval": 30      },      "TCPv6": {        "measurement": [          "Connections Established"        ],        "metrics_collection_interval": 30      },      "statsd": {        "metrics_aggregation_interval": 60,        "metrics_collection_interval": 30,        "service_address": ":8125"      }    }  }}2.    You can also configure your CloudWatch agent config.json file for other Windows Performance counters. This example shows a generic syntax that you can use to add performance counters that are available in Performance Monitor. Be sure that the counters are visible in Windows Performance Monitor or the agent can't push any datapoint for that counter."PerformanceCounter-Family(processor, logical disk, memory etc.)": {  "measurement": [      "Counter-name ("%Usage, "% free space" etc.)"    ],  "metrics_collection_interval": 30,  "resources": [    "Counter Property ( "_total", "C:/" etc.)  ]},3.    After the wizard generates the file, you can find it in C:\Program Files\Amazon\AmazonCloudWatchAgent. Rename this file, and then copy it to this location: C:\ProgramData\Amazon\AmazonCloudWatchAgent\Configs.4.    Start the CloudWatch agent:Once the file has been put in the CloudWatchAgent Configs, Start the cloudWatch Agent Service with.\amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m EC2 -c file:$env:USERPROFILE\config.json -sCreate the configuration file manuallyFor more information on creating the JSON file manually, see Manually create or edit the CloudWatch agent configuration file.View the schema definition for the configuration file for Windows servers:installation-directory/amazon-cloudwatch-agent-schema.jsonAfter you create the file, copy it to the other servers where you want to install the agent in.View the Performance Counter metrics in CloudWatchAfter you configure and start the CloudWatch agent, view the Windows Performance Counters metrics in the CloudWatch console.1.    Open the CloudWatch console.2.    From the navigation pane, under Metrics, choose All Metrics.3.    From the Custom namespaces section, choose CWAgent.Sort by ImageID, InstanceID, InstanceType, instance, objectname, or by InstanceID. Your metrics are then uploaded and you can view them on the console.Related informationCollecting metrics and logs from Amazon EC2 instances and on-premises servers with the CloudWatch agentFollow"