首页 > 解决方案 > Azure 应用程序洞察力查询合并行

问题描述

我有以下查询:

traces
| where customDimensions.Category == "Function"
| where isnotempty(customDimensions.prop__recordId) or isnotempty(customDimensions.prop__Entity)
| project operation_Id, Entity = customDimensions.prop__Entity, recordName = customDimensions.prop__recordName, recordId = customDimensions.prop__recordId

我得到这样的结果: 在此处输入图像描述 我想按 operation_id 合并行,并得到这样的结果: 在此处输入图像描述

标签: azure-application-insights

解决方案


请尝试使用连接运算符,如下所示:

traces
| where customDimensions.Category == "Function"
| where isnotempty(customDimensions.prop__recordId) 
| project operation_Id, customDimensions.prop__recordId
| join kind = inner(
traces
| where customDimensions.Category == "Function"
| where isnotempty(customDimensions.prop__Entity)
| project operation_Id,customDimensions.prop__Entity,customDimensions.prop__recordName
) on operation_Id
| project-away operation_Id1 //remove the redundant column,note that it's operation_Id1 
| project operation_Id, Entity = customDimensions.prop__Entity, recordName = customDimensions.prop__recordName, recordId = customDimensions.prop__recordId

我没有相同的数据,但制作了一些类似的数据,在我身边工作得很好。

合并前:

在此处输入图像描述

合并后:(注意使用 project-away 删除用作连接键的冗余列,默认情况下它始终具有数字后缀 1)

在此处输入图像描述


推荐阅读