本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用亞馬遜監控AWS DataSync活動CloudWatch
您可以AWS DataSync使用 AmazonCloudWatch 來監控;該服務會收集來自的原始資料,並處理DataSync為可讀且近乎即時的指標。這些統計資料會保留 15 個月。
根據預設,DataSync指標資料每隔 5 分鐘會自動CloudWatch在 5 分鐘內傳送至。如需詳細資訊,請參閱什麼是 AmazonCloudWatch? 在亞馬遜CloudWatch用戶指南。
亞馬遜CloudWatch指標DataSync
AmazonCloudWatch 提供指標,您可以使用這些指標取得DataSync效能相關資訊和疑難排解問題。您可以使用下列工具查看的CloudWatch量度:DataSync
-
CloudWatch 主控台
-
CloudWatch CLI
-
CloudWatch API
-
DataSync主控台 (工作執行頁面)
如需詳細資訊,請參閱 Amazon 使用者指南中的使CloudWatch用 Amazon 指CloudWatch標。
DataSync 指標使用 AWS/DataSync
命名空間,並提供下列維度的指標:
-
AgentId— 代理程式的唯一 ID。
-
TaskId— 任務的唯一 ID。其格式為
task-01234567890abcdef
。
AWS/DataSync
命名空間包含下列指標。
指標 | 描述 |
---|---|
|
套用壓縮之後透過網路傳輸的實體位元組數。在大多數情況下,除非數據不可壓縮, 單位:位元組 |
|
已在目的地位置完成準備的位元組總數量。 單位:位元組 |
|
已在來源位置完成準備的位元組總數量。 單位:位元組 |
|
傳送中的位元元元元總數。如需關於自動化狀態,請參閱 單位:位元組 |
|
已在目的地位置驗證過的位元組總數量。 單位:位元組 |
|
已在來源位置驗證過的位元組總數量。 單位:位元組 |
|
已傳輸到目的地位置的所有檔案的總邏輯大小。 單位:位元組 |
|
已在目的地位置完成準備的檔案總數量。 單位:計數 |
|
已在來源位置完成準備的檔案總數量。 單位:計數 |
|
透過網路傳輸的檔案或中繼資料實際數量。在 如果傳輸過程發生失敗,此值可能會小於 單位:計數 |
|
已在目的地位置驗證過的檔案總數量。 單位:計數 |
|
已在來源位置驗證過的檔案總數量。 單位:計數 |
亞馬遜EventBridge活動DataSync
亞馬遜EventBridge事件描述了DataSync資源的變化。您可以設定規則來比對這些事件,並將這些事件路由到一或多個目標函數或串流。盡可能發出事件。
DataSync傳輸事件
以下EventBridge事件可用於DataSync轉移。
Agent state changes | |
---|---|
事件 | 描述 |
Online | The agent is configured properly and is available to use. This status is the normal running status for an agent. |
Offline | The agent's VM is turned off or the agent is in an unhealthy state and has been out of contact with the service for 5 minutes or longer. When the issue that caused the unhealthy state is resolved, the agent returns to ONLINE status. |
Location state changes | |
事件 | 描述 |
Adding | DataSync is adding a location. |
Available | The location is created and is available to use. |
Task state changes | |
事件 | 描述 |
Available | The task was created and is ready to start. |
Running | The task is in progress and functioning properly. |
Unavailable | The task isn't configured properly and can't be used. You may see this when an agent associated with the task goes offline. |
Queued | Another task is running and using the same agent. DataSync runs tasks in series (first in, first out). |
Task execution state changes | |
事件 | 描述 |
Queueing | DataSync is waiting for another task that's using the same agent to finish. |
Launching | DataSync is initializing the task execution. |
Preparing | DataSync is determining which files need to be transferred. |
Transferring | DataSync is performing the actual transfer of your data. |
Verifying | DataSync performs a full data and metadata integrity verification to ensure that the data in your destination is an exact copy of your source. |
Success | The transfer is successful. |
Error | The transfer failed. |
DataSync探索事件
下列EventBridge事件可用於DataSync探索。
Storage system state changes | |
---|---|
事件 | 描述 |
Storage System Connectivity Status Change | The connection between your DataSync agent and on-premises storage system changed. For details, see your CloudWatch logs. |
Discovery job state changes | |
事件 | 描述 |
Discovery Job State Change | The status of your discovery job changed. For more information, see 探索工作. |
Discovery Job Expiration Soon | Your discovery job expires soon. This includes any information the discovery job collected about your on-premises storage system. Before the job expires, you can export collected data by using the DescribeStorageSystemResources and DescribeStorageSystemResourceMetrics operations. |
允許DataSync將記錄檔上傳至記CloudWatch錄群組
DataSync需要足夠的權限才能將記錄檔傳送到您的記CloudWatch錄群組。當您使用主控台建立工作時,DataSync可以使用正確的許可自動建立 IAM 資源政策。
下列範例是授與這些權限的資源策略。
{ "Statement": [ { "Sid": "DataSyncLogsToCloudWatchLogs", "Effect": "Allow", "Action": [ "logs:PutLogEvents", "logs:CreateLogStream" ], "Principal": { "Service": "datasync.amazonaws.com" }, "Condition": { "ArnLike": { "aws:SourceArn": [ "arn:aws:datasync:
region
:account-id
:task/*" ] }, "StringEquals": { "aws:SourceAccount": "account-id
" } }, "Resource": "arn:aws:logs:region
:account-id
:log-group:*:*" } ], "Version": "2012-10-17" }
此原則會使用條件陳述式來確保只有來自指定帳戶的DataSync工作才能存取指定的CloudWatch記錄群組。我們建議在這些條件陳述式中使用aws:SourceArn
和aws:SourceAccount
全域條件內容索引鍵,以防止混淆的副問題。如需詳細資訊,請參閱預防跨服務混淆代理人。
若要指定一或多個工作,請
以工作所在位AWS 區域置的DataSync [Region] 程式碼取代,並取region
代為包含工作之帳戶的AWS 帳戶 ID。若要指定CloudWatch記錄群組,請取代相同的值。您也可以修改account-id
Resource
陳述式以特定的記錄群組為目標。如需使用SourceArn
和的詳細資訊SourceAccount
,請參閱 IAM 使用者指南中的全域條件金鑰。
若要套用政策,請將此政策陳述式儲存至本機電腦上的檔案。然後執行下列AWS CLI命令以套用資源策略:
aws logs put-resource-policy --policy-name trustDataSync --policy-document file://
full-path-to-policy-file
注意
使用相同的命令運行此命令,AWS 帳戶並且您AWS 區域是否激活了DataSync代理。
如需詳細資訊,請參閱《AmazonCloudWatch Logs 使用者指南》中的使用日誌群組和日誌串流。
從命令列監控您的DataSync工作
您可以使用AWS Command Line Interface或標準 Unixwatch
公用程式來追蹤您的DataSync任務。
使用監視您的工作AWS CLI
若要使用 CLI 監視DataSync工作的狀態,請使用describe-task-execution
指令。
aws datasync describe-task-execution \ --task-execution-arn 'arn:aws:datasync:
region
:account-id
:task/task-id
/execution/task-execution-id
'
此命令會傳回類似如下的任務執行資訊。
{ "BytesCompressed": 0, "BytesTransferred": 0, "BytesWritten": 0, "EstimatedFilesToTransfer": 0, "EstimatedBytesToTransfer": 0, "FilesTransferred": 0, "Options": { "VerifyMode": "POINT_IN_TIME_CONSISTENT", "Atime": "BEST_EFFORT", "Mtime": "PRESERVE", "Uid": "INT_VALUE", "Gid": "INT_VALUE", "PreserveDevices": "NONE", "PosixPermissions": "PRESERVE", "PreserveDeletedFiles": "PRESERVE", "OverwriteMode": "NEVER", "TaskQueueing": "ENABLED" }, "Result": { "PrepareDuration": 4355, "PrepareStatus": "Ok", "TransferDuration": 5889, "TransferStatus": "Ok", "VerifyDuration": 4538, "VerifyStatus": "Pending" }, "StartTime": 1532658526.949, "Status": "VERIFYING", "TaskExecutionArn": "arn:aws:datasync:us-east-1:112233445566:task/task-08de6e6697796f026/execution/exec-04ce9d516d69bd52f" }
如果任務執行成功,則 Status (狀態) 的值會變成 SUCCESS (成功)。如果 describe-task-execution
命令失敗,結果所傳送的錯誤代碼可協助您對問題進行故障診斷。如需有關錯誤碼的資訊,請參閱 DataSyncAPI 參考資料TaskExecutionResultDetail中的。
使用watch
公用程式監視您的工作
要從命令行實時監視任務的進度,您可以使用標準的 Unix 實用watch
程序。任務執行持續時間值以毫秒為單位測量。
watch
公用程式無法辨識DataSync別名。下列範例說明如何直接呼叫 CLI。
# pass '-n 1' to update every second and '-d' to highlight differences $ watch -n 1 -d \ "aws datasync describe-task-execution --task-execution-arn 'arn:aws:datasync:
region
:account-id
:task/task-id
/execution/taskexecution-id
'"