如何使用 Azure Monitor 或 ADF 本身在 Azure Data Factory V2 中触发长 运行 进程的警报通知?
How to trigger an alert notification of a long-running process in Azure Data Factory V2 using either Azure Monitor or ADF itself?
我一直在努力寻找当 ADF 任务(即 CopyActivity 或存储过程任务)已 运行 超过 N 小时时触发警报的最佳方法,我想使用Azure Monitor 因为它是 Azure 中推荐的通知服务之一,但是我无法找到 "Running" 条件,因此我不得不使用可用条件(成功和失败)并每 N 小时检查一次,但是这仍然不完美,因为我不知道该过程何时开始,我们可能 运行 一天手动多次该过程,您有什么建议这样做的方法吗?就像一个基于事件的通知,它监听一些时间变量,一旦它大于阈值就会触发电子邮件通知?
is there any way you would recommend doing this? like a event-based
notification that listens to some time variable and as soon as it is
greater than the threshold triggers an email notification?
根据您的要求,我建议您使用 Azure Data Factory SDKs 来监控您的管道和活动。
您可以创建一个每 N 小时触发一次的 time trigger Azure Function。在那个触发函数中:
您可以列出数据工厂帐户中的所有 running activities。
然后循环监控DurationInMs Property in ActivityRun Class to check if any activity has been running for more than N hours and it's still In-Progress status.
最后,发送电子邮件或杀死activity或做任何你想做的事。
我会建议简单的解决方案:
Kusto 查询列出状态为 "Queued" 的所有管道运行,并将其与我们不感兴趣的那些在 CorrelationId 上加入 - 通常为 "Succeeded"、"Failed"。 Join flavor leftanti 通过 "Returning all the records from the left side that don't have matches from the right." 完成工作(如 MS 文档中所指定)。
下一步是设置所需的超时值——在下面的示例代码中为 30m。
最后,您可以根据此查询配置警报规则并获取您的电子邮件通知,或任何您需要的。
ADFPipelineRun
|其中状态 == "Queued"
|加入 kind=leftanti (ADFPipelineRun
|其中状态在 ("Failed", "Succeeded") )
在 CorrelationId 上
|其中开始 < ago(30m)
我只是简单地测试了一下,可能还缺少一些东西。我有一个关于添加要从结果中删除的其他状态的想法 - 比如 "Cancelled".
我一直在努力寻找当 ADF 任务(即 CopyActivity 或存储过程任务)已 运行 超过 N 小时时触发警报的最佳方法,我想使用Azure Monitor 因为它是 Azure 中推荐的通知服务之一,但是我无法找到 "Running" 条件,因此我不得不使用可用条件(成功和失败)并每 N 小时检查一次,但是这仍然不完美,因为我不知道该过程何时开始,我们可能 运行 一天手动多次该过程,您有什么建议这样做的方法吗?就像一个基于事件的通知,它监听一些时间变量,一旦它大于阈值就会触发电子邮件通知?
is there any way you would recommend doing this? like a event-based notification that listens to some time variable and as soon as it is greater than the threshold triggers an email notification?
根据您的要求,我建议您使用 Azure Data Factory SDKs 来监控您的管道和活动。
您可以创建一个每 N 小时触发一次的 time trigger Azure Function。在那个触发函数中:
您可以列出数据工厂帐户中的所有 running activities。
然后循环监控DurationInMs Property in ActivityRun Class to check if any activity has been running for more than N hours and it's still In-Progress status.
最后,发送电子邮件或杀死activity或做任何你想做的事。
我会建议简单的解决方案: Kusto 查询列出状态为 "Queued" 的所有管道运行,并将其与我们不感兴趣的那些在 CorrelationId 上加入 - 通常为 "Succeeded"、"Failed"。 Join flavor leftanti 通过 "Returning all the records from the left side that don't have matches from the right." 完成工作(如 MS 文档中所指定)。 下一步是设置所需的超时值——在下面的示例代码中为 30m。 最后,您可以根据此查询配置警报规则并获取您的电子邮件通知,或任何您需要的。
ADFPipelineRun |其中状态 == "Queued" |加入 kind=leftanti (ADFPipelineRun |其中状态在 ("Failed", "Succeeded") ) 在 CorrelationId 上 |其中开始 < ago(30m)
我只是简单地测试了一下,可能还缺少一些东西。我有一个关于添加要从结果中删除的其他状态的想法 - 比如 "Cancelled".