使用 Glue 导出 DynamoDB 时如何查看进度 table

How to see progress when using Glue to export DynamoDB table

我正在尝试将 DynamoDB table 中的每个项目导出到 S3。我找到了本教程 https://aws.amazon.com/blogs/big-data/how-to-export-an-amazon-dynamodb-table-to-amazon-s3-using-aws-step-functions-and-aws-glue/ 并按照示例进行操作。基本上,

table = glueContext.create_dynamic_frame.from_options(
  "dynamodb",
  connection_options={
    "dynamodb.input.tableName": table_name,
    "dynamodb.throughput.read.percent": read_percentage,
    "dynamodb.splits": splits
  }
)

glueContext.write_dynamic_frame.from_options(
  frame=table,
  connection_type="s3",
  connection_options={
    "path": output_path
  },
  format=output_format,
  transformation_ctx="datasink"
)

我在非产品环境中的小型 table 中对其进行了测试,它运行良好。但是我的 Dynamo table 在生产中超过 400GB,2 亿个项目。我想这需要一段时间,但我不知道需要多长时间。几个小时,甚至几天?有什么方法可以显示进度吗?例如,显示已处理的项目数。我不想盲目地开始这份工作然后等待。

一种方法是 enable continuous logging 让您的 AWS Glue 作业监控其进度。

另一种方法是每当文件存储在 S3 中时触发 Lambda 函数,使用 Amazon S3 event notifications

您是否尝试过 was 文档中的 custom waiter class? 例如,Glue 作业的自定义服务员应如下所示:

class JobCompleteWaiter(CustomWaiter):
    def __init__(self, client):
        super().__init__(
            "JobComplete",
            "get_job_run",
            "JobRun.JobRunState",
            {"SUCCEEDED": WaitState.SUCCEEDED, "FAILED": WaitState.FAILED},
            client,
            max_tries=100,
        )

    def wait(self, JobName, RunId):
        self._wait(JobName=JobName, RunId=RunId)

根据 boto3 文档,您应该期望 JOB 有 6 种不同的可能状态:STARTING'|'RUNNING'|'STOPPING'|'STOPPED'|'SUCCEEDED'|'FAILED'|'TIMEOUT' 所以我checkein是SUCCEEDED还是FAILED.