Apache Flink 仪表板未显示指标
Apache Flink Dashboard not showing metrics
我有以下非常简单的 Apache Flink 管道,我想通过 Apache Flink 仪表板获取一些指标,如 Apache Flink documentation 中所述:
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();
}
}
我 运行 使用通过 Docker-Hub 提供的 Docker 设置执行该管道。一切都使用 Apache Flink 1.10.0。管道 运行 很好,但是当我尝试查看我的指标时,我只得到:
现在我问自己我做错了什么?是否缺少某些配置参数,或者这不是在仪表板中查看该指标的正确位置?有人可以建议或至少给我指出一个资源,我可以从那里获得更多信息吗?
我相信发生的事情是您向地图运算符添加了运算符指标,但网络 ui 显示的是任务指标。 (在这个简单的、令人尴尬的并行作业的情况下,source、map 和 sink 运算符已链接在一起成为一个任务。)
要检查您添加的这个指标,您可以使用 REST API,或任何指标记者。我认为如果您通过
禁用运算符链接,它也可能会出现在网络中 UI
env.disableOperatorChaining();
我有以下非常简单的 Apache Flink 管道,我想通过 Apache Flink 仪表板获取一些指标,如 Apache Flink documentation 中所述:
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();
}
}
我 运行 使用通过 Docker-Hub 提供的 Docker 设置执行该管道。一切都使用 Apache Flink 1.10.0。管道 运行 很好,但是当我尝试查看我的指标时,我只得到:
现在我问自己我做错了什么?是否缺少某些配置参数,或者这不是在仪表板中查看该指标的正确位置?有人可以建议或至少给我指出一个资源,我可以从那里获得更多信息吗?
我相信发生的事情是您向地图运算符添加了运算符指标,但网络 ui 显示的是任务指标。 (在这个简单的、令人尴尬的并行作业的情况下,source、map 和 sink 运算符已链接在一起成为一个任务。)
要检查您添加的这个指标,您可以使用 REST API,或任何指标记者。我认为如果您通过
禁用运算符链接,它也可能会出现在网络中 UI env.disableOperatorChaining();