将 S3 Storage Lens 组附加到控制面板或从控制面板移除 - Amazon Simple Storage Service
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

将 S3 Storage Lens 组附加到控制面板或从控制面板移除

在 Amazon S3 Storage Lens 存储统计管理工具中升级到高级级别后,您可以将 Storage Lens 组附加到控制面板。如果您有多个 Storage Lens 组,则可以根据需要包括或排除组。

您的 Storage Lens 组必须位于控制面板账户中指定的主区域内。将 Storage Lens 组附加到控制面板后,您将在 48 小时内在指标导出中收到新增的 Storage Lens 组聚合数据。

注意

如果要查看 Storage Lens 组的聚合指标,则必须将其附加到 Storage Lens 控制面板。有关 Storage Lens 组 JSON 配置文件的示例,请参阅 JSON 格式的 S3 Storage Lens 存储统计管理工具示例配置(带 Storage Lens 组)

将 Storage Lens 组附加到 Storage Lens 控制面板
  1. 登录到Amazon Web Services Management Console,然后通过以下网址打开 Amazon S3 控制台:https://console.aws.amazon.com/s3/

  2. 在左侧导航窗格中,在 Storage Lens 下选择控制面板

  3. 选择要将 Storage Lens 组附加到的 Storage Lens 控制面板的选项按钮。

  4. 选择编辑

  5. Metrics selection(指标选择)下方,请选择 Advanced metrics and recommendations(高级指标和建议)。

  6. 选择 Storage Lens 组聚合

    注意

    默认情况下,还会选中高级指标。但是,您也可以取消选中此设置,因为聚合 Storage Lens 组数据并非必须。

  7. 向下滚动到 Storage Lens 组聚合,然后指定要在数据聚合中包括或排除的一个或多个 Storage Lens 组。您可以使用以下筛选条件选项:

    • 如果要包括某些 Storage Lens 组,请选择包括 Storage Lens 组。在要包括的 Storage Lens 组下,选择您的 Storage Lens 组。

    • 如果要包括所有 Storage Lens 组,请选择包括此账户中主区域中的所有 Storage Lens 组

    • 如果要排除某些 Storage Lens 组,请选择排除 Storage Lens 组。在要排除的 Storage Lens 组下,选择要排除的 Storage Lens 组。

  8. 选择 Save changes(保存更改)。如果您正确配置了 Storage Lens 组,则将在 48 小时内在控制面板中看到新增的 Storage Lens 组聚合数据。

从 S3 Storage Lens 存储统计管理工具控制面板移除 Storage Lens 组
  1. 登录到Amazon Web Services Management Console,然后通过以下网址打开 Amazon S3 控制台:https://console.aws.amazon.com/s3/

  2. 在左侧导航窗格中,在 Storage Lens 下选择控制面板

  3. 选择要从中移除 Storage Lens 组的 Storage Lens 控制面板的选项按钮。

  4. 选择查看控制面板配置

  5. 选择编辑

  6. 向下滚动到指标选择部分。

  7. Storage Lens 组聚合下,选择要移除的 Storage Lens 组旁的 X。这将移除 Storage Lens 组。

    如果您在控制面板中包括了所有 Storage Lens 组,请清除包括此账户中主区域中的所有 Storage Lens 组旁的复选框。

  8. 选择 Save changes(保存更改)

    注意

    最多需要等待 48 小时,控制面板才会反映配置更新。

例 – 将所有 Storage Lens 组附加到控制面板

以下 Java 版 SDK 示例将账户 111122223333 中的所有 Storage Lens 组附加到 DashBoardConfigurationId 控制面板:

package aws.example.s3control; import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import com.amazonaws.services.s3control.AWSS3Control; import com.amazonaws.services.s3control.AWSS3ControlClient; import com.amazonaws.services.s3control.model.BucketLevel; import com.amazonaws.services.s3control.model.PutStorageLensConfigurationRequest; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import com.amazonaws.services.s3control.model.AccountLevel; import com.amazonaws.services.s3control.model.StorageLensConfiguration; import com.amazonaws.services.s3control.model.StorageLensGroupLevel; import static com.amazonaws.regions.Regions.US_WEST_2; public class CreateDashboardWithStorageLensGroups { public static void main(String[] args) { String configurationId = "ExampleDashboardConfigurationId"; String sourceAccountId = "111122223333"; try { StorageLensGroupLevel storageLensGroupLevel = new StorageLensGroupLevel(); AccountLevel accountLevel = new AccountLevel() .withBucketLevel(new BucketLevel()) .withStorageLensGroupLevel(storageLensGroupLevel); StorageLensConfiguration configuration = new StorageLensConfiguration() .withId(configurationId) .withAccountLevel(accountLevel) .withIsEnabled(true); AWSS3Control s3ControlClient = AWSS3ControlClient.builder() .withCredentials(new ProfileCredentialsProvider()) .withRegion(US_WEST_2) .build(); s3ControlClient.putStorageLensConfiguration(new PutStorageLensConfigurationRequest() .withAccountId(sourceAccountId) .withConfigId(configurationId) .withStorageLensConfiguration(configuration) ); } 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(); } } }
例 – 将两个 Storage Lens 组附加到控制面板

以下 Amazon SDK for Java 示例将两个 Storage Lens 组(StorageLensGroupName1StorageLensGroupName2)附加到 ExampleDashboardConfigurationId 控制面板。

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.BucketLevel; import com.amazonaws.services.s3control.model.PutStorageLensConfigurationRequest; import com.amazonaws.services.s3control.model.StorageLensConfiguration; import com.amazonaws.services.s3control.model.StorageLensGroupLevel; import com.amazonaws.services.s3control.model.StorageLensGroupLevelSelectionCriteria; import static com.amazonaws.regions.Regions.US_WEST_2; public class CreateDashboardWith2StorageLensGroups { public static void main(String[] args) { String configurationId = "ExampleDashboardConfigurationId"; String storageLensGroupName1 = "StorageLensGroupName1"; String storageLensGroupName2 = "StorageLensGroupName2"; String sourceAccountId = "111122223333"; try { StorageLensGroupLevelSelectionCriteria selectionCriteria = new StorageLensGroupLevelSelectionCriteria() .withInclude( "arn:aws:s3:" + US_WEST_2.getName() + ":" + sourceAccountId + ":storage-lens-group/" + storageLensGroupName1, "arn:aws:s3:" + US_WEST_2.getName() + ":" + sourceAccountId + ":storage-lens-group/" + storageLensGroupName2); System.out.println(selectionCriteria); StorageLensGroupLevel storageLensGroupLevel = new StorageLensGroupLevel() .withSelectionCriteria(selectionCriteria); AccountLevel accountLevel = new AccountLevel() .withBucketLevel(new BucketLevel()) .withStorageLensGroupLevel(storageLensGroupLevel); StorageLensConfiguration configuration = new StorageLensConfiguration() .withId(configurationId) .withAccountLevel(accountLevel) .withIsEnabled(true); AWSS3Control s3ControlClient = AWSS3ControlClient.builder() .withCredentials(new ProfileCredentialsProvider()) .withRegion(US_WEST_2) .build(); s3ControlClient.putStorageLensConfiguration(new PutStorageLensConfigurationRequest() .withAccountId(sourceAccountId) .withConfigId(configurationId) .withStorageLensConfiguration(configuration) ); } 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(); } } }
例 – 附加除排除项之外的所有 Storage Lens 组

以下 Java 版 SDK 示例将所有 Storage Lens 组附加到 ExampleDashboardConfigurationId 控制面板,但不包括指定的两个组(StorageLensGroupName1StorageLensGroupName2):

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.BucketLevel; import com.amazonaws.services.s3control.model.PutStorageLensConfigurationRequest; import com.amazonaws.services.s3control.model.StorageLensConfiguration; import com.amazonaws.services.s3control.model.StorageLensGroupLevel; import com.amazonaws.services.s3control.model.StorageLensGroupLevelSelectionCriteria; import static com.amazonaws.regions.Regions.US_WEST_2; public class CreateDashboardWith2StorageLensGroupsExcluded { public static void main(String[] args) { String configurationId = "ExampleDashboardConfigurationId"; String storageLensGroupName1 = "StorageLensGroupName1"; String storageLensGroupName2 = "StorageLensGroupName2"; String sourceAccountId = "111122223333"; try { StorageLensGroupLevelSelectionCriteria selectionCriteria = new StorageLensGroupLevelSelectionCriteria() .withInclude( "arn:aws:s3:" + US_WEST_2.getName() + ":" + sourceAccountId + ":storage-lens-group/" + storageLensGroupName1, "arn:aws:s3:" + US_WEST_2.getName() + ":" + sourceAccountId + ":storage-lens-group/" + storageLensGroupName2); System.out.println(selectionCriteria); StorageLensGroupLevel storageLensGroupLevel = new StorageLensGroupLevel() .withSelectionCriteria(selectionCriteria); AccountLevel accountLevel = new AccountLevel() .withBucketLevel(new BucketLevel()) .withStorageLensGroupLevel(storageLensGroupLevel); StorageLensConfiguration configuration = new StorageLensConfiguration() .withId(configurationId) .withAccountLevel(accountLevel) .withIsEnabled(true); AWSS3Control s3ControlClient = AWSS3ControlClient.builder() .withCredentials(new ProfileCredentialsProvider()) .withRegion(US_WEST_2) .build(); s3ControlClient.putStorageLensConfiguration(new PutStorageLensConfigurationRequest() .withAccountId(sourceAccountId) .withConfigId(configurationId) .withStorageLensConfiguration(configuration) ); } 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(); } } }