Many Google Cloud Marketplace products drive customer usage of Google Cloud
infrastructure and resources. You can integrate labels into your products that
give Google insights into your products' impact in terms of their associated
customer Google Cloud usage, which Google can use to showcase impact and
guide go to market (GTM) investments.

This document describes how to set up partner consumption tracking for
Kubernetes apps that you offer through Cloud Marketplace.

## Label schema

Labels are key-value pairs that you can assign to Google Cloud resources.
For more information about labels, see the
[Overview of labels](https://docs.cloud.google.com/resource-manager/docs/labels-overview.md.txt).

When you use labels for partner consumption tracking, your labels use the
following format:

    goog-partner-solution = SOLUTION_URN

### Find your product's consumption tracking label

For each product that you offer through Cloud Marketplace, you can find its
associated consumption tracking label in Producer Portal. To find the
label, take the following steps:

1. In Producer Portal, visit the **Overview** page.
2. In the list of your products, find the product whose consumption you want to track.
3. Copy and save the value listed for **Consumption tracking label**.
4. When you integrate your product's consumption tracking, use the consumption tracking label that you saved.

The direct link to the Producer Portal **Overview** page is:

```
https://console.cloud.google.com/producer-portal?project=YOUR_PROJECT_ID
```

## Integrate the consumption tracking label with your Kubernetes app

To turn on consumption tracking for your Kubernetes app, complete the following
steps:

- Include the consumption tracking label in all of your Pod specifications, as shown in the example that follows.
- Create your Pod specification with defined resources.

> [!NOTE]
> **Note:** Your product must add the label at the resource level, instead of at the project level.

With Terraform, you can add a default label at the Google provider level that
applies to all Google Cloud resources that Terraform deploys. For more
information about using default labels with Terraform, see the
[Google Cloud Provider Configuration Reference](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#default_labels)
in the Terraform documentation.

### Example consumption tracking label integration

The following example shows a Pod specification for a Kubernetes deployment with
a consumption tracking label added to it:

```terraform
apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-app
  labels:
    app: example-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: example-app
  template:
    metadata:
      labels:
        app: example-app
        goog-partner-solution: isol_plb32_SOLUTION_URN
    spec:
      containers:
      - name: example-app
        image: busybox:latest
        command:
            - "/bin/sh"
            - "-c"
            - "while true; do sleep 3600; done"
        resources:
          limits:
            cpu: "500m"
            ephemeral-storage: "10Mi"
            memory: "0.5Gi"
          requests:
            cpu: "500m"
            ephemeral-storage: "10Mi"
            memory: "0.5Gi"
```

Replace <var translate="no">SOLUTION_URN</var> with your app's consumption tracking
label. To find the consumption tracking label, in Producer Portal, find
your app in the **Your products** table. The value in the
**Consumption tracking label** column is your app's consumption tracking label.

In this sample, the following lines define the resources, which is required for
consumption tracking:

```terraform
resources:
  limits:
    cpu: "500m"
    ephemeral-storage: "10Mi"
    memory: "0.5Gi"
  requests:
    cpu: "500m"
    ephemeral-storage: "10Mi"
    memory: "0.5Gi"
```