简体   繁体   English

如何以编程方式验证 AWS lambda 和粘合作业状态

[英]How to validate AWS lambda and glue job status programatically

I am looking for suggestions on how to validate the glue job and lambda function status, like succeeded or failed in the last run, programmatically using BOTO3 Python.我正在寻找有关如何使用 BOTO3 Python 以编程方式验证胶水作业和 lambda 函数状态的建议,例如上次运行成功或失败。 We have 10+ lambda function and glue jobs that run once a day;我们有 10 多个 lambda 函数和每天运行一次的粘合作业; how can this be achieved using the Python script?如何使用 Python 脚本实现这一点? Any lead would be highly appreciated.任何线索将不胜感激。

I thought of using cloud watch logs to trigger the alert, but I have been tasked with doing this programmatically.我想过使用云监视日志来触发警报,但我的任务是以编程方式执行此操作。

For Glue you would need to first loop over all of the Job Runs by calling GetJobRuns and parse out which ones you want to know more info about, then call GetJobRun :对于 Glue,您需要首先通过调用GetJobRuns所有作业运行并解析出您想了解哪些作业的更多信息,然后调用GetJobRun

  1. get_job_runs | 得到作业运行| Obtain JobName and RunId to pass to next API call获取JobNameRunId传递给下一个 API 调用
  2. get_job_run | 得到工作运行| Check status of JobRunState检查JobRunState的状态

The same thing goes of Lambda, first call ListFunctions then call GetFunction . Lambda 也是如此,首先调用ListFunctions然后调用GetFunction

However, I would strongly advise you to use a DynamoDB table to record the status of all your runs.但是,我强烈建议您使用 DynamoDB 表来记录所有运行的状态。 When your Glue or Lambda runs complete, create an item for each run with the status of the job.当您的 Glue 或 Lambda 运行完成时,为每次运行创建一个包含作业状态的项目。 Then all you need to do is get that days data from DynamoDB.然后您需要做的就是从 DynamoDB 获取当天的数据。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM