在IDEA中执行Flink应用时如何访问Dashboard?

在Flink的local模式、standalone模式下 , 我们可以访问集群中jobmanager节点默认的8081端口 , 就可以打开Flink Dashboard界面 。
在IDEA中执行Flink应用时 , 是否也可以显示Dashboard界面么?
可以 , 但是需要添加flink-runtime-web 包的支持 。
下面具体介绍如何查看dashboard 。
一、添加依赖包首先 , 需要在Flink项目的pom文件中 , 添加如下依赖项:

org.apache.flink
flink-runtime-web_${scala.binary.version}
${flink.version}
compile

二、运行Flink应用查看web frontend端口号在IDEA中启动Flink应用 , 查看启动日志如下:
23:05:06,130 INFO org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - Rest endpoint listening at localhost:43777
23:05:06,132 INFO org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedLeaderService - Proposing leadership to contender http://localhost:43777
23:05:06,136 INFO org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - Web frontend listening at http://localhost:43777.
23:05:06,136 INFO org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - http://localhost:43777 was granted leadership with leaderSessionID=fc988d7f-7780-4849-9931-fbbade84cc6f
23:05:06,136 INFO org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedLeaderService - Received confirmation of leadership for leader http://localhost:43777 , session=fc988d7f-7780-4849-9931-fbbade84cc6f
23:05:06,154 INFO org.apache.flink.runtime.rpc.akka.AkkaRpcService - Starting RPC endpoint for org.apache.flink.runtime.resourcemanager.StandaloneResourceManager at akka://flink/user/rpc/resourcemanager_1 .
23:05:06,173 INFO org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedLeaderService - Proposing leadership to contender LeaderContender: DefaultDispatcherRunner
23:05:06,173 INFO org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedLeaderService - Proposing leadership to contender LeaderContender: StandaloneResourceManager
23:05:06,176 INFO org.apache.flink.runtime.resourcemanager.StandaloneResourceManager - ResourceManager akka://flink/user/rpc/resourcemanager_1 was granted leadership with fencing token a88541b673479191b1fb0ec4a3154cdf
23:05:06,178 INFO org.apache.flink.runtime.minicluster.MiniCluster - Flink Mini Cluster started successfully
通过上面的日志 , 可以看到Flink dashboard监听地址如下:
http://localhost:43777
在浏览器中访问上述URL , 就可以访问Flink Dashboard界面了 。
在IDEA中执行Flink应用时如何访问Dashboard?文章插图
查看正在运行的running jobs:Flink Streaming Word Count by Scala , 如图所示 。
【在IDEA中执行Flink应用时如何访问Dashboard?】其中 , Parallelism(并行度)=8 , 默认并行度和CPU核心数一致 。
在IDEA中执行Flink应用时如何访问Dashboard?文章插图


    推荐阅读