简体   繁体   English

如何使用 Azure Monitor 或 ADF 本身触发 Azure 数据工厂 V2 中长时间运行的进程的警报通知?

[英]How to trigger an alert notification of a long-running process in Azure Data Factory V2 using either Azure Monitor or ADF itself?

I've been trying to find the best way to trigger an alert when an ADF task (ie CopyActivity or Stored Procedure Task) has been running for more than N hours, I wanted to use the Azure Monitor as it is one of the recommended notification services in Azure, however I have not been able to find a "Running" criteria, hence I had to play with the available criteria (Succeeded and Failed) and check this every N hours, however this is still not perfect as I don't know when the process started and we may run the process manually multiple times a day, is there any way you would recommend doing this?我一直在尝试寻找在 ADF 任务(即 CopyActivity 或存储过程任务)运行超过 N 小时时触发警报的最佳方法,我想使用 Azure Monitor,因为它是推荐的通知之一Azure 中的服务,但是我无法找到“正在运行”的标准,因此我不得不使用可用的标准(成功和失败)并每 N 小时检查一次,但这仍然不完美,因为我没有知道流程何时开始,我们可能每天手动多次运行该流程,您有什么建议可以这样做吗? 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?就像一个基于事件的通知,它会监听某个时间变量,一旦它大于阈值就会触发电子邮件通知?

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?就像一个基于事件的通知,它会监听某个时间变量,一旦它大于阈值就会触发电子邮件通知?

Based on your requirements, I suggest you using Azure Data Factory SDKs to monitor your pipelines and activities.根据您的要求,我建议您使用Azure 数据工厂 SDK来监控您的管道和活动。

You could create a time trigger Azure Function which is triggered every N hours.您可以创建一个时间触发器 Azure 函数,它每 N 小时触发一次。 In that trigger function :在那个触发函数中:

  1. You could list all running activities in data factory account.您可以列出数据工厂帐户中的所有正在运行的活动

  2. Then loop them to monitor the 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 .然后循环它们以监视ActivityRun 类中DurationInMs属性,以检查是否有任何活动已运行超过 N 小时并且它仍然处于 In-Progress 状态

  3. Finally, send the email or kill the activity or do whatever you want.最后,发送电子邮件或终止活动或做任何您想做的事情。

I would suggest simple solution: Kusto query for listing all pipeline runs where status is "Queued" and joining it on CorrelationId with those that we are not interested in - typically "Succeeded", "Failed".我建议简单的解决方案: Kusto 查询列出状态为“排队”的所有管道运行,并将其与我们不感兴趣的管道连接到 CorrelationId 上 - 通常是“成功”、“失败”。 Join flavor leftanti does the job by "Returning all the records from the left side that don't have matches from the right." Join flavor leftanti通过“从左侧返回所有右侧没有匹配项的记录”完成这项工作。 (as specified in MS documentation). (如 MS 文档中所述)。 Next step would be to set your desired timeout value - it is 30m in the example code below.下一步是设置所需的超时值 - 在下面的示例代码中为 30m。 Finally, you can configure Alert rule based on this query and get your email notification, or whatever you need.最后,您可以根据此查询配置警报规则并获取电子邮件通知或您需要的任何内容。

ADFPipelineRun | AFPPipelineRun | where Status == "Queued" |其中状态 == “排队” | join kind=leftanti ( ADFPipelineRun | where Status in ("Failed", "Succeeded") ) on CorrelationId |加入 kind=leftanti ( AFPPipelineRun | where Status in ("Failed", "Succeeded") ) on CorrelationId | where Start < ago(30m)起点 < 前 (30m)

I tested this only briefly, maybe there is something missing.我只是简单地测试了这个,也许缺少一些东西。 I have an idea about adding other statuses to be removed from result - like "Cancelled".我有一个关于添加要从结果中删除的其他状态的想法 - 例如“已取消”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Azure Data Factory V2(ADF)在文件夹中查找最新文件 - How to find the latest file in folder using azure data factory v2 (adf) 如何在复制活动( NoSQL 到 SQL )中过滤 ADF(Azure 数据工厂)V2 中最后一次成功触发器运行的数据? - How to filter data on last successful trigger run in ADF(Azure Data Factory) V2 in copy activity ( NoSQL to SQL )? 添加动态内容-Azure数据工厂ADF V2 - Add Dynamic Content - Azure Data Factory ADF V2 使用 Azure 数据工厂 v2 的 ETL - ETL using Azure Data Factory v2 Azure 数据工厂 V2:以文件名作为变量的事件触发器 - Azure Data Factory V2: Event trigger with file name as variable 如何通过 Azure Data Lake Store gen1 中的新文件触发 Azure Data Factory v2 或 Azure Databricks Notebook 中的管道 - How to trigger a pipeline in Azure Data Factory v2 or a Azure Databricks Notebook by a new file in Azure Data Lake Store gen1 使用Azure ADF V2运行.EXE - Run .EXE in using Azure ADF V2 如何在 Azure 数据块中自动化长时间运行的代码和保存数据? - How to automate long-running code and saving data in Azure databricks? 从 Azure 数据工厂 v2 将自定义消息记录到 Azure Monitor 或 App Insights - Logging custom message to Azure Monitor or App Insights from Azure Data Factory v2 Azure数据工厂v2数据转换 - Azure Data Factory v2 Data Transformation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM