本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
建立 Amazon S3 Storage Lens 儀表板
您可以建立其他 S3 Storage Lens 自訂儀表板,這些儀表板可以範圍限定在帳戶中的組織 AWS Organizations 或特定 AWS 區域 或 儲存貯體。
注意
對儀表板組態的任何更新最多可能需要 48 小時才能正確顯示或視覺化。
使用下列步驟在 Amazon S3 主控台上建立 Amazon S3 Storage Lens 儀表板。
步驟 1:定義儀表板範圍
登入 AWS Management Console ,並在 https://console.aws.amazon.com/s3/
:// 開啟 Amazon S3 主控台。 -
在頁面頂端的導覽列中,選擇目前顯示的 AWS 區域名稱。接下來,選擇您想要切換到的區域。
-
在左導覽窗格的 S3 Storage Lens 下,選擇儀表板。
-
選擇 Create dashboard (建立儀表板)。
-
在 Dashboard (儀表板) 頁面的 General (一般) 區段中,執行以下動作:
-
檢視儀表板的主要區域。主要區域是存放此 Storage Lens 儀表板 AWS 區域 組態和指標的 。
-
輸入儀表板名稱。
儀表板名稱必須少於 65 個字元,且不得包含特殊字元或空格。
注意
建立儀表板後,您就無法變更此儀表板名稱。
-
您可以選擇將 Tags (標籤) 新增至儀表板。您可以使用標籤來管理儀表板的權限,並追蹤 S3 Storage Lens 的成本。
如需詳細資訊,請參閱《IAM 使用者指南》中的使用資源標籤控制存取權,以及《AWS Billing 使用者指南》中的 AWS產生的成本分配標籤。
注意
您最多可為儀表板組態中新增 50 個標籤。
-
-
在 Dashboard scope (儀表板範圍) 區段中,執行以下動作:
-
選擇您希望 S3 Storage Lens 在儀表板中包含或排除的區域和儲存貯體。
-
選擇您希望 S3 Storage Lens 包含或排除的選取區域儲存貯體。您可以包含或排除儲存貯體,但不能同時包含和排除。在您建立組織層級儀表板時,無法使用此選項。
注意
-
您可以包含或排除區域和儲存貯體。在組織中跨成員帳戶建立組織層級儀表板時,此選項會僅限於「區域」。
-
您最多可以選擇 50 個要包含或排除的儲存貯體。
-
步驟 2:設定指標選擇
-
在 Metrics selection (指標選取) 區段中,選取您要為此儀表板彙總的指標類型。
-
若要包含儲存貯體層級彙總的免費指標,且其可供查詢使用 14 天,請選擇 Free Metrics (免費指標)。
-
若要啟用進階指標和其他進階選項,請選擇 Advanced metrics and recommendations (進階指標和建議)。這些選項包括進階字首彙總、Amazon CloudWatch 發佈和內容相關建議。資料有 15 個月的時間可用於查詢。進階指標和建議會有額外的費用。如需詳細資訊,請參閱 Amazon S3 定價
。 如需進階指標和免費指標的詳細資訊,請參閱 指標選擇。
-
-
在 Advanced metrics and recommendations features (進階指標和建議功能) 下,選取您想要啟用的選項:
-
Advanced metrics (進階指標)
-
CloudWatch 發佈
-
字首彙總
重要
如果為您的 S3 Storage Lens 組態啟用字首彙總,則字首層級指標將不會發佈至 CloudWatch。僅儲存貯體、帳戶和組織層級 S3 Storage Lens 指標發佈至 CloudWatch。
-
-
如果您已啟用 Advanced metrics (進階指標),請選取要在 S3 Storage Lens 儀表板中顯示的 Advanced metrics categories (進階指標類別):
-
活動指標
-
Detailed status code metrics (詳細的狀態碼指標)
-
Advanced cost optimization metrics (進階成本最佳化指標)
-
Advanced data protection metrics (進階資料保護指標)
如需指標類別的詳細資訊,請參閱 指標類別。如需指標的完整清單,請參閱Amazon S3 Storage Lens 指標詞彙表。
-
-
如果您選擇啟用字首彙總,請設定下列項目:
-
請為此儀表板選擇最小字首閥值大小。
例如,字首閾值 5% 表示組成儲存貯體總儲存體大小 5% 或更大的字首將會彙總。
-
選擇字首深度。
此設定表示可評估字首的最多層級數目。字首深度必須小於 10。
-
輸入字首分隔符號字元。
此值用來識別每個字首層級。Amazon S3 中的預設值是
/
字元,但您的儲存結構可能會使用其他分隔符號字元。
-
(選用) 步驟 3:儀表板的匯出指標
-
在 Metrics export (指標匯出) 區段中,若要建立每日將放置在您選擇的目的地儲存貯體中的指標匯出,請選擇 Enable (啟用)。
指標匯出採用 CSV 或 Apache Parquet 格式。它代表與 S3 Storage Lens 儀表板資料相同的資料範圍,而不提供建議。
-
如果您已啟用指標匯出,請選擇每日指標匯出的輸出格式:CSV 或 Apache Parquet。
Parquet 是 Hadoop 的開放原始碼檔案格式,以平面直欄式格式儲存巢狀資料。
-
選擇指標匯出的目的地 S3 儲存貯體。
您可以在 S3 Storage Lens 儀表板的目前帳戶中選擇一個儲存貯體。或者, AWS 帳戶 如果您有目的地儲存貯體許可和目的地儲存貯體擁有者的帳戶 ID,您可以選擇另一個儲存貯體。
-
選擇目的地 S3 儲存貯體 (格式:
s3://
)。bucket-name
/prefix
儲存貯體必須位於 S3 Storage Lens 儀表板的主要區域中。S3 主控台會顯示將由 Amazon S3 新增至目的地儲存貯體政策的 Destination bucket permission (目的地儲存貯體許可)。Amazon S3 會更新目的地儲存貯體上的儲存貯體政策,以允許 S3 將資料置於該儲存貯體中。
-
(選用) 若要啟用伺服器端加密進行指標匯出,請選擇 Specify an encryption key (指定加密金鑰)。然後,選擇加密類型:Amazon S3 受管金鑰 (SSE-S3) 或 AWS Key Management Service 金鑰 (SSE-KMS)。
您可以在 Amazon S3 受管金鑰 (SSE-S3) 和 AWS Key Management Service (AWS KMS) 金鑰 (SSE-KMS) 之間進行選擇。
-
(選用) 若要指定 AWS KMS 金鑰,您必須選擇 KMS 金鑰或輸入金鑰 Amazon Resource Name (ARN)。
如果您選擇客戶受管金鑰,您必須授予 S3 Storage Lens 許可,才能在 AWS KMS 金鑰政策中加密。如需詳細資訊,請參閱使用 AWS KMS key 加密指標匯出。
-
選擇 Create dashboard (建立儀表板)。
下列範例命令會建立包含標籤的 Amazon S3 Storage Lens 組態。若要使用這些範例,請以您自己的資訊取代
。user input placeholders
aws s3control put-storage-lens-configuration --account-id=
111122223333
--config-id=example-dashboard-configuration-id
--region=us-east-1
--storage-lens-configuration=file://./config.json
--tags=file://./tags.json
下列範例命令會建立不含標籤的 Amazon S3 Storage Lens 組態。若要使用這些範例,請以您自己的資訊取代
。user input placeholders
aws s3control put-storage-lens-configuration --account-id=
222222222222
--config-id=your-configuration-id
--region=us-east-1
--storage-lens-configuration=file://./config.json
範例 – 建立和更新 Amazon S3 Storage Lens 組態
下列範例會在適用於 Java 的 SDK 中建立和更新 Amazon S3 Storage Lens 組態:
package aws.example.s3control; import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import com.amazonaws.services.s3control.AWSS3Control; import com.amazonaws.services.s3control.AWSS3ControlClient; import com.amazonaws.services.s3control.model.AccountLevel; import com.amazonaws.services.s3control.model.ActivityMetrics; import com.amazonaws.services.s3control.model.BucketLevel; import com.amazonaws.services.s3control.model.CloudWatchMetrics; import com.amazonaws.services.s3control.model.Format; import com.amazonaws.services.s3control.model.Include; import com.amazonaws.services.s3control.model.OutputSchemaVersion; import com.amazonaws.services.s3control.model.PrefixLevel; import com.amazonaws.services.s3control.model.PrefixLevelStorageMetrics; import com.amazonaws.services.s3control.model.PutStorageLensConfigurationRequest; import com.amazonaws.services.s3control.model.S3BucketDestination; import com.amazonaws.services.s3control.model.SSES3; import com.amazonaws.services.s3control.model.SelectionCriteria; import com.amazonaws.services.s3control.model.StorageLensAwsOrg; import com.amazonaws.services.s3control.model.StorageLensConfiguration; import com.amazonaws.services.s3control.model.StorageLensDataExport; import com.amazonaws.services.s3control.model.StorageLensDataExportEncryption; import com.amazonaws.services.s3control.model.StorageLensTag; import java.util.Arrays; import java.util.List; import static com.amazonaws.regions.Regions.
US_WEST_2
; public class CreateAndUpdateDashboard { public static void main(String[] args) { String configurationId = "ConfigurationId
"; String sourceAccountId = "111122223333
"; String exportAccountId = "Destination Account ID
"; String exportBucketArn = "arn:aws:s3:::destBucketName
"; // The destination bucket for your metrics export must be in the same Region as your S3 Storage Lens configuration. String awsOrgARN = "arn:aws:organizations::123456789012
:organization/o-abcdefgh
"; Format exportFormat = Format.CSV; try { SelectionCriteria selectionCriteria = new SelectionCriteria() .withDelimiter("/
") .withMaxDepth(5
) .withMinStorageBytesPercentage(10.0
); PrefixLevelStorageMetrics prefixStorageMetrics = new PrefixLevelStorageMetrics() .withIsEnabled(true
) .withSelectionCriteria(selectionCriteria); BucketLevel bucketLevel = new BucketLevel() .withActivityMetrics(new ActivityMetrics().withIsEnabled(true
)) .withAdvancedCostOptimizationMetrics(new AdvancedCostOptimizationMetrics().withIsEnabled(true
)) .withAdvancedDataProtectionMetrics(new AdvancedDataProtectionMetrics().withIsEnabled(true
)) .withDetailedStatusCodesMetrics(new DetailedStatusCodesMetrics().withIsEnabled(true
)) .withPrefixLevel(new PrefixLevel().withStorageMetrics(prefixStorageMetrics)); AccountLevel accountLevel = new AccountLevel() .withActivityMetrics(new ActivityMetrics().withIsEnabled(true
)) .withAdvancedCostOptimizationMetrics(new AdvancedCostOptimizationMetrics().withIsEnabled(true
)) .withAdvancedDataProtectionMetrics(new AdvancedDataProtectionMetrics().withIsEnabled(true
)) .withDetailedStatusCodesMetrics(new DetailedStatusCodesMetrics().withIsEnabled(true
)) .withBucketLevel(bucketLevel); Include include = new Include() .withBuckets(Arrays.asList("arn:aws:s3:::bucketName
")) .withRegions(Arrays.asList("us-west-2
")); StorageLensDataExportEncryption exportEncryption = new StorageLensDataExportEncryption() .withSSES3(new SSES3()); S3BucketDestination s3BucketDestination = new S3BucketDestination() .withAccountId(exportAccountId) .withArn(exportBucketArn) .withEncryption(exportEncryption) .withFormat(exportFormat) .withOutputSchemaVersion(OutputSchemaVersion.V_1) .withPrefix("Prefix"); CloudWatchMetrics cloudWatchMetrics = new CloudWatchMetrics() .withIsEnabled(true
); StorageLensDataExport dataExport = new StorageLensDataExport() .withCloudWatchMetrics(cloudWatchMetrics) .withS3BucketDestination(s3BucketDestination); StorageLensAwsOrg awsOrg = new StorageLensAwsOrg() .withArn(awsOrgARN
); StorageLensConfiguration configuration = new StorageLensConfiguration() .withId(configurationId) .withAccountLevel(accountLevel) .withInclude(include) .withDataExport(dataExport) .withAwsOrg(awsOrg) .withIsEnabled(true
); List<StorageLensTag> tags = Arrays.asList( new StorageLensTag().withKey("key-1
").withValue("value-1
"), new StorageLensTag().withKey("key-2
").withValue("value-2
") ); AWSS3Control s3ControlClient = AWSS3ControlClient.builder() .withCredentials(new ProfileCredentialsProvider()) .withRegion(US_WEST_2
) .build(); s3ControlClient.putStorageLensConfiguration(new PutStorageLensConfigurationRequest() .withAccountId(sourceAccountId) .withConfigId(configurationId) .withStorageLensConfiguration(configuration) .withTags(tags) ); } catch (AmazonServiceException e) { // The call was transmitted successfully, but Amazon S3 couldn't process // it and returned an error response. e.printStackTrace(); } catch (SdkClientException e) { // Amazon S3 couldn't be contacted for a response, or the client // couldn't parse the response from Amazon S3. e.printStackTrace(); } } }
若要進一步了解您的儲存,您可以建立一或多個 S3 Storage Lens 群組,並將其連接至儀表板。S3 Storage Lens 群組是根據字首、尾碼、物件標籤、物件大小、物件存留期為物件定義的自訂篩選條件,或這些篩選條件的組合。
您可以使用 S3 Storage Lens 群組取得對大型共用儲存貯體 (例如資料湖) 的精細可見度,以做出更明智的商業決策。例如,您可以將儲存用量劃分為個別專案的特定物件群組以及單一或多個儲存貯體內的成本中心,以簡化儲存配置並最佳化成本報告。
若要使用 S3 Storage Lens 群組,您必須升級儀表板以使用進階指標和建議。如需關於 S3 Storage Lens 群組的詳細資訊,請參閱 使用 S3 Storage Lens 群組來篩選和彙總指標。