按尺码对纱线的 运行 应用进行排名

Ranking yarn's running application by size

我想到了一种按尺寸列出 yarn 运行 应用程序的方法。因为大小分为分配的 MB 和分配的 VCore,我决定假设一个 VCore 大约为 10000 MB。

# Uses httpie and jq, or you could use curl with -H Content-Type:application/json
http http://yarn-web-ui-url:port/ws/v1/cluster/apps|jq '
  .apps.app 
  | sort_by(.allocatedMB + .allocatedVCores * 10000) 
  | reverse 
  | .[] 
  | select(.state == "RUNNING") 
  | {name, allocatedMB, allocatedVCores, user, id, trackingUrl}' | 
  less

但是有什么方法可以直接在 UI 中执行此操作吗?如果没有,有没有人看到更有效的方式来编写 JQ 部分。

does anyone see a more effective way to write the JQ part

为了效率,最好先选择再排序。您的过滤器也可以稍微简化:

  .apps.app 
  | map(select(.state == "RUNNING"))
  | sort_by(.allocatedMB + .allocatedVCores * 10000) 
  | reverse[] 
  | {name, allocatedMB, allocatedVCores, user, id, trackingUrl}