

# S3 Storage Lens グループをダッシュボードにアタッチまたは削除する、またはダッシュボードから S3 Storage Lens グループを削除する
<a name="storage-lens-groups-dashboard-console"></a>

Amazon S3 ストレージレンズの高度なティアにアップグレードしたら、[Storage Lens グループ](https://docs.aws.amazon.com/AmazonS3/latest/userguide/storage-lens-groups-overview.html)をダッシュボードにアタッチできます。複数の Storage Lens グループがある場合、目的のグループを含めたり除外したりできます。

Storage Lens グループは、ダッシュボードアカウントの指定されたホームリージョン内に存在している必要があります。Storage Lens グループをダッシュボードに接続すると、48 時間以内にメトリクスのエクスポートで追加の Storage Lens グループの集約データを受け取ります。

**注記**  
Storage Lens グループの集約メトリクスを表示するには、そのデータを Storage Lens ダッシュボードにアタッチする必要があります。Storage Lens グループの JSON 設定ファイルの例については、「[JSON の Storage Lens グループを使用した S3 Storage Lens の設定例](S3LensHelperFilesCLI.md#StorageLensGroupsHelperFilesCLI)」を参照してください。

## S3 コンソールの使用
<a name="storage-lens-groups-attach-dashboard-console"></a>

**Storage Lens グループを Storage Lens ダッシュボードにアタッチするには**

1. AWS マネジメントコンソール にサインインし、Amazon S3 コンソール [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/) を開きます。

1. 左ナビゲーションペインの、**[S3 Storage Lens ]** で、**[ダッシュボード]** を選択します。

1. Storage Lens グループをアタッチする Storage Lens ダッシュボードのオプションボタンを選択します。

1. **[編集]** を選択します。

1. **メトリクスの選択**で **[Advanced metrics and recommendations]** (アドバンストメトリクスとレコメンデーション) を選択します。

1. **[Storage Lens グループ集約]** を選択します。
**注記**  
デフォルトでは、**[高度なメトリクス]** も選択されています。ただし、Storage Lens グループのデータを集約する必要がないため、この設定の選択を解除することもできます。

1. **[ストレージレンズグループ集約]** までスクロールし、データ集約に含める、または除外する 1 つまたは複数の Storage Lens グループを指定します。次のフィルタリングオプションを設定できます。
   + 特定の Storage Lens グループを含める場合は、**[Storage Lens グループを含める]** を選択します。**[含めるStorage Lens グループ]** で、Storage Lens グループを選択します。
   + すべての Storage Lens グループを含める場合は、[**ホームリージョンのすべてのStorage Lens グループをこのアカウントに含める**] を選択します。
   + 特定の Storage Lens グループを除外する場合は、**[Storage Lens グループを除外する]** を選択します。**[除外する Storage Lens グループ]** で、除外する Storage Lens グループを選択します。

1. **[Save changes]** (変更の保存) をクリックします。Storage Lens グループを正しく設定していれば、48 時間以内にダッシュボードに追加の Storage Lens グループ集約データが表示されます。

**S3 Storage Lens ダッシュボードから Storage Lens グループを削除するには**

1. AWS マネジメントコンソール にサインインし、Amazon S3 コンソール [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/) を開きます。

1. ナビゲーションペインの、**[S3 Storage Lens]** で、**[ダッシュボード]** を選択します。

1. Storage Lens グループを削除する Storage Lens ダッシュボードのオプションボタンを選択します。

1. **[ダッシュボード設定を表示]** を選択します。

1. **[編集]** を選択します。

1. **[メトリクスの選択]** セクションまで下にスクロールします。

1. **[Storage Lens グループ集約]** で、削除する Storage Lens グループの横にある **[X]** を選択します。これにより、Storage Lens グループが削除されます。

   すべての Storage Lens グループをダッシュボードに含めた場合は、**[このアカウントにホームリージョンのすべての Storage Lens グループを含める]** の横にあるチェックボックスをオフにします。

1. **[Save changes]** (変更の保存) をクリックします。
**注記**  
ダッシュボードに設定の更新が反映されるまでに最大 48 時間かかることがあります。

## AWS SDK for Java の使用
<a name="StorageLensGroupsConfigurationJava"></a>

**Example – すべての ストレージレンズグループをダッシュボードにアタッチする**  
次の SDK for Java の例では、アカウント {{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();
        }
    }
}
```

**Example – 2 つの ストレージレンズグループをダッシュボードにアタッチする**  
次の AWS SDK for Java 例では、2 つのストレージレンズグループ ({{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();
        }
    }
}
```

**Example – 除外項目を含むすべてのストレージレンズグループをアタッチする**  
次の SDK for Java 例では、2 つの 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();
        }
    }
}
```