Spring Boot ActuatorのThreaddumpエンドでライブスレッド名を取得する

メモ

Spring Boot 1の場合

curl -s http://localhost:8080/dump | jq '.[].threadName'

RUNNABLEな状態のみの場合

curl -s http://localhost:8080/dump | jq '. | map(select(.threadState == "RUNNABLE"))[].threadName'

watchしたいなら

watch -n 1 "curl -s http://localhost:8080/dump  | jq '. | map(select(.threadState == \"RUNNABLE\"))[].threadName'"

Spring Boot 2 (2.0.0.M7以降)の場合

2.0.0.M7からActuatorエンドポイントのprefixが変わりました。 [URL]

curl -s http://localhost:8080/actuator/threaddump  | jq '.threads[].threadName'

RUNNABLEな状態のみの場合

curl -s http://localhost:8080/actuator/threaddump  | jq '.threads | map(select(.threadState == "RUNNABLE"))[].threadName'

watchしたいなら

watch -n 1 "curl -s http://localhost:8080/actuator/threaddump  | jq '.threads | map(select(.threadState == \"RUNNABLE\"))[].threadName'"

Spring Boot 2 (2.0.0.M6以前)の場合

curl -s http://localhost:8080/application/threaddump  | jq '.threads[].threadName'

RUNNABLEな状態のみの場合

curl -s http://localhost:8080/application/threaddump  | jq '.threads | map(select(.threadState == "RUNNABLE"))[].threadName'

watchしたいなら

watch -n 1 "curl -s http://localhost:8080/application/threaddump  | jq '.threads | map(select(.threadState == \"RUNNABLE\"))[].threadName'"