使用Azure Monitor监控服务器内存使用率

前面和大家聊了如何使用Azure Monitor对服务器的CPU资源进行监控,从而确保在出现CPU使用率过高时,我们可以第一时间对其进行处理,来确保系统可以平稳运行。但是大家要知道,除了CPU资源以外还有很多项指标会影响我们系统的运行状态,比如我们今天要和大家聊得内存资源。内存使用率过高会导致业务系统运行缓慢、无法登陆、系统崩溃等问题。所以对内存资源使用率的监视也是必不可少的。那么下面就让我们来看一下如何使用Azure Monitor来监控系统的内存使用率。

先觉条件
使用Azure Monitor监控系统的内存资源使用率的先觉条件我们已经在之前的文章中和大家聊过,具体大家可以参考如下博客:
https://blog.51cto.com/wuyvzhang/2472792

查询收集到的数据
我们可以使用如下查询语句,查询内存剩余内存小于1024MB的服务器:

let setMBValue = 1024;
let startDate = ago(12h);
// enter how many days/hours to look back on
Perf
| where TimeGenerated > startDate
| where ObjectName == "Memory" and CounterName == "Available MBytes Memory" and Computer in ((Heartbeat
| distinct Computer))
| extend FreeMemory = CounterValue
| summarize FreeMemoryMB = min(FreeMemory) by Computer
| where FreeMemoryMB < setMBValue
| summarize max(FreeMemoryMB) by Computer
| join
(
Perf
| where TimeGenerated > startDate
| where ObjectName == "Memory" and CounterName == "Available MBytes Memory" and Computer in ((Heartbeat
| distinct Computer))
| extend FreeMemory = CounterValue
)
on Computer
| make-series Free_Memory_MB = min(FreeMemory) on TimeGenerated from ago(8h) to now() step 2h by Computer
| render timechart

使用Azure Monitor监控服务器内存使用率

创建Alert
如果我们想要设置邮件,短信等报警规则,可以通过“+ New alert rule”来创建:
使用Azure Monitor监控服务器内存使用率

创建完成Alert以后,当系统的可用内存低于1024MB时,我们就会收到警报:
使用Azure Monitor监控服务器内存使用率
使用Azure Monitor监控服务器内存使用率

将性能图表固定到仪表板
统一我们也可以通过点击查询窗口右上方的“固定”按钮,然后选择我们要将图标展示在那个Dashboard,来将查询结果展示到Azure Dashboard:
使用Azure Monitor监控服务器内存使用率

猜你喜欢

转载自blog.51cto.com/wuyvzhang/2472807