This topic describes how to bind tags to Message Queue for Apache Kafka resources such as instances, topics, and consumer groups to help you categorize and manage resources based on tags.

Background information

A tag consists of a tag key and a tag value and is used to mark Message Queue for Apache Kafka resources. If you have multiple types of Message Queue for Apache Kafka resources within your account and different resource types have multiple associations, you can use tags to group and categorize your resources based on the purposes they serve and the relations between them. This way, when you conduct routine O&M or locate problems, you can retrieve resources, perform batch operations, and fix the problems in an efficient manner.

Usage notes

  • Each tag consists of a key-value pair.
  • A tag must have a unique tag key.

    For example, the city:shanghai tag is bound to a Message Queue for Apache Kafka instance. When the city:newyork tag is bound to the instance, the city:shanghai tag is automatically unbound from the instance.

  • Tags are not shared across regions. For example, in the China (Shanghai) region, you cannot view tags that are created in the China (Hangzhou) region.
  • After a tag is unbound from a resource, the system automatically deletes the tag if the tag is not bound to other resources.
  • For more information about how to design tag keys and values, see Best practices for tag design.

Limits

  • A maximum of 20 tags can be bound to a resource.
  • A tag can be bound to a maximum of 50 resources.
  • A maximum of 20 tags can be bound or unbound at a time.

Bind tags

You can bind tags to Message Queue for Apache Kafka resources such as instances, topics, and consumer groups. This helps you categorize your resources.

  1. Log on to the Message Queue for Apache Kafka console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance resides.
  3. In the left-side navigation pane, click Tags.
  4. On the Tags page, click Create Tag.
  5. In the Create Tag wizard, create a tag and click Next in the Select Tag step.
    Notice You can create a maximum of 20 tags at a time. Each tag must be unique.
    1. Enter a tag key in the Tag Key field or select an existing tag key from the Label key drop-down list.
    2. Enter a tag value in the Tag Value field or select an existing tag value from the Label value drop-down list.
  6. In the Create Tag wizard, bind the created tag to a resource and click Bind in the Bind Resource step.
    Notice You can select up to 50 resources of the same type.
    • Click the Instances tab and select the instance to be bound.
    • Click the Topics tab and select the topic to be bound.
    • Click the Groups tab and select the group to be bound.
    On the Tags page, you can view the created tag and the resource to which the tag is bound. To bind the tag to more resources or unbind the tag from a resource, click Bind Resource in the Actions column.

Edit tags

If the tags bound to an instance cannot help you efficiently categorize or retrieve resources, you can bind other existing tags or create tags and bind the new tags to the instance for easy management.

  1. Log on to the Message Queue for Apache Kafka console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance resides.
  3. Edit the tags of an instance, a topic, or a consumer group based on your needs.
    • Edit tags of an instance
      1. On the Instances page, find the instance for which you want to edit a tag, move the pointer over the tag icon in the Tag column of the instance, and then click Edit.
      2. In the Edit Tags for Instance panel, find the Tag Key to be edited.
      3. Edit the tag key in the Tag Key field, edit the tag value in the Tag Value field, and then click OK.
    • Edit tags of a topic
      1. On the Instances page, click the name of your instance.
      2. In the left-side navigation pane, click Topics.
      3. On the Topics page, find the topic for which you want to edit a tag, move the pointer over the tag icon in the Tag column of the topic, and then click Edit.
      4. In the Edit Tags for Topic panel, find the Tag Key to be edited.
      5. Edit the tag key in the Tag Key field, edit the tag value in the Tag Value field, and then click OK.
    • Edit tags of a consumer group
      1. On the Instances page, click the name of your instance.
      2. In the left-side navigation pane, click Groups.
      3. On the Groups page, find the consumer group for which you want to edit a tag, move the pointer over the tag icon in the Tag column, and then click Edit.
      4. In the Edit Tags for Group panel, find the Tag Key to be edited.
      5. Edit the tag key in the Tag Key field, edit the tag value in the Tag Value field, and then click OK.

Use tags to retrieve resources

After you bind a tag to a resource, you can retrieve the resource by using this tag.

  1. Log on to the Message Queue for Apache Kafka console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance resides.
  3. In the left-side navigation pane, click Tags.
  4. On the Tags page, select the tag key that you want to use from the Select Tag Key drop-down list. Then, the tag values that correspond to the tag key appear. Enter the tag value that you want to use in the search box and click the Search icon. Then, click Details in the Actions column of the tag value.
    Note If no tag value is available, Null appears.
  5. On the Tag Details page, you can view the resources that are bound to the tag on the Instances, Topics, or Groups tab.

Unbind tags

When tags are bound to unsuitable resources or can no longer help you efficiently manage or retrieve resources, you can unbind multiple tags from resources at a time.

Notice You can unbind a maximum of 20 tags at a time. After a tag is unbound, the tag is automatically deleted if the number of resources bound to the tag is zero.
  1. Log on to the Message Queue for Apache Kafka console.
  2. In the Resource Distribution section of the Overview page, select the region where your instance resides.
  3. In the left-side navigation pane, click Tags.
  4. On the Tags page, select the tag key that you want to unbind from the Select Tag Key drop-down list. Then, the tag values that correspond to the tag key appear. Find the tag value that you want to unbind, and click Details in the Actions column of the tag value.
  5. On the Tag Details page, select one or more resources to be unbound from the tag on the Instances, Topics, or Groups tab.
    • Unbind a single resource: In the resource list, find the resource that you want to unbind and click Unbind Resource in the Actions column.
    • Unbind multiple resources: In the resource list, select the resources that you want to unbind. Then, click Unbind Resource below the resource list.
  6. In the Note message, read the note and click OK.