如何监控 Azure VM 上的 Windows 服务?

How to monitor a Windows Service on an Azure VM?

我在 Azure VM 可用性集上有一个 windows 服务 运行。

使用任何 Azure 监控解决方案来监测此服务的最佳方法是什么?

如果您只想监控它是否 运行,您可以使用 Log Analytics。更多详情请参考此article.

我在身边测试过,效果很好。

1.Create 工作区并根据此 doc.

启用 Log Analytics VM 扩展

2.Once 步骤 1 完成,导航到您的工作区 -> 在左侧面板中,select 高级设置 -> 数据 -> Windows 事件日志,然后在文本框中,输入 "system",然后在下拉列表中输入 select 系统 -> 单击添加按钮。

3.click 保存按钮。

4.In 在左侧面板中,单击日志。然后在查询编辑器中,键入以下命令(请注意 == 区分大小写):

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 测试结果: