azuremonitoringazure-application-insightsazure-vm-scale-setazure-oms

How to monitor a Windows Service on an Azure VM?


I have a windows service running on a Azure VM availability set.

What is the best way to instrument monitoring for this service utilizing any of the Azure monitoring solutions?


Solution

  • If you just want to monitor if it's running or not, you can use Log Analytics. More details please refer to this article.

    I have tested it at my side, it works well.

    1.Create a workspace and Enable the Log Analytics VM Extension as per this doc.

    2.Once step 1 is completed, nav to your workspace -> in the left panel, select Advanced settings -> Data -> Windows Event Logs, then in the textbox, type "system", then select system in the dropdown -> click the add button.

    enter image description here

    3.click Save button.

    enter image description here

    4.In the left panel, click Logs. Then in the query editor, type the following command(please note that the == is case sensitive):

    Event
    | where TimeGenerated >ago(1d)
    | where EventLog  == "System" and EventID ==7036 and Source == "Service Control Manager" 
    | parse kind=relaxed EventData with * '<Data Name="param1">' Windows_Service_Name '</Data><Data Name="param2">' Windows_Service_State '</Data>'*
    //you can add a filter by service name here like    | where Windows_Service_Name =="Windows Update"
    | sort by TimeGenerated desc
    | project Computer, Windows_Service_Name, Windows_Service_State, TimeGenerated
    

    5.The test result:

    enter image description here