This block of code puts the megabytes of available memory custom metrics into CloudWatch. However I am unable to get it to post the hostname with the metrics. This block is in the AWS.EC2.Windows.CloudWatch.json file within the directory:
C:\Program Files\Amazon\SSM\Plugins\awsCloudWatch\
{
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "MemoryAvailableMBytes",
"Parameters": {
"CategoryName": "Memory",
"CounterName": "Available MBytes",
"DimensionName": "InstanceID",
"DimensionValue": "{instance_id}",
"InstanceName": "",
"MetricName": "AvailableMBytes",
"Unit": "Megabytes"
}
},
I have attempted to use the following key pairs for InstanceName: "InstanceName": "{hostname}", "InstanceName": "{instance}",
I am making sure to restart the EC2Config service then the Amazon SSM Agent service after editing the AWS.EC2.Windows.CloudWatch.json file. The "InstanceName": "{hostname}", key pair had worked in an earlier version of the JSON file. When I assign the {hostname} value to InstanceName the metrics stop being written to CloudWatch.