简体   繁体   English

Apache Flink 仪表板未显示指标

[英]Apache Flink Dashboard not showing metrics

I have the following very simple Apache Flink Pipeline for which I would like to get some metrics, as explained in the Apache Flink documentation , via the Apache Flink Dashboard:我有以下非常简单的 Apache Flink Pipeline,我想通过 Apache Flink 仪表板获取一些指标,如Apache Flink 文档中所述:

import org.apache.flink.api.common.functions.RichMapFunction;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.metrics.Counter;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.RichSourceFunction;

public class Pipeline {

    public static void main(String[] args) throws Exception {
        final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.addSource(new RichSourceFunction<String>() {
            private static final long serialVersionUID = 3990963645875188158L;
            private boolean notCanceled = true;

            @Override
            public void run(SourceContext<String> ctx) throws Exception {
                while (notCanceled) {
                    ctx.collect("test");
                }
            }

            @Override
            public void cancel() {
                notCanceled = false;
            }
        }).map(new RichMapFunction<String, String>() {
            private static final long serialVersionUID = 1L;
            private transient Counter counter;

            @Override
            public void open(Configuration parameters) throws Exception {
                super.open(parameters);
                this.counter = getRuntimeContext()
                        .getMetricGroup()
                        .counter("myCounter");
            }

            @Override
            public String map(String value) throws Exception {
                this.counter.inc();
                return "mappedtext";
            }
        }).print();

        env.execute();
    }

}

I do run that Pipeline using the Docker Setup available via Docker-Hub .我确实使用Docker-Hub提供的 Docker 设置运行该管道。 Everything uses Apache Flink 1.10.0.一切都使用 Apache Flink 1.10.0。 The Pipeline runs fine, but when I try to view my metric I only get:管道运行良好,但是当我尝试查看我的指标时,我只会得到: 指标未显示

Now I ask myself what am I doing wrong?现在我问自己我做错了什么? Is there some configuration parameter I am missing or is this not the correct place to view that metric in the dashboard?我是否缺少某些配置参数,或者这不是在仪表板中查看该指标的正确位置? Can someone please advise or at least point me to a resource, where I would get more information?有人可以建议或至少指出我可以从哪里获得更多信息的资源吗?

I believe what's going on is that you have added an operator metric to the map operator, but the web ui is displaying task metrics.我相信正在发生的事情是您已向地图运算符添加了运算符度量,但 Web ui 正在显示任务度量。 (In the case of this simple, embarrassingly parallel job, the source, map, and sink operators have been chained together into a single task.) (在这个简单的、令人尴尬的并行作业的情况下,源、映射和接收器操作符已被链接到一个任务中。)

To inspect this metric you've added, you could use the REST API, or any of the metrics reporters.要检查您添加的此指标,您可以使用 REST API 或任何指标报告器。 I think it may also show up in the web UI if you disable operator chaining via我认为如果您通过以下方式禁用操作员链接,它也可能显示在 Web UI 中

    env.disableOperatorChaining();

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

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