简体   繁体   English

如何在作业 AWS Glue 中获取开始和结束时间?

[英]How to get Start and End time in a Job AWS Glue?

I want to get Start and End time in a Job AWS Glue, i tested these options but it doesn't work.我想在作业 AWS Glue 中获取开始和结束时间,我测试了这些选项,但它不起作用。

args = getResolvedOptions(sys.argv, ['TempDir','JOB_NAME','START_JOB_RUN','END_JOB_RUN'])
start_job_run = args['START_JOB_RUN']

or或者

args = getResolvedOptions(sys.argv, ['TempDir','JOB_NAME'])
job_name = args['JOB_NAME']
start_job_run = job_name['START_JOB_RUN']

Another option, but in my opinion it's not the best way, it's define at the beginning of script start time and in the end a end time.另一种选择,但在我看来这不是最好的方法,它是在脚本开始时间的开头和结束时间定义的。

You can't get the job start and end time within the same glue job.您无法在同一个胶水作业中获得作业的开始和结束时间。

One option is that you can always use the system time to log when the job started and when it ended.一种选择是您始终可以使用系统时间来记录作业何时开始和何时结束。

Otherwise, you should use the JobRun API to get the job metadata and status.否则,您应该使用 JobRun API 来获取作业元数据和状态。

You can use boto3 library to retrive the details.您可以使用 boto3 库来检索详细信息。

response = glueClient.get_job_run(
    JobName='string',
    RunId='string',
    PredecessorsIncluded=True|False
)

It will result in startTime, endTime along with other details.它将产生 startTime、endTime 以及其他详细信息。

Here is the detailed documentation:这是详细的文档:

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/glue.html#Glue.Client.get_job_run https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/glue.html#Glue.Client.get_job_run
https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-jobs-runs.html https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-jobs-runs.html

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

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