

# Amazon MSK system tables schema and example queries

This page describes the columns of the Amazon MSK system tables and provides example queries.

## Table schemas
<a name="msk-system-tables-schema-tables"></a>

### clusters
<a name="msk-system-tables-schema-clusters"></a>

Full name: `"s3tablescatalog/aws-catalog"."msk"."clusters"`. Partitioned by `bucket(32, id)`.

The `clusters` system table contains one row for each cluster in your account and Region.

The following table describes the columns of the clusters table.


| Column | Type | Required | Description | 
| --- | --- | --- | --- | 
| `id` | `string` | Yes | Unique identifier of the asset. | 
| `ingestion_time` | `timestamptz` | Yes | Time this asset record was ingested into the system table, in UTC. | 
| `update_time` | `timestamptz` | No | Time the asset was last updated in the AWS Glue Data Catalog, in UTC. | 
| `schema_version` | `string` | Yes | Identifier of this system table's column layout. Changes when a column is added, removed, renamed, or retyped. | 
| `created_time` | `timestamptz` | No | Time the resource was created, in UTC. | 
| `name` | `string` | No | The user-provided business name for the asset. | 
| `description` | `string` | No | The user-provided business description for the asset. | 
| `resource_name` | `string` | Yes | The resource's technical name. | 
| `resource_description` | `string` | No | The resource's technical description. | 
| `client_authentication_enum` | `list<string>` | No | The client authentication modes enabled for client-broker connections to the cluster. Values: Iam, Scram, Tls, Unauthenticated. | 
| `client_broker_encryption_enum` | `string` | No | Indicates the encryption setting for data in transit between clients and brokers. TLS means that client-broker communication is enabled with TLS only. TLS\_PLAINTEXT means that client-broker communication is enabled for both TLS-encrypted, as well as plaintext data. PLAINTEXT means that client-broker communication is enabled in plaintext only. Values: TLS, TLS\_PLAINTEXT, PLAINTEXT. | 
| `cluster_type_enum` | `string` | No | The provisioning type of the cluster. Values: PROVISIONED, SERVERLESS. | 
| `in_cluster_encryption_enum` | `string` | No | When set to Enabled, it indicates that data communication among the broker nodes of the cluster is encrypted. When set to Disabled, the communication happens in plaintext. Values: Enabled, Disabled. | 
| `instance_type` | `string` | No | The type of broker used in the Amazon MSK cluster. | 
| `kafka_version` | `string` | No | The version of Apache Kafka. | 
| `management_mode_enum` | `string` | No | The Apache Kafka metadata management mode. Values: Zookeeper, Kraft, Migration. | 
| `network_type_enum` | `string` | No | The network type of the cluster, which is IPv4 or DUAL. The DUAL network type uses both IPv4 and IPv6 addresses for your cluster and its resources. By default, a cluster uses the IPv4 network type. Values: IPV4, DUAL. | 
| `number_of_broker_nodes` | `int` | No | The number of broker nodes in the cluster. | 
| `public_access_enum` | `string` | No | Public access control for brokers. Values: DISABLED, SERVICE\_PROVIDED\_EIPS. | 
| `state_enum` | `string` | No | The state of an Apache Kafka cluster. Values: CREATING, ACTIVE, UPDATING, REBOOTING\_BROKER, MAINTENANCE, HEALING, DELETING, FAILED. | 
| `storage_mode_enum` | `string` | No | This controls storage mode for supported storage tiers. Values: LOCAL, TIERED. | 
| `vpc_connectivity_enum` | `string` | No | VpcConnectivity control for brokers. Values: Enabled, Disabled. | 
| `vpc_connectivity_client_authentication_enum` | `list<string>` | No | The client authentication modes enabled for client connections over VPC connectivity. Values: Iam, Scram, Tls, Unauthenticated. | 
| `kms_key_id` | `string` | No | The identifier of the AWS KMS key that encrypts the resource at rest, as the source service reports it: a key ID, key ARN, alias name or alias ARN. | 

### topics
<a name="msk-system-tables-schema-topics"></a>

Full name: `"s3tablescatalog/aws-catalog"."msk"."topics"`. Partitioned by `bucket(32, id)`.

The `topics` system table contains one row for each topic in your account and Region.

The following table describes the columns of the topics table.


| Column | Type | Required | Description | 
| --- | --- | --- | --- | 
| `id` | `string` | Yes | Unique identifier of the asset. | 
| `ingestion_time` | `timestamptz` | Yes | Time this asset record was ingested into the system table, in UTC. | 
| `update_time` | `timestamptz` | No | Time the asset was last updated in the AWS Glue Data Catalog, in UTC. | 
| `schema_version` | `string` | Yes | Identifier of this system table's column layout. Changes when a column is added, removed, renamed, or retyped. | 
| `created_time` | `timestamptz` | No | Time the resource was created, in UTC. | 
| `name` | `string` | No | The user-provided business name for the asset. | 
| `description` | `string` | No | The user-provided business description for the asset. | 
| `resource_name` | `string` | Yes | The resource's technical name. | 
| `resource_description` | `string` | No | The resource's technical description. | 
| `cleanup_policy` | `string` | No | The Kafka log cleanup policy: delete, compact, or compact,delete. | 
| `compression_type_enum` | `string` | No | The Kafka compression codec for the topic. Values: producer, uncompressed, gzip, snappy, lz4, zstd. | 
| `min_insync_replicas` | `int` | No | The minimum number of in-sync replicas that must acknowledge a write when a producer sets acks to all. | 
| `partition_count` | `int` | No | The number of partitions configured for the topic. | 
| `replication_factor` | `int` | No | The replication factor of the topic. | 
| `retention_bytes` | `long` | No | The maximum size in bytes a partition log can grow to before old log segments are discarded under the delete cleanup policy. | 
| `retention_ms` | `long` | No | The topic retention period in milliseconds. | 
| `topic_id` | `string` | No | The Kafka topic ID. | 
| `belongs_to` | `string` | No | Fully qualified identifier of the container asset this asset is a member of. | 

## Example queries
<a name="msk-system-tables-example-queries"></a>

*Clusters by public access and encryption in transit*

```sql
SELECT cluster_type_enum, public_access_enum, client_broker_encryption_enum,
       count(*) AS clusters
FROM "s3tablescatalog/aws-catalog"."msk"."clusters"
GROUP BY 1, 2, 3;
```

*Topics with a replication factor below 3*

```sql
SELECT resource_name, replication_factor, min_insync_replicas, partition_count
FROM "s3tablescatalog/aws-catalog"."msk"."topics"
WHERE replication_factor < 3;
```