自定义数据流模板 - BigQuery 到 CloudStorage - 文档?一般解决方案建议?

Custom Dataflow Template - BigQuery to CloudStorage - documentation? general solution advice?

我正在使用 BigQuery table 数据源。它是 'unbounded',因为它是通过批处理更新的。它包含来自服务器日志的 session 键控报告数据,其中每一行捕获一个请求。我无权访问原始日志数据,必须使用 BigQuery table。

我想使用 beam api 开发一个基于 Java 的自定义 google 数据流模板,目标是:

  1. 整理键控 session objects

  2. 推导 session 级别指标

  3. 根据 session 指标导出可过滤的 window 级别指标,例如,在之前 window 期间出错的 session 百分比和每个过滤的错误 属性,例如,每个设备类型的错误百分比

  4. 将结果作为 formatted/compressed 报告写入云存储。

这似乎是一个相当标准的用例?到目前为止,在我的研究中,我还没有找到一个完美的例子,仍然无法确定某些基本要求的最佳实践方法。我将非常感谢任何指示。要研究的关键词?文档、教程。我目前的想法是正确的还是我需要考虑其他方法?

问题:

  1. beam windowing 和 BigQuery I/O 连接器 - 我看到我可以指定一个 window 类型和尺寸通过光束 api。我的 BQ table 每行都有一个时间戳字段。我应该以某种方式通过配置传递它还是应该是自动的?我是否需要通过 SQL 查询以某种方式手动执行此操作?这个我不清楚。

  2. 固定时间 windowing 与 session windowing 函数 - 示例是基本的,不涉及任何边缘情况。我的 session 可以持续几个小时。每个 window 可能有 100ks 加 session 个键。 session window 会支持这个吗?

  3. BigQuery 与 BigQueryClientStorage - 我不清楚其中的区别。我知道 BQCS 提供了性能优势,但我是否必须在初步步骤中存储 BQ 数据才能使用它?或者我可以直接通过 BQCS 查询我的 table,它会帮我解决这个问题吗?

对于 number 1,您可以在应用窗口之前简单地使用 withTimestamps 函数,这会将时间戳分配给您的项目。 Here 是一些 python 个示例。

对于 数字 2 documentation 状态:

Session windowing applies on a per-key basis and is useful for data that is irregularly distributed with respect to time. [...] If data arrives after the minimum specified gap duration time, this initiates the start of a new window.

同样在 java documentation 中,您只能指定最短间隙持续时间,而不能指定最长间隙。这意味着会话窗口可以轻松支持持续数小时的会话。毕竟,它所做的唯一一件事就是在您的数据上加上水印并使其保持活动状态。

对于数字3BigQuery IO Connector and the BigQuery storage APIs is that the latter (an experimental feature as of 01/2020) access directly data stored, without the logical passage through BigQuery (BigQuery data isn't stored in BigQuery). This means that with storage APIs, the documentation状态之间的差异:

you can't use it to read data sources such as federated tables and logical views

此外,这两种方法之间有不同的限制和配额,您可以在上面的文档 link 中找到。