Apache Flink-显示计数器值,但不显示仪表值

时间:2020-01-16 12:42:20

标签: apache-flink flink-streaming

我们正在使用 Flink 1.8.0 并在 EMR-纱线上运行它,并希望测量吞吐量。

  1. 由于我们的运算符是链接在一起的,因此我们在代码中添加了仪表和计数器-本质上是一个异步运算符,它使用kinesis作为源和同步进行API调用。在Application Master(即Flink的Web UI)中,我们能够获取计数器的值,而不是仪表的值。
public class AsyncClass extends RichAsyncFunction<String, String> {

    private transient Counter counter;

    private transient Meter meter;

    @Override
    public void open(Configuration parameters) throws Exception {
        super.open(parameters);

        this.counter = getRuntimeContext()
                  .getMetricGroup()
                  .counter("myCounter");

        this.meter = getRuntimeContext()
                .getMetricGroup()
                .meter("myMeter", new DropwizardMeterWrapper(new com.codahale.metrics.Meter()));
    }

    @Override
    public void close() throws Exception {
        super.close();
        ExecutorUtils.gracefulShutdown(20000, TimeUnit.MILLISECONDS, executorService);
    }



    @Override
    public void asyncInvoke(String key, final ResultFuture<String> resultFuture) throws Exception {


        resultFuture.complete(key);
        this.meter.markEvent();
        this.counter.inc();

    }
}
  1. 要衡量应用程序的完整吞吐量,我们显然需要所有任务管理器的吞吐量。使用仪表,我们可以获取各个任务管理器的指标。有什么方法可以在运营商级别对其进行衡量吗?

1 个答案:

答案 0 :(得分:0)

将结果显示出来,仪表将显示整数值,并且以十进制表示速率。当我的负载为每秒1个事件恒定时,实际上它的测量值为0.9xxx,因此每秒仅显示0个事件。

相关问题