Azure Kusto 查询 trim 完整 Azure 资源 ID 的名称

Azure Kusto Query to trim the name of a full Azure Resource ID

我有一个从 Azure 应用服务输出的诊断日志中提取并推送到 Log Analytics 工作区的查询。

AppServiceAppLogs
| where TimeGenerated >= now(-1h) and Level == "Error"
| project TimeGenerated , _ResourceId , Source, ResultDescription
| summarize ErrorsLogged = count() by _ResourceId
| order by ErrorsLogged
| render piechart 

当图表(任何图表)呈现时,它会显示正确的完整 _ResourceId table 内容,例如...

/subscriptions/00000-000000-000000-00000000/resourcegroups/my-resource-group/providers/microsoft.web/sites/my-webapp

这些最终因太长而无法显示。结果中的 /subscriptions/00000-000000-000000-00000000/resourcegroups/my-resource-group/providers/microsoft.web/sites/ 是否有 trim?

提前致谢

您可以尝试类似的方法:

AppServiceAppLogs
| where TimeGenerated >= now(-1h) and Level == "Error"
| project TimeGenerated, ResourceName=tostring(split(_ResourceId, "/")[-1]), Source, ResultDescription
| summarize ErrorsLogged = count() by ResourceName
| order by ErrorsLogged
| render piechart 

基本上它使用 "/" 作为分隔符(它给你一个数组)拆分 _ResourceId,然后获取该数组中的最后一个元素并将其别名为 ResourceName

参考文献: