To list your topics in a cluster, you can use the Google Cloud console, the Google Cloud CLI, the client library, the Managed Kafka API, or the open source Apache Kafka APIs.
Required roles and permissions to list your topics
To get the permissions that you need to list your topics,
ask your administrator to grant you the
Managed Kafka Viewer (roles/managedkafka.viewer
) IAM role on your project.
For more information about granting roles, see Manage access to projects, folders, and organizations.
This predefined role contains the permissions required to list your topics. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to list your topics:
-
List topics:
managedkafka.topics.list
-
Get topic:
managedkafka.topics.get
You might also be able to get these permissions with custom roles or other predefined roles.
For more information about the Managed Kafka Viewer (roles/managedkafka.viewer
) IAM role,
see Managed Service for Apache Kafka predefined roles.
List your topics
Console
In the Google Cloud console, go to the Clusters page.
The clusters you created in a project are listed.
- Click the cluster for which you want to see the topics.
The cluster details page is displayed. In the cluster details page, for the Resources tab, the topics are listed.
gcloud
-
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
Run the
gcloud beta managed-kafka topics list
command:gcloud beta managed-kafka topics list CLUSTER_ID \ --location=LOCATION_ID \ --limit=LIMIT
This command retrieves a list of all topics present within the specified Managed Service for Apache Kafka cluster. You can use optional flags to filter, limit, and sort the output.
Replace the following:
CLUSTER_ID: The name of the cluster whose topics you want to list.
LOCATION_ID: The location of the cluster.
LIMIT: (Optional) The maximum number of topics to list.