azure-log-analytics - 使用 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)
你能帮我解决这个问题吗?
提前致谢。拉利特
解决方案
更新:
请更改您的查询,如下所示:
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 Queued
or InProgress
(in query, its where Status in ("Queued","InProgress")
)。
最后,我们只需要使用where (now() - Start) > 3h
.
我自己测试了一下,没问题。如果您还有更多问题,请告诉我。
推荐阅读
- c - 如何在c中的递归算法中通过引用传递参数?
- javascript - 从选择框中传递值作为 React 中的参数
- python - 如何在 Pyplot 中获得平滑的平均曲线
- git - grep 存储库中的所有提交
- swift - 更改 WKInterfaceLabel 文本
- java - 如何仅使用 KeyListener 旋转一次摆动的矩形,而无需再次旋转
- android - 远程 logcat - Android Studio
- c++ - Windows Subsystem for Linux (WSL) 下的间歇性随机“找不到文件”错误
- mysql - MySQL 全文不准确
- context-free-grammar - 看了两个问题,不知道怎么回答