AWS Batch 活動 - AWS Batch

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

AWS Batch 活動

AWS Batch 將工作狀態變更事件傳送至 EventBridge。 AWS Batch 追蹤工作的狀態。如果先前提交的工作狀態變更,則會叫用事件。例如,如果狀RUNNING態中的工作移至狀FAILED態。這些事件便歸類為任務狀態變更事件。

注意

AWS Batch future 可能會新增其他事件類型、來源和詳細資料。如果您以程式設計方式還原序列化事件 JSON 資料,請確定您的應用程式已準備好處理未知的屬性。這是為了避免在添加這些附加屬性時出現問題。

任務狀態變更事件

只要現有 (先前提交的) 工作變更狀態,就會建立事件。如需 AWS Batch 工作狀態的詳細資訊,請參閱任務狀態

注意

不會為初始工作提交建立事件。

範例 任務狀態變更事件

Job 狀態變更事件會以下列格式傳遞。此detail區段類似於 API 參考DescribeJobsAPI 作業傳回的JobDetail物件。AWS Batch 如需有關 EventBridge 參數的詳細資訊,請參閱 Amazon EventBridge 使用者指南中的事件和事件模式

{ "version": "0", "id": "c8f9c4b5-76e5-d76a-f980-7011e206042b", "detail-type": "Batch Job State Change", "source": "aws.batch", "account": "123456789012", "time": "2022-01-11T23:36:40Z", "region": "us-east-1", "resources": [ "arn:aws:batch:us-east-1:123456789012:job/4c7599ae-0a82-49aa-ba5a-4727fcce14a8" ], "detail": { "jobArn": "arn:aws:batch:us-east-1:123456789012:job/4c7599ae-0a82-49aa-ba5a-4727fcce14a8", "jobName": "event-test", "jobId": "4c7599ae-0a82-49aa-ba5a-4727fcce14a8", "jobQueue": "arn:aws:batch:us-east-1:123456789012:job-queue/PexjEHappyPathCanary2JobQueue", "status": "RUNNABLE", "attempts": [], "createdAt": 1641944200058, "retryStrategy": { "attempts": 2, "evaluateOnExit": [] }, "dependsOn": [], "jobDefinition": "arn:aws:batch:us-east-1:123456789012:job-definition/first-run-job-definition:1", "parameters": {}, "container": { "image": "137112412989.dkr.ecr.us-east-1.amazonaws.com/amazonlinux:latest", "command": [ "sleep", "600" ], "volumes": [], "environment": [], "mountPoints": [], "ulimits": [], "networkInterfaces": [], "resourceRequirements": [ { "value": "2", "type": "VCPU" }, { "value": "256", "type": "MEMORY" } ], "secrets": [] }, "tags": { "resourceArn": "arn:aws:batch:us-east-1:123456789012:job/4c7599ae-0a82-49aa-ba5a-4727fcce14a8" }, "propagateTags": false, "platformCapabilities": [] } }

Job 佇列封鎖的事件

只要 AWS Batch 偵測到RUNNABLE狀態中的工作並因此封鎖佇列,就會在 Amazon E CloudWatch vents 中建立事件。如需支援之封鎖佇列原因的相關資訊,請參閱封鎖的工作佇列訊息範例DescribeJobsAPI 動作的statusReason欄位中也有相同的原因。

範例 任務狀態變更事件

Job 狀態變更事件會以下列格式傳遞。此detail區段類似於 API 參考DescribeJobsAPI 作業傳回的JobDetail物件。AWS Batch 如需有關 EventBridge參數的詳細資訊,請參閱 Amazon EventBridge 使用者指南中的事件和事件模式

{ "version": "0", "id": "c8f9c4b5-76e5-d76a-f980-7011e206042b", "detail-type": "Batch Job Queue Blocked", "source": "aws.batch", "account": "123456789012", "time": "2022-01-11T23:36:40Z", "region": "us-east-1", "resources": [ "arn:aws:batch:us-east-1:123456789012:job/4c7599ae-0a82-49aa-ba5a-4727fcce14a8", "arn:aws:batch:us-east-1:123456789012:job-queue/PexjEHappyPathCanary2JobQueue" ], "detail": { "jobArn": "arn:aws:batch:us-east-1:123456789012:job/4c7599ae-0a82-49aa-ba5a-4727fcce14a8", "jobName": "event-test", "jobId": "4c7599ae-0a82-49aa-ba5a-4727fcce14a8", "jobQueue": "arn:aws:batch:us-east-1:123456789012:job-queue/PexjEHappyPathCanary2JobQueue", "status": "RUNNABLE", "statusReason": "blocked-reason" "attempts": [], "createdAt": 1641944200058, "retryStrategy": { "attempts": 2, "evaluateOnExit": [] }, "dependsOn": [], "jobDefinition": "arn:aws:batch:us-east-1:123456789012:job-definition/first-run-job-definition:1", "parameters": {}, "container": { "image": "137112412989.dkr.ecr.us-east-1.amazonaws.com/amazonlinux:latest", "command": [ "sleep", "600" ], "volumes": [], "environment": [], "mountPoints": [], "ulimits": [], "networkInterfaces": [], "resourceRequirements": [ { "value": "2", "type": "VCPU" }, { "value": "256", "type": "MEMORY" } ], "secrets": [] }, "tags": { "resourceArn": "arn:aws:batch:us-east-1:123456789012:job/4c7599ae-0a82-49aa-ba5a-4727fcce14a8" }, "propagateTags": false, "platformCapabilities": [] } }