CloudWatch Custom Metrics for Windows Server

June 2, 2016 | Comments(3) |

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.

ADVANTAGES:

  • It is very easy to implement.
  • There is no need to write scripts which sometimes can be really lengthy.
  • Task Scheduler is not required which in turn can save memory.
  • Most Importantly, margin of making error is very less.

Let’s take an example that you want to send Free disk and Memory utilization metrics to CloudWatch.

PREREQUISITES:

  • EC2Config version should be 2.2.5 or later.
  • Create IAM user with following permissions.

IMPLEMENTATION:

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.

ec2
3. Go to C:Program FilesAmazonEc2ConfigServiceSettingsAWS.EC2.Windows.CloudWatch.json and replace below code in the file.

Screenshot (7) 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.


3 Responses to “CloudWatch Custom Metrics for Windows Server”

  1. Adnan

    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

    Reply
  2. Santosh

    You have attached IAM role, still required to provide access and secret keys?

    Reply
  3. Ron Langham

    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()

    Reply

Leave a Reply