使用Azure Monitor監視Process

常見的監控場景中,我們除了監控服務器的性能、服務的運行狀況以外,也需要對某些進程的運行狀況進行監控。在Azure Monitor中我們可以將進程ID視爲性能計數器,來完成對進程運行狀況的監控。

每個進程都會在性能計數器中寫入很多數值。默認情況下Azure Monitor是不會收集這些數值的,但是我們可以很容易的在Windows Performance 中看到:
使用Azure Monitor監視Process

配置收集進程數據
我們可以使用如下方式配置Azure Monitor以性能計數器的方式監控進程,在此以notepad爲例:
在Log Analytics工作區中點擊“Advanced settings”--“Data”--“Windows Performance Counters”,添加“Process[notepad]\ID Process”:
使用Azure Monitor監視Process

查看收集到的數據
配置完成以後,我們可以使用如下查詢來查詢notepad的進程ID。如果記事本程序沒有運行,則沒有數據。如果需要設置Alert,警報規則可以配置爲在最近X分鐘內返回零結果時生成警報。

Perf
| where InstanceName == "notepad"
| extend localTimestamp = TimeGenerated + 8h
| where TimeGenerated > ago(5m)
| project TimeGenerated , CounterValue, InstanceName
| order by TimeGenerated desc

使用Azure Monitor監視Process

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章