【问题标题】:How to find total execution time taken for each step in Google DataFlow using java sdk如何使用 java sdk 查找 Google DataFlow 中每个步骤的总执行时间
【发布时间】:2018-03-22 20:17:39
【问题描述】:

我正在使用 Apache-beam-2.3.0 在 Google 云平台上运行 DataFlow 作业。每个 dataFlow 作业有 5 个步骤。我想跟踪使用 java SDK 完成作业中每个步骤所花费的时间

Pipeline pipeline = Pipeline.create(options);

for(int i=0; i<5; i++) {
PCollection<String> csv = pipeline.apply(transform1);
csv.apply(transform2);
}

pipeline.run().waitUntilFinish();

如何使用PipelineResult衡量完成工作中每个步骤所用的时间

【问题讨论】:

  • 感谢任何输入

标签: java google-cloud-dataflow apache-beam


【解决方案1】:

您可以使用queryMetricsPipelineResult 来查看步骤级别的指标。例如:

Pipeline p = ...;
 p.apply("create1", Create.of("hello")).apply("myStepName1", ParDo.of(new SomeDoFn()));
 p.apply("create2", Create.of("world")).apply("myStepName2", ParDo.of(new SomeDoFn()));
 PipelineResult result = p.run();
 MetricResults metrics = result.metrics();
 MetricQueryResults metricResults = metrics.queryMetrics(new MetricsFilter.Builder()
     .addNameFilter("my-counter")
     .addStepFilter("myStepName1").addStepFilter("myStepName2")
     .build());
 Iterable<MetricResult<Long>> counters = metricResults.counters();
 // counters should contain the value of my-counter reported from each of the ParDo
 // applications.

在这种情况下,您可以定义 distribution metric,而不是计数器,如 here 所述。此link 中的一些示例。

【讨论】:

    猜你喜欢
    • 2017-12-15
    • 1970-01-01
    • 1970-01-01
    • 2020-10-27
    • 2016-11-04
    • 1970-01-01
    • 2016-06-12
    • 1970-01-01
    • 2022-08-18
    相关资源
    最近更新 更多