This topic describes how to add 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 these resource types are associated in various ways, 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.
  • Each tag key must be unique within a resource.

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

  • Tags are not shared across regions. For example, in the China (Shanghai) region, you cannot view the tags that are created in the China (Hangzhou) region.
  • After a tag is removed from a resource, Message Queue for Apache Kafka automatically deletes the tag if the tag is not added 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 added to a resource.
  • A tag can be added to a maximum of 50 resources.
  • A maximum of 20 tags can be added at a time.

Add tags

You can add 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, configure a tag and click Next in the Select Tag step.
    Notice You can configure 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, add the created tag to a resource and click Bind in the Bind Resource step.
    Notice If you select resources that are all of the same type, you can select up to 50 resources of the specified type.
    • Click the Instances tab and select the instance to which the tag is to be added.
    • Click the Topics tab and select the topic to which the tag is to be added.
    • Click the Groups tab and select the consumer group to which the tag is to be added.
    On the Tags page, you can view the created tag and the resource to which the tag is added. To add the tag to more resources, click Bind Resource in the Actions column.

Edit tags

If the tags added to an instance cannot help you efficiently categorize or retrieve resources, you can add other existing tags or create tags and add 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 a tag 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, and then click edit.
      2. In the Edit Tags for Instance panel, find the tag 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 a tag of a topic
      1. On the Instances page, click the name of the instance where the topic for which you want to edit a tag resides.
      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, and then click edit.
      4. In the Edit Tags for Topic panel, find the tag 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 a tag of a consumer group
      1. On the Instances page, click the name of the instance where the consumer group for which you want to edit a tag resides.
      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 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 add 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 to which the tag is added on the Instances, Topics, and Groups tabs.

Remove tags

If a tag is added to unsuitable resources or can no longer help you efficiently manage or retrieve resources, you can remove the tag from one or more resources at a time.

Notice After a tag is removed from a resource, the tag is automatically deleted if it is not added to other 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, select the tag key that you want to remove 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 remove and click Details in the Actions column.
  5. On the Tag Details page, select one or more resources from which you want to remove the tag on the Instances, Topics, or Groups tab.
    • Remove a tag from a single resource: In the resource list, find the resource from which you want to remove the tag and click Unbind Resource in the Actions column.
    • Remove a tag from multiple resources: In the resource list, select the resources from which you want to remove the tag. Then, click Unbind Resource below the resource list.
  6. In the Note message, read the note and click OK.