Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
日志搜索警报规则通过使用 Log Analytics 查询以设置频率评估日志来监视资源。 可以在日志搜索警报规则查询中包含来自 Azure 数据资源管理器和 Azure Resource Graph 的数据。
本文提供了使用 Azure 数据资源管理器和 Azure Resource Graph 的日志搜索警报规则查询的示例。 有关创建日志搜索警报规则的详细信息,请参阅创建日志搜索警报规则。
检查虚拟机运行状况的查询
此查询发现标记为“关键”的虚拟机,这些虚拟机在过去 2 分钟内没有检测信号。
arg("").Resources
| where type == "microsoft.compute/virtualmachines"
| summarize LastCall = max(case(isnull(TimeGenerated), make_datetime(1970, 1, 1), TimeGenerated)) by name, id
| extend SystemDown = case(LastCall < ago(2m), 1, 0)
| where SystemDown == 1
此查询发现标记为“关键”的虚拟机在 24 小时前有检测信号,但在过去 2 分钟内没有检测信号。
{
arg("").Resources
| where type == "microsoft.compute/virtualmachines"
| where tags.BusinessCriticality =~ 'critical' and subscriptionId == '123-456-123-456'
| join kind=leftouter (
Heartbeat
| where TimeGenerated > ago(24h)
)
on $left.name == $right.Resource
| summarize LastCall = max(case(isnull(TimeGenerated), make_datetime(1970, 1, 1), TimeGenerated)) by name, id
| extend SystemDown = case(LastCall < ago(2m), 1, 0)
| where SystemDown == 1
}
用于筛选需要监视的虚拟机的查询
{
let RuleGroupTags = dynamic(['Linux']);
Perf | where ObjectName == 'Processor' and CounterName == '% Idle Time' and (InstanceName in ('_Total,'total'))
| extend CpuUtilisation = (100 - CounterValue)
| join kind=inner hint.remote=left (arg("").Resources
| where type =~ 'Microsoft.Compute/virtualMachines'
| project _ResourceId=tolower(id), tags) on _ResourceId
| project-away _ResourceId1
| where (tostring(tags.monitorRuleGroup) in (RuleGroupTags))
}
查询,查找将在 30 天内过期的证书的资源
{
arg("").Resources
| where type == "microsoft.web/certificates"
| extend ExpirationDate = todatetime(properties.expirationDate)
| project ExpirationDate, name, resourceGroup, properties.expirationDate
| where ExpirationDate < now() + 30d
| order by ExpirationDate asc
}
查询,会在订阅中创建新资源时发出警报
{
arg("").resourcechanges
| extend changeTime = todatetime(properties.changeAttributes.timestamp),
changeType = tostring(properties.changeType),targetResourceType = tostring(properties.targetResourceType),
changedBy = tostring(properties.changeAttributes.changedBy),
createdResource = tostring(properties.targetResourceId)
| where changeType == "Create" and changeTime <ago(1h)
| project changeTime,createdResource,changedBy
}