To view the detailed information for a single consumer group, 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 view a consumer group


To get the permissions that
you need to view your consumer groups,

ask your administrator to grant you the
[Managed Kafka Viewer](https://docs.cloud.google.com/iam/docs/roles-permissions/managedkafka.md.txt#managedkafka.viewer) (`roles/managedkafka.viewer`) IAM role on your project.


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


This predefined role contains

the permissions required to view your consumer groups. To see the exact permissions that are
required, expand the **Required permissions** section:


#### Required permissions

The following permissions are required to view your consumer groups:

- List consumer groups: `managedkafka.consumerGroups.list`
- Get consumer group details: `managedkafka.consumerGroups.get`


You might also be able to get
these permissions
with [custom roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles.md.txt) or
other [predefined roles](https://docs.cloud.google.com/iam/docs/roles-overview.md.txt#predefined).

## View a consumer group

To view the detailed information for a consumer group for a specific
cluster, follow these steps:

### Console

1. In the Google Cloud console, go to the **Cluster** page.

   [Go to Clusters](https://console.cloud.google.com/managedkafka/clusters)
2. Click the cluster for which you want to see the consumer groups. The **Cluster details** page is displayed. In the **Cluster details** page,
   under the **Resources** tab, the consumer groups are listed.

3. Click the consumer group.The **Consumer group details** page opens.

4. The page contains the following details:
   - **Configuration:** This tab displays the name of the consumer group. It also shows the topic to which the consumer group is attached.
   - **Monitoring:** This tab displays the offset lag by partition monitoring chart.

### gcloud

1. In the Google Cloud console, activate Cloud Shell.

   [Activate Cloud Shell](https://console.cloud.google.com/?cloudshell=true)


   At the bottom of the Google Cloud console, a
   [Cloud Shell](https://docs.cloud.google.com/shell/docs/how-cloud-shell-works.md.txt)
   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.
2. Run the [`gcloud managed-kafka consumer-groups describe`](https://docs.cloud.google.com/sdk/gcloud/reference/managed-kafka/consumer-groups/describe) command:

   <br />

   ```bash
   gcloud managed-kafka consumer-groups describe CONSUMER_GROUP_ID \
       --cluster=CLUSTER \
       --location=LOCATION
   ```

   This command provides detailed information about a specific
   Managed Service for Apache Kafka consumer group. It includes information about the consumer
   group, including its name, group ID, creation time, and update time.

   Replace the following:
   - <var translate="no">CONSUMER_GROUP_ID</var>: The ID or name of the consumer group.

   - <var translate="no">CLUSTER</var>: The ID or name of the cluster.

   - <var translate="no">LOCATION</var>: The location of the cluster.

   <br />

### Go

Before trying this sample, follow the Go setup instructions in
[Install the client libraries](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/reference/libraries.md.txt#install). For more information,
see the [Managed Service for Apache Kafka Go API reference documentation](https://docs.cloud.google.com/go/docs/reference/cloud.google.com/go/managedkafka/latest/apiv1.md.txt).

To authenticate to Managed Service for Apache Kafka, set up Application Default Credentials(ADC).
For more information,
see [Set up ADC for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```go
import (
	"context"
	"fmt"
	"io"

	"cloud.google.com/go/managedkafka/apiv1/managedkafkapb"
	"google.golang.org/api/option"

	managedkafka "cloud.google.com/go/managedkafka/apiv1"
)

func getConsumerGroup(w io.Writer, projectID, region, clusterID, consumerGroupID string, opts ...option.ClientOption) error {
	// projectID := "my-project-id"
	// region := "us-central1"
	// clusterID := "my-cluster"
	// consumerGroupID := "my-consumer-group"
	ctx := context.Background()
	client, err := managedkafka.NewClient(ctx, opts...)
	if err != nil {
		return fmt.Errorf("managedkafka.NewClient got err: %w", err)
	}
	defer client.Close()

	clusterPath := fmt.Sprintf("projects/%s/locations/%s/clusters/%s", projectID, region, clusterID)
	consumerGroupPath := fmt.Sprintf("%s/consumerGroups/%s", clusterPath, consumerGroupID)
	req := &managedkafkapb.GetConsumerGroupRequest{
		Name: consumerGroupPath,
	}
	consumerGroup, err := client.GetConsumerGroup(ctx, req)
	if err != nil {
		return fmt.Errorf("client.GetConsumerGroup got err: %w", err)
	}
	fmt.Fprintf(w, "Got consumer group: %#v\n", consumerGroup)
	return nil
}
```

### Java

Before trying this sample, follow the Java setup instructions in
[Install the client libraries](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/reference/libraries.md.txt#install). For more information,
see the [Managed Service for Apache Kafka Java API reference documentation](https://docs.cloud.google.com/java/docs/reference/google-cloud-managedkafka/latest/overview.md.txt).

To authenticate to Managed Service for Apache Kafka, set up Application Default Credentials.
For more information, see [Set up ADC for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```java
import com.google.api.gax.rpc.ApiException;
import com.google.cloud.managedkafka.v1.ConsumerGroup;
import com.google.cloud.managedkafka.v1.ConsumerGroupName;
import com.google.cloud.managedkafka.v1.ManagedKafkaClient;
import java.io.IOException;

public class GetConsumerGroup {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the example.
    String projectId = "my-project-id";
    String region = "my-region"; // e.g. us-east1
    String clusterId = "my-cluster";
    String consumerGroupId = "my-consumer-group";
    getConsumerGroup(projectId, region, clusterId, consumerGroupId);
  }

  public static void getConsumerGroup(
      String projectId, String region, String clusterId, String consumerGroupId) throws Exception {
    try (ManagedKafkaClient managedKafkaClient = ManagedKafkaClient.create()) {
      // This operation is being handled synchronously.
      ConsumerGroup consumerGroup =
          managedKafkaClient.getConsumerGroup(
              ConsumerGroupName.of(projectId, region, clusterId, consumerGroupId));
      System.out.println(consumerGroup.getAllFields());
    } catch (IOException | ApiException e) {
      System.err.printf("managedKafkaClient.getConsumerGroup got err: %s", e.getMessage());
    }
  }
}
```

### Python

Before trying this sample, follow the Python setup instructions in
[Install the client libraries](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/reference/libraries.md.txt#install). For more information,
see the [Managed Service for Apache Kafka Python API reference documentation](https://docs.cloud.google.com/python/docs/reference/google-cloud-managedkafka/latest.md.txt).

To authenticate to Managed Service for Apache Kafka, set up Application Default Credentials.
For more information,
see [Set up ADC for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment.md.txt).

```python
from google.api_core.exceptions import NotFound
from google.cloud import managedkafka_v1

# TODO(developer)
# project_id = "my-project-id"
# region = "us-central1"
# cluster_id = "my-cluster"
# consumer_group_id = "my-consumer-group"

client = managedkafka_v1.ManagedKafkaClient()

consumer_group_path = client.consumer_group_path(
    project_id, region, cluster_id, consumer_group_id
)
request = managedkafka_v1.GetConsumerGroupRequest(
    name=consumer_group_path,
)

try:
    consumer_group = client.get_consumer_group(request=request)
    print("Got consumer group:", consumer_group)
except NotFound as e:
    print(f"Failed to get consumer group {consumer_group_id} with error: {e.message}")
```

<br />

## What's next?

- [Edit a consumer group](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/edit-consumer-group.md.txt).

- [Delete a consumer group](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/delete-consumer-group.md.txt).

*Apache Kafka® is a registered
trademark of The Apache Software Foundation or its affiliates in the United
States and/or other countries.*