- Consulting
- Training
- Partners
- About Us
x
It’s not rare that users having requirements of sending custom metrics to CloudWatch. These metrics can be application based or server based. There are different ways we can send these metrics to CloudWatch like writing a simple PowerShell script and scheduling it in Task Scheduler to run periodically. Alternate way to accomplish this, which I personally find very easy is by making simple changes in EC2ConfigService in your windows instance.
Let’s take an example that you want to send Free disk and Memory utilization metrics to CloudWatch.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowAccessToSSM", "Effect": "Allow", "Action": [ "cloudwatch:PutMetricData", "logs:CreateLogGroup", "logs:CreateLogStream", "logs:DescribeLogGroups", "logs:DescribeLogStreams", "logs:PutLogEvents" ], "Resource": [ "*" ] } ] } |
1. RDP into your windows instance and from the Start menu, click All Programs, and then click EC2ConfigService Settings.
2. Enable CloudWatch Logs Integration and click OK.
3. Go to C:Program FilesAmazonEc2ConfigServiceSettingsAWS.EC2.Windows.CloudWatch.json and replace below code in the file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
{ "EngineConfiguration": { "PollInterval": "00:00:15", "Components": [ { "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": "FreeDisk", "Unit": "Megabytes", "DimensionName": "InstanceId", "DimensionValue": "{instance_id}" } }, { "Id": "CloudWatch", "FullName": "AWS.EC2.Windows.CloudWatch.CloudWatch.CloudWatchOutputComponent,AWS.EC2.Windows.CloudWatch", "Parameters": { "AccessKey": "xxxxxxxxxxxxxxxxxxxx", "SecretKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "Region": "us-east-1", "NameSpace": "Windows/Default" } } ], "Flows": { "Flows": [ "(PerformanceCounterMemory,PerformanceCounterDisk),CloudWatch" ] } } } |
4. Go to Control PanelSystem and SecurityAdministrative ToolsSettings and restart EC2 Config service.
And It’s done. You can see metrics on CloudWatch in Custom Metric tab. If you are finding any issues in implementation, you can check C:Program FilesAmazonEc2ConfigServiceLogs Ec2ConfigLog file.
I have used same methodology for some of our clients and personally, I found this simpler in comparison to the other methods.
Feel free to comment if you have any issues in Implementing the same, I will be happy to assist you.
Need professional assistance or consulting services for your custom metrics implementation.? Kindly visit here Please share this blog if you like it.
Voiced by Amazon Polly |
CloudThat is a leading provider of cloud training and consulting services, empowering individuals and organizations to leverage the full potential of cloud computing. With a commitment to delivering cutting-edge expertise, CloudThat equips professionals with the skills needed to thrive in the digital era.
Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!
Ron Langham
Sep 14, 2017
Still having trouble getting this to work. Using EC2Config 3.18. I see the following warning in the Ec2ConfigLog.txt file, could this be related?
2017-09-14T16:24:01.914Z: Warning: Unable to Publish to WMI. | System.Management.Instrumentation.WmiProviderInstallationException: Exception of type ‘System.Management.Instrumentation.WMIInfraException’ was thrown.
at System.Management.Instrumentation.InstrumentationManager.Publish(Object value)
at Ec2Config.LegacyConfiguration.LegacyConfigurator.PublishWmiInstance()
Santosh
Sep 8, 2017
You have attached IAM role, still required to provide access and secret keys?
Adnan
Apr 27, 2017
Actually above tutorial will not work on latest ec2service version. ec2config 4.x. version send data via SSM agent, if you have any idea than please guide me for that
Anderson
Feb 7, 2018
Was it possible to monitor?
Click to Comment