---
title: Spring Boot ActuatorのThreaddumpエンドでライブスレッド名を取得する
tags: ["Spring Boot", "Spring Boot Actuator"]
categories: ["Programming", "Java", "org", "springframework", "boot"]
date: 2017-11-12T18:24:42Z
updated: 2018-01-02T12:58:18Z
---

メモ

### 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](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0.0-M7-Release-Notes#actuator-configuration-changes)]

```
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'"
```
