如要將 Google Cloud 工作流程和其他資源分組,以便在 Google Cloud 貴機構中進行報表、稽核和存取權控管,請使用標記。標記和標籤各自獨立運作,您可以將兩者套用至同一個工作流程。
什麼是標籤?
標籤是鍵/值組合,可指派給 Google Cloud 工作流程。這些標籤可協助您整理這些資源,並以所需精細度大規模管理費用。您可以為每項資源加上標籤,並根據標籤篩選資源。標籤的相關資訊會轉送至帳單系統,方便您依據標籤查看帳單費用明細。您可以使用內建的帳單報表,依資源標籤篩選及分組費用。您也可以使用標籤查詢帳單資料匯出內容。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-11 (世界標準時間)。"],[],[],null,["# Label workflows\n\nLabels are key-value pairs that you can use to identify and group related\nworkflows and store metadata about a workflow. You can specify multiple labels\nfor a workflow.\n\nThis page explains how you can use labels with your workflows. It also describes\nhow to add, update, and remove the labels for a workflow.\n| **Note:** Workflow labels are inherited by executions of the workflow.\n\nTo group workflows and other resources across Google Cloud for\nreporting, auditing, and access control in your Google Cloud organization,\nuse [tags](/workflows/docs/create-manage-tags). Tags and labels work\nindependently of each other, and you can apply both to the same workflow.\n\nWhat are labels?\n----------------\n\nA label is a key-value pair that you can assign to Google Cloud workflows.\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 workflows 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\nAdd or update labels\n--------------------\n\nYou can add one or more labels to a workflow when you\n[create a workflow](/workflows/docs/creating-updating-workflow#create_a_workflow).\nYou can also add or edit labels when\n[updating a workflow](/workflows/docs/creating-updating-workflow#update_a_workflow).\n\nIf you update an existing label, or add a new one, it can take up to 10 minutes\nfor the new label to take effect.\n\nFilter workflows by label\n-------------------------\n\nYou can search for and list specific workflows by filtering them by label. \n\n### Console\n\n1. In the Google Cloud console, go to the **Workflows** page:\n\n\n [Go to Workflows](https://console.cloud.google.com/workflows)\n\n \u003cbr /\u003e\n\n2. In the\n filter_list\n **Filter** field, select **Labels** as the filter criteria and, in the\n **Values** list, select a key-value pair.\n\n### gcloud\n\nUse the `--filter` flag with the\n[gcloud workflows list](/sdk/gcloud/reference/workflows/list) command: \n\n gcloud workflows list \\\n --filter labels.\u003cvar translate=\"no\"\u003eKEY\u003c/var\u003e=\u003cvar translate=\"no\"\u003eVALUE\u003c/var\u003e\n\nReplace \u003cvar translate=\"no\"\u003eKEY\u003c/var\u003e and \u003cvar translate=\"no\"\u003eVALUE\u003c/var\u003e with\na label key-value pair.\n\nFor more information about the filter syntax in the Google Cloud CLI,\nsee [`gcloud topic filters`](/sdk/gcloud/reference/topic/filters).\n\nWorkflow labels are inherited by executions of the workflow. To view execution\nlabels, use the `workflows.executions.list` method to\n[list and filter workflow executions](/workflows/docs/executing-workflow#filter_executions).\n\nDelete labels\n-------------\n\nYou can delete a specific label using the Google Cloud console, or you can use\nthe gcloud CLI to delete all the labels from a workflow. \n\n### Console\n\n1. In the Google Cloud console, go to the **Workflows** page:\n\n\n [Go to Workflows](https://console.cloud.google.com/workflows)\n\n \u003cbr /\u003e\n\n2. Click the name of the workflow you want to update.\n\n The **Workflow details** page appears.\n3. Click\n edit\n **Edit**.\n\n The **Edit workflow** page appears.\n4. Next to the label that you want to remove, click\n delete\n **Delete item**.\n\n5. Click **Next**.\n\n6. To redeploy the workflow, click **Deploy**.\n\n### gcloud\n\nUse the `--labels` flag with an empty value and the\n[gcloud workflows deploy](/sdk/gcloud/reference/workflows/deploy) command: \n\n```bash\ngcloud workflows deploy WORKFLOW_NAME \\\n --labels=\"\" \\\n --source=YAML_OR_JSON_SOURCE_FILE\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eWORKFLOW_NAME\u003c/var\u003e: the name of your workflow.\n\n- \u003cvar translate=\"no\"\u003eYAML_OR_JSON_SOURCE_FILE\u003c/var\u003e: the source file for the\n workflow in either YAML or JSON format. For example: `myFirstWorkflow.yaml`."]]