Parsing logs to Azure log service from on-prem virtual machine Setup email alerts from Azure log service

Add VM performance counters to Azure Log Service

Welcome back. In this post I will continue the discussion about the Azure Log Service, which builds on-top of Shipping logs to Azure and pre-parsing logs. You are welcome to read them first.

Now I will write about adding a custom performance counter monitor to Microsoft monitoring agent on Windows Server machine. But first a bit of background.

Our customer has few Windows virtual machines with web servers and databases, which runs a business critical document system. Those VMs are connected to Azure logs service with Microsoft monitoring agent. By default, “Windows Performance Counters” section inside OMS workspace is already sending some basic performance counters like LogicalDisk(*)\% Free Space, Memory(*)\Available MBytes or Processor(_Total)\% Processor Time every 10 seconds. That’s great to monitor the VM as a whole, but to detect anomalies in business critical processes and applications, we need to be more specific with performance counters to send alerts. In essence, we would like to know when a specific process is giving us a problem.

To add any performance counter to our monitoring agent, we first need to know how to find the counter and what is the correct syntax. Powershell to the rescueeeeee… Let’s open Powershell and type the following:

Get-Counter -Counter “\Memory\Available MBytes”

Get available memory in MB on a VM.
Figure 1: Get available memory in MB on a VM.

We are calling Get-Counter command to retrieve the available memory on a running machine. Nice! Now I would like to get the available counters of a process on our server. We run the Windows service which has a name Service. Let’s write this command:

Get-Counter -Counter “\Process(service)\*”

Get all performance counters of a service.exe process
Figure 2: Get all performance counters of a service.exe process.

Now let’s get more specific and grab Working set – private counter from the service.exe process. We modify the command like this:

Get-Counter -Counter “\Process(service)\Working Set – Private”

Get working set counter from service.exe process

Figure 3: Get working set counter from service.exe process.

What we get back are the bytes of a Working set – private counter.

To add this counter to our Azure Log Service, we need to go to Azure portal and set it up. Go to your OMS instance and select Advanced Settings > Data >Windows performance counters from the menu. Now we can add a new counter. In our case we enter the command from above: Process(service)\Working Set – Private, hit add and set the sample interval to 10 seconds or whatever you like.

Add a new performance counter.
Figure 4: Add a new performance counter.

Within a few minutes we can see the performance counter in Azure logs.

Figure 5: Performance counter is saved to Azure Logs.

And that’s it! Next time we will setup an Alert so stay tunned :).

If you want to know more about the Get-Counter tool, click here.

About Miha
I've always been fascinated by computers. I am happy that I can work in this creative field of software development, where I can solve problems. I am also an avid cyclist :) and I love to learn...a lot!
Related Posts
  • All
  • By Author
  • By Category
  • By Tag

Leave a Reply