简体   繁体   English

如何从 GCP 的结算 UI 中删除标签?

[英]How do I delete labels from the billing UI in GCP?

In Google Cloud Platform, you can add labels to several resources and also add labels to the query jobs you execute .在 Google Cloud Platform 中,您可以为多个资源添加标签,也可以为您执行的查询作业添加标签 I did this second option.我做了第二个选项。 A typical code looks like this:典型的代码如下所示:

bq query --label=my_label:{parameter} --label=my_label2:{parameter2} --format=json --use_legacy_sql=false '{query}'"

But, by mistake, the first time I did like this:但是,错误地,我第一次这样做:

bq query --label=my_label{parameter} --label=my_label2:{parameter2} --format=json --use_legacy_sql=false '{query}'"

which created several jobs (I regularly ran this command) having a label named my_labelFoo with an empty value instead of a label named my_label with a value of Foo .它创建了几个作业(我经常运行此命令),其中一个名为my_labelFoo具有一个空值,而不是一个名为my_label且值为Foo的 label 。 This was detected when, in the Billing UI, we noticed several labels as options for filtering, being all of them:当我们在 Billing UI 中注意到几个标签作为过滤选项时,检测到了这一点,它们都是:

my_labelFoo my_labelBar my_labelBaz my_labelJohn my_labelGeorge my_labelRingo my_labelPaul... my_labelFoo my_labelBar my_labelBaz my_labelJohn my_labelGeorge my_labelRingo my_labelPaul...

What I tried to do, then, is to delete the metadata of those wrong jobs.那么,我试图做的是删除那些错误作业的元数据。 So I tried this query in BigQuery (having the appropriate permissions):所以我在 BigQuery 中尝试了这个查询(具有适当的权限):

SELECT job_id, query, labels FROM `my-project`.`region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT WHERE ARRAY_LENGTH(labels) > 0 AND EXISTS(SELECT * FROM UNNEST(labels) l WHERE l.key = 'my_labelRingo')"

For each job_id retrieved this way, I tried invoking:对于以这种方式检索到的每个job_id ,我尝试调用:

from google.cloud.bigquery import Client
Client().delete_job_metadata(job_id, location="us")

What I can say for good, is that the job entries were removed (they were a few amount), but...我可以说的是,工作条目已被删除(它们是一些数量),但是......

...when I go back to the Billing UI, I still see the my_labelRingo as a selectable label from there . ...当我 go 返回计费 UI 时,我仍然看到 my_labelRingo 作为可选的 label 从那里 I don't want that label to exist anymore.我不希望 label 不再存在。

So, my question is:所以,我的问题是:

  • How do I delete the wrong labels from the Billing UI?如何从计费 UI 中删除错误的标签?
  • Is there, perhaps, a time I have to wait for my_labelRingo to cease to exist?是否有时间我必须等待my_labelRingo不复存在?

The situation you are experiencing with the labels in the Billing console is something specific to Cloud Billing Support and you will need to directly engage them using this link so they can fully investigate why it is happening.您在计费控制台中遇到的标签情况是 Cloud Billing 支持所特有的,您需要使用此链接直接与他们联系,以便他们全面调查发生这种情况的原因。

The solutions shared below are different alternatives to delete labels in the GCP BigQuery console.下面分享的解决方案是在 GCP BigQuery 控制台中删除标签的不同替代方法。

You can delete a table or view label in the following ways:您可以通过以下方式删除表或查看label:

  1. Using the console使用控制台

  2. Using SQL DDL statements使用 SQL DDL 语句

  3. Using the bq command-line tool's bq update command使用 bq 命令行工具的 bq update 命令

  4. Calling the tables.patch API method调用tables.patch API方法

  • Because views are treated like table resources, tables.patch is used to modify both views and tables.因为视图被视为表资源,tables.patch 用于修改视图和表。
  1. Using the client libraries使用客户端库

But you would need to have the next permissions:但是您需要拥有以下权限:

  • bigquery.tables.get bigquery.tables.get

  • bigquery.tables.update bigquery.tables.update

For example to delete a label through the console you need to follow the next steps:例如,要通过控制台删除 label,您需要执行以下步骤:

  1. On the console, select the dataset you want to edit.在控制台上,select 您要编辑的数据集。

  2. Click on the details tab and then click the pencil icon to the right of labels.单击详细信息选项卡,然后单击标签右侧的铅笔图标。

在此处输入图像描述

  1. On the edit labels dialog在编辑标签对话框中
  • For each label you want to delete, click delete (X)对于您要删除的每个 label,单击删除 (X)

在此处输入图像描述

  • Click on update to save the changes,单击更新以保存更改,

Also you can see more ways to delete labels.您还可以看到更多删除标签的方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM