首页 > 解决方案 > 使用 Kusto Query 在 ADF v2 中为长时间运行的管道设置警报

问题描述

我在 ADF V2 中有一个管道,它通常需要 3 小时才能运行,但有时需要 3 多个小时。因此,如果管道使用 Azure 日志分析(Kusto Query)运行超过 3 小时,我想设置一个警报,我已经编写了一个查询,但它会显示管道成功或失败的结果。如果管道花费超过 3 小时并且正在进行中,我想要一个警报。

我的查询是

ADFPipelineRun
| where PipelineName == "XYZ"
| where (End - Start) > 3h
| project information = 'Expected Time : 3 Hours, Pipeline took more that 3 hours' ,PipelineName,(End - Start)

你能帮我解决这个问题吗?

提前致谢。拉利特

标签: azure-log-analytics

解决方案


更新

请更改您的查询,如下所示:

ADFPipelineRun 
| where PipelineName == "pipeline11"
| top 1 by TimeGenerated
| where Status in ("Queued","InProgress")
| where (now() - Start) > 3h //please change the time to 3h in your case
| project information = 'Expected Time : 3 Hours, Pipeline took more that 3 hours' ,PipelineName,(now() - Start)

解释:

管道有一些状态,如:Succeeded, Failed, Queued, InProgress. 如果管道现在正在运行且未完成,则其状态必须是以下两者之一:Queued, InProgress

所以我们只需要使用 获取最新的一条记录top 1 by TimeGenerated,然后检查它的状态 if Queuedor InProgress(in query, its where Status in ("Queued","InProgress"))。

最后,我们只需要使用where (now() - Start) > 3h.

我自己测试了一下,没问题。如果您还有更多问题,请告诉我。


推荐阅读