6

I've added labels to the projects in Google Cloud Run GCP, so that I can view the cost filtered by env label to the billing report ( key: env and value: prod ). Regardless of applying any label to Cloud Run, Cost Table does not show the service, even if I do not have any other Cloud Run services without the env label.

I tried redeploying the services a month ago, but nothing changed.

Any idea how to resolve?

Below images show attached labels and the problem inside the Cost Table.

Here Labels attached to Cloud Run

Here Cost Table without filtering by label

Here Cost Table when filtering by label

pualien
  • 138
  • 7
  • Try changing **Group by** to **Label keys** – John Hanley Mar 30 '22 at 08:35
  • @JohnHanley unfortunately as far I can see the costs when grouping by label keys does not count Google Cloud Run labelled services – pualien Mar 30 '22 at 08:58
  • What happens when you change **Group by**? Did you also enable exporting billing data to BigQuery? – John Hanley Mar 30 '22 at 08:59
  • @JohnHanley It happens that the total count by Label does not count Google Cloud Run consumptions. Yes I have billing data to BigQuery – pualien Mar 30 '22 at 09:26
  • Your responses are too terse, I have no idea what is happening on your screen. – John Hanley Mar 30 '22 at 19:24
  • @JohnHanley the problem is that neither in BigQuery GCP cost data I cannot see Cloud Run. Have you got labeled Cloud Run figuring on your Cloud Platform Cost Table? – pualien Mar 31 '22 at 21:25
  • Hi, have you defined the labels through .yaml file? – Zeenath S N Apr 01 '22 at 08:12
  • @ZeenathSN nope I defined them via terraform – pualien Apr 05 '22 at 15:30
  • I think you will have to check if you have made some mistake in defining the labels via terraform, or I suggest you raise a [Google Cloud support ticket](https://cloud.google.com/support/docs/manage-cases#creating_cases), it will be helpful in knowing the root cause. – Zeenath S N Apr 07 '22 at 10:12
  • @pualien did you ever resolve this issue? I am observing similiar behavior. I have Cloud Run services that I have been deploying over a period of ~months with labels. I am able to confirm the labels are being applied to the Cloud Run services. I see a subset (not all!) of the labels listed in Cloud Billing reports. I am unable to "Group By" the label keys that are being caught by billing but the report does not enumerate the label's values. Curiously, I can filter the reports by one of the labels and it finds a single value (there should be more). This appears to be buggy. Did you report it? – DazWilkin Aug 08 '22 at 19:08
  • Filed an issue: https://issuetracker.google.com/issues/241812812 – DazWilkin Aug 08 '22 at 19:56
  • @DazWilkin I haven't resolved yet. I agree that seems buggy, and thanks for filed the issue – pualien Aug 25 '22 at 11:40
  • I think *my* issue is that I've been unable to generate enough Cloud Run spend for the labels to appear. Are you incurring cost attributable to the labels? – DazWilkin Aug 25 '22 at 16:04
  • @pualien Did you do anything to show that Label filter on the Billing page? In my case, smh, the Label section is not even there. I have set a label on one of my Cloud Run services. However, the Label filter is still not there even after days of waiting. – Yusril Maulidan Raji Sep 20 '22 at 12:30
  • @pualien I just found that in this billing tutorial video (https://youtu.be/jRb8piwa2GI?t=97), the Label filter seems not enabled by default. In the video, the menu has no Label filter. Therefore, might I know how you enabled this Label filter in your case? – Yusril Maulidan Raji Sep 20 '22 at 12:43
  • @DazWilkin yes even if I have costs within Google Cloud Run nothing appears when also grouping on labels – pualien Sep 21 '22 at 12:28
  • @YusrilMaulidanRaji as you see in the images I can filter on labels (also grouping on them), but no costs linked Google Cloud Run appears within the labels – pualien Sep 21 '22 at 12:29

1 Answers1

1

According to Google's documentation, the label must be applied to spec.template.metadata.label.

metadata.labels sets labels on the service object, while spec.template.metadata.label sets labels on the created revision. Only labels set on the revision are passed to logs and billing.

Emphasis mine. This key piece of information is only provided under the YAML implementation. The terraform tab simply states:

Add the following to a google_cloud_run_service resource in your Terraform configuration, under the template attribute

metadata {
  # Labels
  # https://cloud.google.com/run/docs/configuring/labels
  labels = {
    foo : "bar"
    baz : "quux"
  }
}

Looking at the issue you raised, it looks like you have set the label on the service object rather than the revision. I made the same mistake at first, too!

Anthony Manning-Franklin
  • 4,408
  • 1
  • 18
  • 23