我们使用Azure应用程序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#"
},
]"
}
预期输出
文件名 | 相关性ID | 函数名 | 代码 | ||
---|---|---|---|---|---|
示例文件1 | e33a8d45-0566-4bf2-94f8-54a6fec29bff | 示例函数1 | #231256# | ||
样本文件1 | e33a8d45-0566-4bf2-94f8-54a6fec29bff | Sample- function -2 | #231258# |
mv-expand operator
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"]
文件名 | 相关性ID | 函数名 | 代码 | ||
---|---|---|---|---|---|
示例文件1 | e33a8d45-0566-4bf2-94f8-54a6fec29bff | 示例函数1 | #231256# | ||
样本文件1 | e33a8d45-0566-4bf2-94f8-54a6fec29bff | Sample- function -2 | #231258# |
如何使用KQL实现上述输出?
- 下面是可用于获取相关id的示例命令和函数名在列。
customEvents
| extend Org = tostring(customDimensions.correlationID)
- 参考文档