[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# Add labels to secrets\n\nThis page provides an overview of labels, describes how to add labels to a\nsecret, and how to view and update labels attached to a secret.\n\nWhat are labels?\n----------------\n\nA label is a key-value pair that you can assign to Google Cloud Secret Manager secrets.\nThey help you organize these resources and manage your costs at scale, with the\ngranularity you need. You can attach a label to each resource, then filter the\nresources based on their labels. Information about labels is forwarded to the billing system that\nlets you break down your billed charges by label. With built-in [billing reports](/billing/docs/how-to/reports),\nyou can filter and group costs by resource labels. You can also use labels to\nquery [billing data exports](/billing/docs/how-to/bq-examples).\n\nRequirements for labels\n-----------------------\n\nThe labels applied to a resource must meet the following\nrequirements:\n\n- Each resource can have up to 64 labels.\n- Each label must be a key-value pair.\n- Keys have a minimum length of 1 character and a maximum length of 63 characters, and cannot be empty. Values can be empty, and have a maximum length of 63 characters.\n- Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed. Keys must start with a lowercase letter or international character.\n- The key portion of a label must be unique within a single resource. However, you can use the same key with multiple resources.\n\nThese limits apply to the key and value for each label, and to the\nindividual Google Cloud resources that have labels. There\nis no limit on how many labels you can apply across all resources\nwithin a project.\n\nCommon uses of labels\n---------------------\n\nHere are some common use cases for labels:\n\n- **Team or cost center labels** : Add labels based on team or\n cost center to distinguish Secret Manager secrets owned by different\n teams (for example, `team:research` and `team:analytics`). You can use this\n type of label for cost accounting or budgeting.\n\n- **Component labels** : For example, `component:redis`,\n `component:frontend`, `component:ingest`, and `component:dashboard`.\n\n- **Environment or stage labels** : For example,\n `environment:production` and `environment:test`.\n\n- **State labels** : For example, `state:active`,\n `state:readytodelete`, and `state:archive`.\n\n- **Ownership labels** : Used to identify the teams that are\n responsible for operations, for example: `team:shopping-cart`.\n\n\n| **Note:** Don't include sensitive information in labels, including personally identifiable information, such as an individual's name or title. Labels are not designed to handle sensitive information.\n\nWe don't recommend creating large numbers of unique labels, such as\nfor timestamps or individual values for every API call.\nThe problem with this approach is that when the values change frequently or with\nkeys that clutter the catalog, this makes it difficult to effectively filter and\nreport on resources.\n\nLabels and tags\n---------------\n\nLabels can be used as queryable annotations for resources, but can't be used\nto set conditions on policies. Tags provide a way to conditionally allow or\ndeny policies based on whether a resource has a specific tag, by providing fine-grained\ncontrol over policies. For more information, see the\n[Tags overview](/resource-manager/docs/tags/tags-overview).\n\nCreate a secret with labels\n---------------------------\n\nTo add a label when creating the secret, follow these steps: \n\n### Console\n\n1. In the Google Cloud console, go to the **Secret Manager** page.\n\n\n [Go to Secret Manager](https://console.cloud.google.com/security/secret-manager)\n2. On the **Secret Manager** page, click **Create secret**.\n\n3. On the **Create secret** page, enter a name for the secret in the **Name** field.\n\n4. Enter a value for the secret (for example, `abcd1234`). You can also upload a text file containing the secret value using\n the **Upload file** option. This action automatically creates the secret version.\n\n5. Go to the **Labels** section, and then click **Add label**.\n\n6. Enter the key and corresponding value to create a label.\n\n7. Click **Create secret**.\n\nView labels on a secret\n-----------------------\n\nTo view assigned labels, follow these steps: \n\n### Console\n\n1. In the Google Cloud console, go to the **Secret Manager** page.\n\n\n [Go to Secret Manager](https://console.cloud.google.com/security/secret-manager)\n2. On the **Secret Manager** page, select the secret whose labels you want to view.\n\n3. If the **Info Panel** is closed, click **Show Info Panel** to display it.\n\n4. In the panel, click the **Labels** tab. All the labels added to the secret are displayed.\n\nUpdate labels\n-------------\n\nTo update labels, follow these steps: \n\n### Console\n\n1. In the Google Cloud console, go to the **Secret Manager** page.\n\n\n [Go to Secret Manager](https://console.cloud.google.com/security/secret-manager)\n2. Select the secret that you want to edit.\n\n3. Open the **Info Panel** , and then click the **Labels** tab.\n\n4. Update the existing value of a label and click **Save**.\n\n You can also delete an existing label or add a new label. To edit the key of a label, add a new\n label with the same key name, and then delete the old label.\n\nRemove labels\n-------------\n\nTo remove labels, follow these steps: \n\n### Console\n\n1. In the Google Cloud console, go to the **Secret Manager** page.\n\n\n [Go to Secret Manager](https://console.cloud.google.com/security/secret-manager)\n2. Select the secret that you want to edit.\n\n3. Open the **Info Panel** , and then click the **Labels** tab.\n\n4. Click delete**Delete**\n to remove the labels that you no longer require.\n\n5. Click **Save**.\n\nWhat's next\n-----------\n\n- [Create rotation schedules](/secret-manager/docs/secret-rotation)\n- [Set an expiration date for a secret](/secret-manager/docs/creating-and-managing-expiring-secrets)"]]