azure - 应用洞察 : How to query full trace of azure function executions containing errors?

标签 azure azure-functions azure-application-insights

我想使用 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/

相关文章:

azure - 如何从 powershell 获取 EventHub 命名空间 SAS key

azure - 如何使用Azure上/dev/sdb1下的空磁盘空间?

c# - Azure Function App - 引用外部库

azure - Azure API 管理可以根据请求负载进行缓存吗?

asp.net-mvc - Azure AD 在闲置 20-30 分钟后超时 - 如何避免?

azure - 从 Azure Functions HttpTrigger 返回 JArray 时出现问题

python - 使用 python 在 azure 函数中并行调用方法

azure - 如何在 Azure Application Insights 中查看或筛选记录器名称的跟踪?

c# - 跟踪、调试和信息消息未从 WorkerService 到达 App Insights

azure - 用 KQL 投影一周中的每一天