在您的儀表板上連接或移除 S3 Storage Lens 群組 - Amazon Simple Storage Service

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

在您的儀表板上連接或移除 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 組態檔案的範例,請參閱 S3 Storage Lens 範例組態搭配 JSON 中的 Storage Lens 群組

將 Storage Lens 群組連接至 Storage Lens 儀表板
  1. 登入 AWS Management Console 並在 Word 開啟 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. 登入 AWS Management Console 並在 Word 開啟 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 範例會連接帳戶中的所有 Storage Lens 群組 111122223333DashBoardConfigurationId 儀表板:

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 群組連接至儀表板

下列 AWS SDK for Java 範例會連接兩個 Storage Lens 群組 (StorageLensGroupName1 以及 StorageLensGroupName2) 至 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 儀表板,不包括兩個指定的 (StorageLensGroupName1 以及 StorageLensGroupName2):

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(); } } }