Azure 应用洞察 |知识库 |获取异常详细信息

Azure Application Insights | KQL | Get exception details

我们正在使用 Azure application Insights 进行错误记录。我是 KQL 的新手,正在尝试以下列格式从内置的“customDimensions”列中获取自定义属性,

“customDimensions”列中的数据

{
  "File Name":"Sample File 1",
  "Correlation ID":"e33a8d45-0566-4bf2-94f8-54a6fec29bff",
  "Error List":"[
      {
        "Function Name":"Sample Function 1",
        "Code":"#231256#"
      },
      {
        "Function Name":"Sample-Function-2",
        "Code":"#231258#"
      },
   ]"
}

预期输出

File Name Correlation ID Function Name Code
Sample File 1 e33a8d45-0566-4bf2-94f8-54a6fec29bff Sample Function 1 #231256#
Sample File 1 e33a8d45-0566-4bf2-94f8-54a6fec29bff Sample-Function-2 #231258#

如何使用 KQL 实现上述输出?

谢谢。

更新:添加示例数据表

datatable(ErrorDetails:dynamic)
[
    dynamic({
        "File Name":"Sample File 1",
        "Correlation ID":"e33a8d45-0566-4bf2-94f8-54a6fec29bff",
        "Error List": [{
                "Function Name":"Sample Function 1",
                "Code":"#231256#"
            },
            {
                "Function Name":"Sample-Function-2",
                "Code":"#231258#"
            }
        ]
    })
]

How can I achieve the above output using KQL?

  • Beow 是示例命令,可用于获取列中的 correlation idfunction names
customEvents
 | extend Org = tostring(customDimensions.correlationID)
  • 参考这个有相关讨论的document

mv-expand 运算符

datatable(ErrorDetails:dynamic)
[
    dynamic({
        "File Name":"Sample File 1",
        "Correlation ID":"e33a8d45-0566-4bf2-94f8-54a6fec29bff",
        "Error List": [{
                "Function Name":"Sample Function 1",
                "Code":"#231256#"
            },
            {
                "Function Name":"Sample-Function-2",
                "Code":"#231258#"
            }
        ]
    })
]
| mv-expand EL = ErrorDetails.["Error List"]
| project ["File Name"] = ErrorDetails["File Name"], ["Correlation ID"] = ErrorDetails["Correlation ID"], ["Function Name"] = EL["Function Name"], ["Code"] = EL["Code"]
File Name Correlation ID Function Name Code
Sample File 1 e33a8d45-0566-4bf2-94f8-54a6fec29bff Sample Function 1 #231256#
Sample File 1 e33a8d45-0566-4bf2-94f8-54a6fec29bff Sample-Function-2 #231258#

Fiddle