Azure应用程序见解查询合并行

时间:2019-02-27 08:15:07

标签: azure-application-insights

我有以下查询:

 public class DailyTransactions
{
    [Key]
    public int DailyTransactions_Id { get; set; }

    public double Account { get; set; }

    public string Account_Name { get; set; }

    public double Debit { get; set; }

    public double Credit { get; set; }

    public DateTime Date { get; set; }

    public string Remarks { get; set; }

    public int CustomerId { get; set; }

    [ForeignKey("CustomerId")]
    public virtual Customers customers { get; set; }

    public int ContractId { get; set; }

    [ForeignKey("ContractId")]
    public virtual Contracts contracts { get; set; }

}

我得到如下结果: enter image description here 我想通过operation_id合并行,并获得如下结果: enter image description here

2 个答案:

答案 0 :(得分:0)

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

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

我没有相同的数据,但是做了一些相似的数据,在我这边工作得很好。

合并之前:

enter image description here

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

enter image description here

答案 1 :(得分:0)

最终查询是:

| 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
) on operation_Id
| join kind = inner(
traces
| where customDimensions.Category == "Function"
| where isnotempty(customDimensions.prop__recordName)
| project operation_Id,customDimensions.prop__recordName
) on operation_Id
| project operation_Id, Entity = customDimensions_prop__Entity, recordName = customDimensions_prop__recordName, recordId = customDimensions_prop__recordId