

# Create an Amazon S3 Storage Lens for Tables dashboard

To turn on Amazon S3 Storage Lens for Tables, you create a configuration. The configuration controls what Amazon S3 collects, which table buckets it covers, and where it delivers your metrics. You can create a configuration by using the Amazon S3 console, the AWS CLI, or the API. Before you begin, make sure that you have the permissions described in [Setting Amazon S3 Storage Lens for Tables permissions](s3-tables-storage-lens-permissions.md).

## Using the S3 console
<a name="s3-tables-storage-lens-console-creating"></a>

Use the following steps to create an Amazon S3 Storage Lens for Tables dashboard on the Amazon S3 console.

**Step 1: Configure general settings**

1. Sign in to the AWS Management Console and open the Amazon S3 console at [https://console.aws.amazon.com/s3/](https://console.aws.amazon.com/s3/).

1. In the navigation bar, choose the name of the currently displayed AWS Region. Next, choose the Region that you want to switch to.

1. In the left navigation pane, choose **Storage Lens**, and then choose the **Table buckets** tab.

1. Choose **Create S3 Tables dashboard**.

1. In the **General** step, do the following:

   1. View the **Home Region** for your dashboard. The home Region is the AWS Region where the configuration and metrics for this Storage Lens dashboard are stored.

   1. For **Dashboard name**, enter a name for your dashboard.

      The dashboard name must be fewer than 65 characters and must not contain special characters or spaces.
**Note**  
You can't change the dashboard name after the dashboard is created.

   1. For **Status**, choose **Enabled**. When the dashboard is enabled, it displays updated daily metrics.

   1. Under **Tags - optional**, add tags to your dashboard. You can use tags to manage permissions for your dashboard and track storage costs for S3 Storage Lens. For more information, see [Controlling access to AWS resources using tags](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html) in the *IAM User Guide*.
**Note**  
You can add up to 50 tags to your dashboard configuration.

1. Choose **Next** to save your changes and proceed.

**Step 2: Define the dashboard scope**

1. In the **Dashboard scope** step, specify the accounts, Regions, and table buckets to include in the scope of the dashboard.

1. Choose the table buckets in your selected Regions that you want S3 Storage Lens to include or exclude. Choose either **Include all table buckets** or **Exclude table buckets**. You can either include or exclude table buckets, but not both.
**Note**  
If you choose **Include all table buckets**, the dashboard also includes AWS managed table buckets that AWS services create on your behalf.
**Note**  
To create an organization-level dashboard, you must first enable trusted access for S3 Storage Lens in AWS Organizations. If trusted access isn't enabled, the console prompts you to configure your AWS Organizations settings.

1. Choose **Next** to save your changes and proceed.

**Step 3: Choose your Storage Lens tier**

1. In the **Storage Lens tier** step, choose the tier of features that you want to aggregate for this dashboard:

   1. To include free tier metrics, choose **Free tier**.

   1. To add advanced metrics, choose **Advanced tier**. The advanced tier has an additional cost. For more information, see [Amazon S3 pricing](https://aws.amazon.com/s3/pricing/).

1. If you chose **Advanced tier**, select the advanced metric categories that you want to enable:
   + **Storage metrics**
   + **Activity metrics**
   + **Maintenance metrics**

1. Choose **Next** to save your changes and proceed.

**Step 4: Choose your metrics export and publishing settings**

1. In the **Metrics export and publishing** step, if you chose the advanced tier, choose **CloudWatch publishing** to access your Storage Lens metrics in Amazon CloudWatch.

1. To export your Storage Lens dashboard data daily, turn on the daily data export, and then choose the destination bucket type:
   + **General purpose bucket** – Update the **General purpose bucket destination settings**.
   + **Table bucket** – Update the **Table bucket destination settings**.

1. Choose **Next** to save your changes and proceed.

**Step 5: Review your dashboard configuration and create your dashboard**

1. On the **Review and create** step, review your settings. To make changes to a section, choose **Edit** for that section.

1. After you review and confirm your dashboard configuration settings, choose **Submit** to create your dashboard.

After you successfully create your dashboard, you can view it in the list of dashboards on the **Table buckets** tab.

## Using the AWS CLI
<a name="s3-tables-storage-lens-cli-creating"></a>

You create a configuration by using the `put-storage-lens-configuration` command, which calls the `PutStorageLensConfiguration` operation. This operation creates a configuration or replaces an existing one that has the same identifier. You provide the configuration body as a JSON file through the `--storage-lens-configuration` flag. For a sample configuration body and the fields it supports, see [Helper files for using Amazon S3 Storage Lens for Tables](s3-tables-storage-lens-helper-files.md).

**Example**  
The following example command creates an Amazon S3 Storage Lens for Tables configuration. To use this example, replace the `{{user input placeholders}}` with your own information.  

```
aws s3tables put-storage-lens-configuration --storage-lens-id={{your-configuration-id}} --storage-lens-configuration={{file://./config.json}}
```

## Using the AWS SDK for Java
<a name="s3-tables-storage-lens-java-creating"></a>

The following example creates a representative Amazon S3 Storage Lens for Tables configuration in SDK for Java: it scopes the dashboard to specific AWS Regions and table buckets, enables the advanced tier metric categories, publishes metrics to CloudWatch, and exports metrics to AWS managed S3 Tables. To use this example, replace the `{{user input placeholders}}` with your own information.

**Example – Create an Amazon S3 Storage Lens for Tables configuration**  

```Java
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3tables.S3TablesClient;
import software.amazon.awssdk.services.s3tables.model.PutStorageLensConfigurationRequest;
import software.amazon.awssdk.services.s3tables.model.StorageLensConfiguration;
import software.amazon.awssdk.services.s3tables.model.S3TablesException;

public class CreateStorageLensConfiguration {

    public static void main(String[] args) {
        String storageLensId = "{{your-configuration-id}}";

        try (S3TablesClient s3TablesClient = S3TablesClient.builder()
                .region(Region.{{US_EAST_1}})
                .build()) {

            StorageLensConfiguration configuration = StorageLensConfiguration.builder()
                    .id(storageLensId)
                    .isEnabled(true)
                    // Scope: include specific Regions and table buckets. Omit include to cover all.
                    .include(scope -> scope
                            .regions("{{us-east-1}}")
                            .tableBuckets("{{arn:aws:s3tables:us-east-1:111122223333:bucket/amzn-s3-demo-bucket}}"))
                    // Advanced tier: add the storage, activity, and maintenance metric categories.
                    .advancedMetricsCategoriesWithStrings("StorageMetrics", "ActivityMetrics", "MaintenanceMetrics")
                    .dataExport(export -> export
                            // Publish metrics to CloudWatch (advanced tier).
                            .cloudWatchMetrics(cw -> cw.isEnabled(true))
                            // Export metrics to AWS managed S3 Tables.
                            .storageLensTableDestination(dest -> dest.isEnabled(true)))
                    .build();

            s3TablesClient.putStorageLensConfiguration(PutStorageLensConfigurationRequest.builder()
                    .storageLensId(storageLensId)
                    .storageLensConfiguration(configuration)
                    .build());
        } catch (S3TablesException e) {
            System.err.println(e.awsErrorDetails().errorMessage());
        }
    }
}
```