Labeling App Engine resources

Labels are a lightweight way to group together resources that are related orassociated with each other. You can use labels to get a more fine-grained viewof how resources are billed for your App Engine services. You can alsotake advantage of features like nested filtering to perform more precisesearches for your resources.

Here are some ways you can use labels:

  • Label the types of services you create. For example, if you add labels suchasservice:default,service:backend andservice:frontend to yourApp Engine services, you can compare how these different services useoutgoing bandwidth, instance hours, and otherresources.

  • Label by team or cost center to distinguish projects owned bydifferent teams. This can be used in cost accounting or budgeting. Forexample,team:marketing andteam:research.

  • Label the environment a service is running in. For example,environment:prod andenvironment:test.

  • Label by owner or primary contact if there's an individual who isresponsible for a resource.

  • Label the status of a service. For example,state:inuse andstate:readyfordeletion.

Labels can be used only for billing data and not for any other tools, such as the Metrics Explorer.

Restrictions

  • You can assign up to 64 labels to each resource.
  • You can only explicitly label services. Versions and instances inheritlabels from their parent service.
  • The App Engine flexible environment does not support billing labels for Firestore in Datastore mode (Datastore) usage.

Adding or modifying labels

To add labels to App Engine services:

Console

  1. Go to the App Engine Services page.

    Go to Services

  2. Select the checkboxes next to the services you want to label.

  3. ClickShow info panel and select theLabels tab to expand the labelscolumn.

  4. ClickAdd label to add a key-value pair to the services you selected. Forexample, to add the labelenv:prod, enterenv for theKey andprodfor theValue.

  5. Save your changes.

Admin API

You can add and set labels through theService resource. Refer to theAdmin API reference documentation:

Viewing billing data associated with your labeled services

You can add granularity to billing data for your application using labels. Forexample, you can view the costs for a specific resource, such as the outgoingbandwidth, broken down by day and by service. This can give you insight intodaily application costs and allow you to optimize your application's resource use.

To view labels for billing, export your data to BigQuery and then querythe data:

  1. Export your billing data to BigQuery.

    After you enable the BigQuery export, it might take a fewhours to see your data.

  2. From theBigQuery page in the Google Cloud console,select your project and billing dataset.

  3. Run a query against the table created from your BigQueryexport.

Labels are added to your dataset as repeated fields, which that means multiplelabels can be attached to a single row in your cost dataset. To easily query bylabel, you might want toFLATTEN the table on the labelsfield.

For example, the following query pulls cost data, the label key, and the labelvalue for outgoing bandwidth where a label exists:

SELECTproduct,resource_type,start_time,end_time,labels.key,labels.value,costFROM(FLATTEN([YOUR_DATASET.TABLEID],labels))WHEREcost >0.0andlabels.keyisnotnullandresource_type='OutBandwidth'LIMIT100

BigQuery returns your data with a flattened output:

productresource_typestart_timeend_timelabels_keylabels_valuecost
App EngineOut Bandwidth2017-10-07 22:00:002017-10-07 23:00:00servicedefault0.020033
App EngineOut Bandwidth2017-10-07 13:00:002017-10-07 14:00:00servicefrontend0.016042
App EngineOut Bandwidth2017-10-07 06:00:002017-10-07 07:00:00servicebackend_task0.013125
App EngineOut Bandwidth2017-10-07 21:00:002017-10-07 22:00:00servicedefault0.020722
App EngineOut Bandwidth2017-10-07 19:00:002017-10-07 20:00:00servicefrontend0.020725
App EngineOut Bandwidth2017-10-08 04:00:002017-10-08 05:00:00servicebackend_task0.02072
App EngineOut Bandwidth2017-10-08 02:00:002017-10-08 03:00:00servicedefault0.020723
App EngineOut Bandwidth2017-10-07 14:00:002017-10-07 15:00:00servicefrontend0.020724
App EngineOut Bandwidth2017-10-07 23:00:002017-10-08 00:00:00servicebackend_task0.021417

Time periods in billing reports

To ensure that each day in the report covers a full 24 hour period, the billingdata that you export only contains data up to the most recent midnight, PacificTime. For example, if you export billing data at noon on December 3rd, theexport includes data up to December 2nd, 11:59 PM.

For each day in the report, billing data is attributed to labels thatexist at the beginning of the day. For example, if you create a label at noonPacific Time on December 3rd, the report for December 3rd will not attributedata to the label since the label did not exist at the beginning of the day.Data will be attributed to the label starting December 4th.

Labels created at noon and removed in the same 24 hour period will not have dataattributed to it.

Viewing labels in the Google Cloud console

After you label resources, you can view the labels in the Google Cloud console.

  1. Go to the App Engine Services page.

    Go to Services

  2. For each service, you can see all the labels in theLabels column.

Removing labels

To remove labels from services:

  1. Go to the App Engine Services page.

    Go to App Engine Services

  2. Select the checkboxes next to the services for which you want to removelabels.

  3. ClickShow info panel and select theLabels tab to expand the labelscolumn.

  4. Click theX next to all the labels you want to remove.

  5. Save your changes.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-17 UTC.