[[["容易理解","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 (世界標準時間)。"],[[["\u003cp\u003eLabels allow for grouping related resources and provide a detailed view of billing for App Engine services, enabling comparisons across services like \u003ccode\u003eservice:default\u003c/code\u003e, \u003ccode\u003eservice:backend\u003c/code\u003e, and \u003ccode\u003eservice:frontend\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eLabels can be applied to distinguish projects by team or cost center, such as \u003ccode\u003eteam:marketing\u003c/code\u003e or \u003ccode\u003eteam:research\u003c/code\u003e, or to indicate a service's environment like \u003ccode\u003eenvironment:prod\u003c/code\u003e or \u003ccode\u003eenvironment:test\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEach resource can have up to 64 labels, with services being explicitly labeled and versions and instances inheriting labels from their parent service, and note that the App Engine flexible environment does not support billing labels for Firestore in Datastore mode usage.\u003c/p\u003e\n"],["\u003cp\u003eTo view billing data using labels, you can export your data to BigQuery and run queries against the exported dataset, which allows for granular insights into costs, such as outgoing bandwidth costs broken down by service.\u003c/p\u003e\n"],["\u003cp\u003eLabels can be added or modified through the Google Cloud console or via the Admin API, and they can be removed by selecting the services and clicking the "X" next to the labels within the info panel.\u003c/p\u003e\n"]]],[],null,["# Labeling App Engine resources\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\nLabels are a lightweight way to group together resources that are related or\nassociated with each other. You can use labels to get a more fine-grained view\nof how resources are billed for your App Engine services. You can also\ntake advantage of features like nested filtering to perform more precise\nsearches for your resources.\n\nHere are some ways you can use labels:\n\n- Label the types of services you create. For example, if you add labels such\n as `service:default`, `service:backend` and `service:frontend` to your\n App Engine services, you can compare how these different services use\n outgoing bandwidth, instance hours, and other\n [resources](/appengine/docs/standard/quotas#Resources).\n\n- Label by team or cost center to distinguish projects owned by\n different teams. This can be used in cost accounting or budgeting. For\n example, `team:marketing` and `team:research`.\n\n- Label the environment a service is running in. For example,\n `environment:prod` and `environment:test`.\n\n- Label by owner or primary contact if there's an individual who is\n responsible for a resource.\n\n- Label the status of a service. For example, `state:inuse` and\n `state:readyfordeletion`.\n\nLabels can be used only for billing data and not for any other tools, such as\nthe Metrics Explorer.\n\nRestrictions\n------------\n\n- You can assign up to 64 labels to each resource.\n- You can only explicitly label services. Versions and instances inherit labels from their parent service.\n- The App Engine flexible environment does not support billing labels for Firestore in Datastore mode (Datastore) usage.\n\nAdding or modifying labels\n--------------------------\n\nTo add labels to App Engine services: \n\n### Console\n\n1. Go to the App Engine Services page.\n\n [Go to Services](https://console.cloud.google.com/appengine/services)\n2. Select the checkboxes next to the services you want to label.\n\n3. Click **Show info panel** and select the **Labels** tab to expand the labels\n column.\n\n4. Click **Add label** to add a key-value pair to the services you selected. For\n example, to add the label `env:prod`, enter `env` for the **Key** and `prod`\n for the **Value**.\n\n5. Save your changes.\n\n### Admin API\n\nYou can add and set labels through the `Service` resource. Refer to the\nAdmin API reference documentation:\n\n- [REST API](/appengine/docs/admin-api/reference/rest/v1/apps.services#resource:-service)\n- [RPC API](/appengine/docs/admin-api/reference/rpc/google.appengine.v1#service)\n\nViewing billing data associated with your labeled services\n----------------------------------------------------------\n\nYou can add granularity to billing data for your application using labels. For\nexample, you can view the costs for a specific resource, such as the outgoing\nbandwidth, broken down by day and by service. This can give you insight into\ndaily application costs and allow you to optimize your application's resource use.\n\nTo view labels for billing, export your data to BigQuery and then query\nthe data:\n\n1. [Export your billing data to BigQuery](/billing/docs/how-to/export-data-bigquery).\n\n After you enable the BigQuery export, it might take a few\n hours to see your data.\n2. From the [BigQuery page in the Google Cloud console](https://console.cloud.google.com/bigquery),\n select your project and billing dataset.\n\n3. Run a query against the table created from your BigQuery\n export.\n\nLabels are added to your dataset as repeated fields, which that means multiple\nlabels can be attached to a single row in your cost dataset. To easily query by\nlabel, you might want to\n[FLATTEN](/bigquery/docs/legacy-nested-repeated#flatten) the table on the labels\nfield.\n\nFor example, the following query pulls cost data, the label key, and the label\nvalue for outgoing bandwidth where a label exists: \n\n SELECT\n product,\n resource_type,\n start_time,\n end_time,\n labels.key,\n labels.value,\n cost\n FROM (FLATTEN([YOUR_DATASET.TABLEID], labels))\n WHERE\n cost \u003e 0.0\n and labels.key is not null\n and resource_type = 'Out Bandwidth'\n LIMIT 100\n\nBigQuery returns your data with a flattened output:\n\n### Time periods in billing reports\n\nTo ensure that each day in the report covers a full 24 hour period, the billing\ndata that you export only contains data up to the most recent midnight, Pacific\nTime. For example, if you export billing data at noon on December 3rd, the\nexport includes data up to December 2nd, 11:59 PM.\n\nFor each day in the report, billing data is attributed to labels that\nexist at the beginning of the day. For example, if you create a label at noon\nPacific Time on December 3rd, the report for December 3rd will not attribute\ndata to the label since the label did not exist at the beginning of the day.\nData will be attributed to the label starting December 4th.\n\nLabels created at noon and removed in the same 24 hour period will not have data\nattributed to it.\n\nViewing labels in the Google Cloud console\n------------------------------------------\n\nAfter you label resources, you can view the labels in the Google Cloud console.\n\n1. Go to the App Engine Services page.\n\n [Go to Services](https://console.cloud.google.com/appengine/services)\n2. For each service, you can see all the labels in the **Labels** column.\n\nRemoving labels\n---------------\n\nTo remove labels from services:\n\n1. Go to the App Engine Services page.\n\n [Go to App Engine Services](https://console.cloud.google.com/appengine/services)\n2. Select the checkboxes next to the services for which you want to remove\n labels.\n\n3. Click **Show info panel** and select the **Labels** tab to expand the labels\n column.\n\n4. Click the **X** next to all the labels you want to remove.\n\n5. Save your changes."]]