

# Enabling CloudWatch publishing for Amazon S3 Storage Lens for Tables

You can enable CloudWatch support for new or existing dashboard configurations by using the S3 console, AWS CLI, and AWS SDKs. The CloudWatch publishing option is available for dashboards that use the advanced tier. For advanced tier pricing, see [Amazon S3 pricing](https://aws.amazon.com/s3/pricing/). No additional CloudWatch metrics publishing charges apply; however, other CloudWatch charges, such as dashboards, alarms, and API calls, do apply.

To enable the CloudWatch publishing option for Amazon S3 Storage Lens for Tables metrics, see the following topics.

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

You turn on the CloudWatch publishing option when you create or edit an Amazon S3 Storage Lens for Tables dashboard in the Amazon S3 console. CloudWatch publishing is available only when you choose the advanced tier.

**To turn on CloudWatch publishing for a dashboard**

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 left navigation pane, choose **Storage Lens**, and then choose the **Table buckets** tab.

1. Create a dashboard, or choose an existing dashboard and choose **Edit**.

1. In the **Storage Lens tier** step, choose **Advanced tier**.

1. In the **Metrics export and publishing** step, choose **CloudWatch publishing**.

1. Proceed through the remaining steps, and then on the **Review and create** step, choose **Submit**.

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

To enable the CloudWatch publishing option, use the `put-storage-lens-configuration` command with a configuration that sets `cloudWatchMetrics` to `isEnabled: true` under `dataExport`. CloudWatch publishing requires the advanced tier, so your configuration must also include `advancedMetricsCategories`. The following example enables the CloudWatch publishing option for 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}}
```

The following `config.json` file enables the CloudWatch publishing option. For the full set of configuration fields, see [Helper files for using Amazon S3 Storage Lens for Tables](s3-tables-storage-lens-helper-files.md).

```json
{
  "id": "{{your-configuration-id}}",
  "isEnabled": {{true}},
  "advancedMetricsCategories": [
    "{{StorageMetrics}}",
    "{{ActivityMetrics}}",
    "{{MaintenanceMetrics}}"
  ],
  "dataExport": {
    "cloudWatchMetrics": {
      "isEnabled": {{true}}
    }
  }
}
```

## Using the AWS SDK for Java
<a name="s3-tables-storage-lens-cloudwatch-enable-publish-sdk"></a>

The following example enables the CloudWatch publishing option for an Amazon S3 Storage Lens for Tables configuration by using the AWS SDK for SDK for Java. CloudWatch publishing requires the advanced tier, so the configuration also sets advanced metrics categories. To use this example, replace the `{{user input placeholders}}` with your own information.

**Example – Enable CloudWatch publishing for 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.StorageLensConfigurationItem;
import software.amazon.awssdk.services.s3tables.model.StorageLensDataExport;

public class EnableCloudWatchPublishing {

    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)
                    .advancedMetricsCategoriesWithStrings("{{StorageMetrics}}", "{{ActivityMetrics}}", "{{MaintenanceMetrics}}")
                    .dataExport(StorageLensDataExport.builder()
                            .cloudWatchMetrics(StorageLensConfigurationItem.builder()
                                    .isEnabled(true)
                                    .build())
                            .build())
                    .build();

            s3TablesClient.putStorageLensConfiguration(PutStorageLensConfigurationRequest.builder()
                    .storageLensId(storageLensId)
                    .storageLensConfiguration(configuration)
                    .build());
        }
    }
}
```

**Next steps**  
After you enable the CloudWatch publishing option, you can access your Amazon S3 Storage Lens for Tables metrics in CloudWatch. You also can leverage CloudWatch features to monitor and analyze your data in CloudWatch. For more information, see the following topics:
+ [Amazon S3 Storage Lens for Tables metrics and dimensions](s3-tables-storage-lens-cloudwatch-metrics-dimensions.md)
+ [Working with Amazon S3 Storage Lens for Tables metrics in CloudWatch](s3-tables-storage-lens-cloudwatch-monitoring-cloudwatch.md)