我想使用 Application Insights 分析 Azure Functions 的日志输出。如果函数执行的日志输出至少包含一个错误,我想查看该执行的整个日志输出。
起点:
traces
| where severityLevel == 3
| where operation_Name == "MyFunctionName"
| project timestamp, operation_Name, message
但这仅提供错误本身,而不提供函数执行的其他输出。
最佳答案
对于 Azure Functions V1:
traces
| where severityLevel == 3
| where operation_Id != ""
| where operation_Name == "MyFunctionName"
| project operation_Name , operation_Id, severityLevel
| join (traces | project timestamp, operation_Id, message ) on operation_Id
| project timestamp, operation_Name, operation_Id, message
具有相同操作_Id 的所有行都属于一个函数执行。
对于 Azure Functions V2:
traces
| extend invocationId = tostring(customDimensions.InvocationId)
| where severityLevel == 3
| where invocationId != ""
| where operation_Name == "MyFunctionName"
| project operation_Name, severityLevel, invocationId
| join (traces |extend invocationId = tostring(customDimensions.InvocationId)| project timestamp, invocationId, message ) on invocationId
| project timestamp, operation_Name, message, invocationId
具有相同 invokingId 的所有行都属于一个函数执行。
关于azure - 应用洞察 : How to query full trace of azure function executions containing errors?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55807767/