I have created a user and added the following inline policy to him. It reads the below piece :
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowAccessToSSM",
"Effect": "Allow",
"Action": [
"cloudwatch:PutMetricData",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:DescribeLogGroups",
"logs:DescribeLogStreams",
"logs:PutLogEvents"
],
"Resource": [
"*"
]
}
]
}
Then, I have successfully monitored the Available Memory by making the following changes to the .json file :
...
{
"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": "CloudWatch",
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatch.CloudWatchOutputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters":{
"AccessKey": "xxxxxxxxxxxxxxxxxxx",
"SecretKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"Region": "us-east-1",
"NameSpace": "Windows/Demo"
}
}
"Flows": {
"Flows":
[
"PerformanceCounterMemory,CloudWatch"
]
}
...
After editing that file this way, I enabled CloudWatch Integration checkbox in ec2ConfigSettings.
Next, I have restarted both ec2Config and Amazon SSM Agent Services.
Successfully, I could see the Memory metric in my CloudWatch console.
Now, I thought of monitoring the available Disk Space too.
For that, I have added this part to my .json file :
{
"Id": "PerformanceCounterDisk",
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"CategoryName": "LogicalDisk",
"CounterName": "% Free Space",
"InstanceName": "C:",
"MetricName": "FreeDisk",
"Unit": "Percent",
"DimensionName": "InstanceId",
"DimensionValue": "{instance_id}"
}
},
"Flows": {
"Flows":
[
"(PerformanceCounterMemory,PerformanceCounterDisk),CloudWatch"
]
}
After doing this, I have restarted both the ec2Config and Amazon SSM Agent Services, but I can't see this metric under my namespace. Only memory is being shown and not disk space.
What mistake have I done?
See Question&Answers more detail:
os