有没有办法获取 flink taskmanagers 的任务管理器 id

Is there a way to get the task manager id of the flink taskmanagers

我想获取任务管理器的完整 ID/哈希 ID 并使用它报告指标。

您可以在 http://localhost:8081 的 JobManager Web 前端检查哪些任务映射到哪个任务槽。你还有一堆指标。

您可以使用公制。

在(丰富的)用户定义的函数调用中 getRuntimeContext().getMetricGroup().getAllVariables().get("")

最后我通过获取每个任务管理器的 YARN 应用程序容器 ID 得到了解决方案运行。

容器 ID 适合我的目的,不过感谢您的所有见解。

您可以通过以下方式获取计划任务管理器的 JSON 格式输出:

curl -s "http://localhost:8081/taskmanagers/"

如果您只对 TaskManager 的 ID 感兴趣,可以使用 jq (https://stedolan.github.io/jq/) 获取它。

获取第一个TaskManager的id的例子:

local task_manager_id=`curl -s "http://localhost:8081/taskmanagers/" | jq -r '.taskmanagers[0].id'`