gpt4 book ai didi

Azure Kusto 查询用于修剪完整 Azure 资源 ID 的名称

转载 作者:行者123 更新时间:2023-12-02 07:38:15 25 4
gpt4 key购买 nike

我有一个查询,该查询取自 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 表内容,例如...

/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/

提前致谢

最佳答案

您可以尝试以下操作:

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 .

引用文献:

关于Azure Kusto 查询用于修剪完整 Azure 资源 ID 的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69255646/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com