Azure Monitor 日志查询中的 resource() 表达式

resource 表达式在范围限定为资源的 Azure Monitor 查询中使用,可以从其他资源检索数据。

语法

resource(标识符)

参数

  • 标识符:资源的资源 ID。
标识符 说明 示例
资源 包括资源的数据。 resource("/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcesgroups/myresourcegroup/providers/microsoft.compute/virtualmachines/myvm")
资源组或订阅 包括资源及其包含的所有资源的数据。 resource("/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcesgroups/myresourcegroup)

注释

  • 你必须具有该资源的读取访问权限。

示例

union (Heartbeat),(resource("/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcesgroups/myresourcegroup/providers/microsoft.compute/virtualmachines/myvm").Heartbeat) | summarize count() by _ResourceId, TenantId
union (Heartbeat),(resource("/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcesgroups/myresourcegroup).Heartbeat) | summarize count() by _ResourceId, TenantId

后续步骤