You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Logic App中Terminate终止的工作流未在Log Analytics显示失败状态

问题描述
  • 环境:使用包含Try-Catch块+Terminate语句的Logic App,搭配LogicAppsManagement监控解决方案
  • 现象:通过Terminate动作标记为失败的工作流,在Logic App运行历史中正常显示为失败状态;但执行以下Log Analytics查询时,这类运行并未被统计为Failed状态:
// Logic App execution distribution by status 
// Completed executions by workflow,status and error. 
//logic app execution status summary
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.LOGIC"
| where OperationName has "workflowRunCompleted"
| summarize dcount(resource_runId_s) by resource_workflowName_s, status_s, error_code_s
| project LogicAppName = resource_workflowName_s , NumberOfExecutions = dcount_resource_runId_s , RunStatus = status_s , Error = error_code_s 
  • 需求:期望查询结果与Logic App运行历史中的状态保持一致
原因与解决方案

核心原因

当在Try-Catch块中使用Terminate动作标记失败时,Logic App的运行事件在Log Analytics中会触发workflowRunFailed操作,而非当前查询中过滤的workflowRunCompleted。当前查询仅捕获了正常完成的运行,遗漏了由Terminate触发的失败运行事件。

修正后的查询

调整查询条件,同时包含workflowRunCompleted和workflowRunFailed两种操作,确保覆盖所有运行状态:

// Logic App execution distribution by status 
// Completed and failed executions by workflow,status and error. 
//logic app execution status summary
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.LOGIC"
| where OperationName has_any ("workflowRunCompleted", "workflowRunFailed")
| summarize dcount(resource_runId_s) by resource_workflowName_s, status_s, error_code_s
| project LogicAppName = resource_workflowName_s , NumberOfExecutions = dcount_resource_runId_s , RunStatus = status_s , Error = error_code_s 

额外说明

  • 若需要更精准区分Terminate导致的失败,可以进一步过滤error_code_s字段,通常Terminate动作对应的错误代码为TerminateWithStatus
  • 部分版本的Logic App日志中存在resource_runStatus_s字段,可直接匹配运行状态,进一步增强查询准确性

内容的提问来源于stack exchange,提问作者max gaulhofer

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 00:21:05