

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

# 將 S3 Storage Lens 指標匯出至 S3 資料表
<a name="storage-lens-s3-tables-export"></a>

您可以設定 Amazon S3 Storage Lens 將儲存分析和洞見匯出至 S3 Tables。當您啟用 S3 Tables 匯出時，您的指標會自動儲存在 AWS受管資料表儲存貯體中的唯讀 Apache Iceberg `aws-s3`資料表中，使其可使用 SQL 搭配 Amazon Athena、Amazon Redshift 和 Amazon EMR 等 AWS 分析服務來查詢。

**注意**  
將 S3 Storage Lens 指標匯出至 AWS受管 S3 資料表無需額外費用。資料表儲存、資料表管理和資料表上的請求需支付標準費用。如需詳細資訊，請參閱 [Simple Storage Service (Amazon S3) 定價](https://aws.amazon.com/s3/pricing)。

## 使用主控台啟用 S3 Tables 匯出
<a name="storage-lens-s3-tables-export-console"></a>

1. 登入 AWS 管理主控台，並在 https：//[https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/) 開啟 Amazon S3 主控台。

1. 在左側導覽窗格中，選擇 **Storage Lens**，然後選擇 **Storage Lens Dashboards**。

1. 在 **Storage Lens 儀表板**清單中，選擇您要編輯的儀表板。

1. 選擇**編輯**。

1. 在**儀表板**頁面上，導覽至**指標匯出和發佈**區段。

1. 若要啟用**預設指標報告的**資料表匯出，請在儲存貯體類型中選取**資料表儲存貯**體。

1. 若要啟用**擴展字首指標報告的**資料表匯出，請在儲存貯體類型中選取**資料表儲存貯**體。

1. 檢閱儀表板組態，然後按一下**提交**。

**注意**  
啟用 S3 Tables 匯出後，資料表中最多可能需要 48 小時才能使用第一個資料。

**注意**  
將 S3 Storage Lens 指標匯出至 AWS受管 S3 資料表無需額外費用。標準費用適用於資料表儲存、資料表管理、資料表上的請求和監控。您可以使用 Amazon S3 主控台、Amazon S3 API AWS CLI、 或 AWS SDKs，啟用或停用匯出至 Amazon S3 資料表。 Amazon S3 

**注意**  
根據預設，S3 資料表中的記錄不會過期。為了協助將資料表的儲存成本降至最低，您可以啟用和設定資料表的記錄過期時間。使用此選項時，Amazon S3 會在記錄過期時自動從資料表中移除記錄。請參閱：[記錄資料表的過期時間。](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-record-expiration.html)

## 使用 啟用 S3 Tables 匯出 AWS CLI
<a name="storage-lens-s3-tables-export-cli"></a>

**注意**  
在執行下列命令之前，請確定您擁有最新的 CLI 版本。請參閱[安裝或更新至最新版本的 AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)。

下列範例使用 啟用 S3 Storage Lens 組態「預設指標報告」的 S3 Tables 匯出 AWS CLI。若要使用此範例，請以您自己的資訊取代*使用者輸入預留位置*。

```
aws s3control put-storage-lens-configuration --account-id=555555555555 --config-id=your-configuration-id --storage-lens-configuration '{
   "Id":"your-configuration-id",
   "AccountLevel":{
      "ActivityMetrics":{
        "IsEnabled":true
      },
      "BucketLevel":{
         "ActivityMetrics":{
            "IsEnabled":true
         }
      }
   },
   "DataExport":{
      "S3BucketDestination":{
         "OutputSchemaVersion":"V_1",
         "Format":"CSV",
         "AccountId":"555555555555",
         "Arn":"arn:aws:s3:::my-export-bucket",
         "Prefix":"storage-lens-exports/"
      },
      "StorageLensTableDestination":{
         "IsEnabled":true
      }
   },
   "IsEnabled":true
}'
```

## 使用 AWS SDKs 啟用 S3 資料表匯出
<a name="storage-lens-s3-tables-export-sdk"></a>

下列範例使用適用於 Python 的 AWS SDK (BotoS3) 啟用 S3 Storage Lens 組態「預設指標報告」的 S3 Tables 匯出。若要使用此範例，請以您自己的資訊取代*使用者輸入預留位置*。

```
import boto3

s3control = boto3.client('s3control')

response = s3control.put_storage_lens_configuration( AccountId='555555555555', ConfigId='your-configuration-id', StorageLensConfiguration={
        'Id': 'your-configuration-id',
        'AccountLevel': {
            'ActivityMetrics': {
              'IsEnabled': True
            },
            'BucketLevel': {
                'ActivityMetrics': {
                    'IsEnabled': True
                }
            }
        },
        'DataExport': {
            'S3BucketDestination': {
                'OutputSchemaVersion': 'V_1',
                'Format': 'CSV',
                'AccountId': '555555555555',
                'Arn': 'arn:aws:s3:::my-export-bucket',
                'Prefix': 'storage-lens-exports/'
            },
            'StorageLensTableDestination': {
                'IsEnabled': True
            }
        },
        'IsEnabled': True
    }
)
```

如需使用 AWS SDKs的詳細資訊，請參閱 [AWS SDKs和工具](https://aws.amazon.com/developer/tools/)。

## 後續步驟
<a name="storage-lens-s3-tables-export-next-steps"></a>

啟用 S3 Tables 匯出後，您可以：
+ 了解 [S3 Storage Lens 匯出至 S3 Tables 的資料表命名](storage-lens-s3-tables-naming.md) 
+ 了解 [了解 S3 Storage Lens 資料表結構描述](storage-lens-s3-tables-schemas.md) 