標籤是可指派給 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-04 (世界標準時間)。"],[],[],null,["# Label Cloud Workstations resources\n\nThis page describes how to use labels with Cloud Workstations resources.\n\n\u003cbr /\u003e\n\nWhat are labels?\n----------------\n\nA label is a key-value pair that you can assign to Google Cloud instances.\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 instances 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+ **Virtual machine labels**: A label can be\nattached to a virtual machine. Virtual machine tags that you defined in the\npast appear as a label without a value.\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\nFor more information about Google Cloud labels, see [Organize resources using\nlabels](/compute/docs/labeling-resources#filter).\n\nFor more information about tagging Cloud Workstations resources, see [Tag Cloud Workstations resources](/workstations/docs/tags).\n\nCloud Workstations resource labels\n----------------------------------\n\nCloud Workstations automatically applies the following labels to all resources:\n\n- `workstation_cluster_id`\n- `workstation_config_id`\n- `workstation_id`\n- `workstation_location`\n- `goog-drz-workstation-location`\n- `goog-drz-workstation-uuid`\n- `goog-workstations`\n\nCustom Cloud Workstations labels\n--------------------------------\n\nYou can also add your custom labels to workstation clusters, workstation\nconfigurations and workstations, which recursively applies them to all\nunderlying Compute Engine resources, although not to the underlying\nCloud Workstations API resources. To label Compute Engine resources for\nindividual workstations, be sure to add labels for each individual workstation.\n\nUse the `labels` field when calling the\n[Cloud Workstations API](/workstations/docs/apis).\n\nFor example, in the sample `config.json` file that follows, `webserver` is a key\nand `backend` is the corresponding value. Similarly, `media` is a key and\n`images` is the corresponding value. \n\n {\n \"idleTimeout\": \"7200s\",\n \"host\": {\n \"gce_instance\": {\n \"machine_type\": \"e2-standard-8\",\n \"pool_size\": 1\n }\n },\n \"persistentDirectories\": [\n {\n \"mountPath\": \"/home\",\n \"gcePd\": {\n \"sizeGb\": 200,\n \"fsType\": \"ext4\"\n }\n }\n ],\n \"labels\": {\n \"webserver\": \"backend\",\n \"media\": \"images\"\n }\n }"]]