繁体   English   中英

如何使用 azure 资源图获取 Azure VM 最后一次重启

[英]how to get Azure VM last reboot using azure resource graph

我正在使用 azure 资源图来创建仪表板并需要 VM 上次重启或关机日期。 请需要你的帮助。 谢谢

我试图在我的环境中重现相同的内容:

图查询:

Resources
| where type == 'microsoft.compute/virtualmachines'
| summarize count() by PowerState = tostring(properties.extended.instanceView.powerState.code)

检查电源状态: 在此处输入图像描述

尝试以下查询:

resources
| where type has 'microsoft.compute/virtualmachines/extensions' 
| where name has 'MicrosoftMonitoringAgent' or name has 'AzureMonitorWindowsAgent' 
| extend AzureVM = extract('virtualMachines/(.*)/extensions',1,id), ArcVM = extract('machines/(.*)/extensions',1,id)
|summarize count() by name=tolower(AzureVM), ArcVM=tolower(ArcVM), subscriptionId, resourceGroup,  AgentType=name
| extend hasBoth = iff(count_ > 0, 'Yes', 'No') 
| join 
 ( 
    resources
    | where type =~ 'Microsoft.Compute/virtualMachines'
    | project name, properties.extended.instanceView.powerState.displayStatus,
                    properties.extended.instanceView.powerState.code,
                    created_ = properties.timeCreated
    | order by name desc
 ) on name

我在哪里创建了 azure 虚拟机运行时间和释放时间。

在此处输入图像描述

如果你想在虚拟机停止时发出警报,你可以检查这个: azureportal - Azure 警报在虚拟机停止时通知 - 堆栈内存溢出

参考资料: 资源图示例 | 微软学习

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM