简体   繁体   English

从 GCP 中的日志接收器创建 BigQuery 数据集

[英]Creating a BigQuery dataset from a log sink in GCP

When running跑步时

gcloud logging sinks list

it seems I have several sinks for my project看来我的项目有几个水槽

▶ gcloud logging sinks list
NAME                    DESTINATION                                                                                    FILTER
myapp1                  bigquery.googleapis.com/projects/myproject/datasets/myapp1                      resource.type="k8s_container" resource.labels.cluster_name="mygkecluster" resource.labels.container_name="myapp1"
myapp2                  bigquery.googleapis.com/projects/myproject/datasets/myapp2                      resource.type="k8s_container" resource.labels.cluster_name="mygkecluster" resource.labels.container_name="myapp2"
myapp3                  bigquery.googleapis.com/projects/myproject/datasets/myapp3                      resource.type="k8s_container" resource.labels.cluster_name="mygkecluster" resource.labels.container_name="myapp3"

However, when I navigate in my BigQuery console, I don't see the corresponding datasets.但是,当我在BigQuery控制台中导航时,我看不到相应的数据集。

Is there a way to import these sinks as datasets so that I can run queries against them?有没有办法将这些接收器作为数据集导入,以便我可以对它们运行查询?

This guide on creating BigQuery datasets does not list how to do so from a log sink (unless I am missing something)关于创建BigQuery数据集的指南没有列出如何从日志接收器执行此操作(除非我遗漏了什么)

Also any idea why the above datasets are not displayed when using the bq ls command?还有任何想法为什么在使用bq ls命令时不显示上述数据集?

Firstly, be sure to be in the good project.首先,一定要在好的项目中。 if not, you can import dataset from external project by clicking on the PIN button (and you need to have enough permission for this).如果没有,您可以通过单击 PIN 按钮从外部项目导入数据集(并且您需要为此拥有足够的权限)。

Secondly, the Cloud Logging sink to BigQuery doesn't create the dataset, only the tables.其次,BigQuery 的 Cloud Logging 接收器不会创建数据集,只会创建表。 So, if you have created the sinks without the dataset, you sinks aren't running (or run in error).因此,如果您创建了没有数据集的接收器,则接收器没有运行(或错误运行)。 Here more details 这里有更多细节

BigQuery: Select or create the particular dataset to receive the exported logs. BigQuery:Select 或创建特定数据集以接收导出的日志。 You also have the option to use partitioned tables.您还可以选择使用分区表。

In general, what you expect for this feature to do is right, using BigQuery as log sink is to allow you to query the logs with BQ.一般来说,你期望这个功能做的事情是对的,使用 BigQuery 作为日志接收器是为了让你可以使用 BQ 查询日志。 For the problem you're facing, I believe it is to do with using Web console vs. gcloud.对于您面临的问题,我相信这与使用 Web 控制台与 gcloud 有关。

When using BigQuery as log sink, there are 2 ways to specify a dataset:使用 BigQuery 作为日志接收器时,有两种方法可以指定数据集:

  1. point to an existing dataset指向现有数据集
  2. create a new dataset创建一个新数据集

When creating a new sink via web console, there's an option to have Cloud Logging create a new dataset for you as well.通过 web 控制台创建新接收器时,还可以选择让 Cloud Logging 为您创建新数据集。 However, when using gcloud logging sinks create , it does not automatically create a dataset for you, only create the log sink.但是,当使用gcloud logging sinks create时,它不会自动为您创建数据集,只会创建日志接收器。 It seems like it also does not validate whether the specified dataset exists.似乎它也没有验证指定的数据集是否存在。

To resolve this, you could either use web console for the task or create the datasets on your own.要解决此问题,您可以使用 web 控制台执行任务或自行创建数据集。 There's nothing special about creating a BQ dataset to be a log sink destination comparing to creating a BQ dataset for other purpose.与为其他目的创建 BQ 数据集相比,创建 BQ 数据集作为日志接收器目的地并没有什么特别之处。 Create a BQ dataset, then create a log sink to point to the dataset and you're good to go.创建一个 BQ 数据集,然后创建一个日志接收器以指向该数据集,然后您就可以使用 go。

Conceptually, different products (BigQuery, Cloud Logging) on GCP runs independently, the log sink in Cloud Logging is simply an object that pairs up filter and destination, but does not own/manage the destination resource (eg. BQ dataset).从概念上讲,GCP 上的不同产品(BigQuery、Cloud Logging)独立运行,Cloud Logging 中的日志接收器只是一个将过滤器和目标配对的 object,但不拥有/管理目标资源(例如 BQ 数据集)。 It's just that in web console, it provide some extra integration to make things easier.只是在 web 控制台中,它提供了一些额外的集成以使事情变得更容易。

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

相关问题 GCP 日志路由器接收器未将日志路由到主题? - GCP Log Router Sink Not Routing Logs to Topic? 如何将一个 bigquery 数据集复制或传输到来自不同 gcp 组织的另一个 bigquery - How to copy or transfer one bigquery dataset to another bigquery from a different gcp organization 在GCP中创建REST API从BigQuery读取数据 - Creating REST API in GCP to read data from BigQuery GCP Dataflow 无法访问其他 GCP 项目中的 BigQuery 数据集 - GCP Dataflow is unable to access BigQuery dataset in a different GCP project 尝试在 GCP 中创建 BigQuery 数据集传输配置从项目 A 到项目 B - Trying to Create a BigQuery Dataset Transfer config from Project A to Project B in GCP 带有多个接收器过滤器的 GCP 日志导出发布/订阅 Terraform - GCP Log-export pub/sub with multiple sink filters with Terraform 更新在GCP中包含bigquery数据集的云部署 - Updating cloud deployment which contains bigquery dataset in GCP SQL 使用 github_repos 数据集在 GCP BigQuery 上查询验证失败 - SQL Query validation failure on GCP BigQuery with github_repos dataset 有没有办法监控 BigQuery (GCP) 中数据集下的所有表/视图更新? - Is there a way to monitor all table/view updates under a dataset in BigQuery (GCP)? 将数据从 GCP (BIgquery) 迁移到 Teradata - Migrating data from GCP (BIgquery) to Teradata
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM