我有以下非常简单的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。管道运行正常,但是当我尝试查看指标时,只会得到:
现在我问自己我在做什么错?是否缺少一些配置参数,或者这不是在仪表板中查看该指标的正确位置?有人可以建议或至少指向我提供更多信息的资源吗?
env.disableOperatorChaining();