AWS - Setup cloudwatch custom metrics for windows
Setup cloudwatch custom metrics for windows
--send windows
performance counters to cloudwatch
To monitor memory or disk usage of an EC2 windows instance
with cloudwatch, we can setup cloudwatch custom metrics and send windows
performance counters to cloudwatch.
For Ec2Config service version prior to 4.2, we can
accomplish this with EC2Config service by enabling CloudWatch integration.
However, EC2Config
service is no longer supports enabling CloudWatch integration after version
4.2.
Now that in the EC2ConfigService Settings window, the Cloud
Watch Integration Checkbox disappears.
Even the CloudWatch Logs section is not there anymore. Searching from the internet, many would tell
you to get the latest version of EC2Config. That is because the Cloud Watch
Integration only available for EC2Config version should be 2.2.5 or later. Many
people have got problems because that their EC2Config version was earlier than
2.2.5. Before version 4.2, get the
latest version of EC2Config would work. It won’t work anymore after 4.2. Shall
we uninstall our Ec2Config service and install an earlier version? That sounds
like a choice but might not be good one. AWS moved this function out of EC2Config
service, it got be able to achieve it somewhere else.
Now SSM Agent is responsible for this function. So 1. get
latest version of SSM Agent installed in the EC2 instance. 2. Attach an IAM
role with ‘AmazonEC2RolesforSSM’ policy. Then follow the steps of in following
document:
To configure integration with
CloudWatch using Run Command
2.
In the navigation pane, choose Systems
Manager Services, Run Command.
3.
Choose Run a command.
4.
For Command document, choose AWS-ConfigureCloudWatch.
5.
For Target instances, choose the
instances to integrate with CloudWatch. If you do not see an instance in this
list, it might not be configured for Run Command. For more information, see Systems Manager Prerequisites in the Amazon EC2 Systems Manager User Guide.
6.
For Status, choose Enabled.
7.
For Properties, copy and paste your JSON
content.
8.
Complete the remaining optional fields and
choose Run.
Note:
1. In
the step 7, we can just use the json file we used for Ec2ConfigService before:
C:\Program Files\Amazon\Ec2ConfigService\Settings\AWS.EC2.Windows.CloudWatch.json
With contents such as:
{
"Id":
"PerformanceCounterMemory",
"FullName":
"AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters":
{
"CategoryName":
"Memory",
"CounterName":
"Available MBytes",
"InstanceName":
"",
"MetricName":
"Memory",
"Unit":
"Megabytes",
"DimensionName":
"InstanceId",
"DimensionValue":
"{instance_id}"
}
},
{
"Id":
"PerformanceCounterDisk",
"FullName":
"AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters":
{
"CategoryName":
"LogicalDisk",
"CounterName":
"Free Megabytes",
"InstanceName":
"C:",
"MetricName":
"CdriveFreeDisk",
"Unit":
"Megabytes",
"DimensionName":
"InstanceId",
"DimensionValue":
"{instance_id}"
}
},
2.
We can remove the content in the AccessKey and
SecretKey because we attached the IAM role which has enough privilege to the
EC2 instance:
{
"Id":
"CloudWatch",
"FullName":
"AWS.EC2.Windows.CloudWatch.CloudWatch.CloudWatchOutputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters":
{
"AccessKey":
"",
"SecretKey":
"",
"Region":
"us-east-1",
"NameSpace":
"Windows/Default"
}
}
Comments
Post a Comment