how to take thread dump of java application on a distroless container running on kubernetes?

1/20/2022

My cluster have many java applications running on it, I would like to take thread dump for few microservices. But as these are distroless images, I was thinking of ephemeral containers but not sure if volume can be attached to such containers. Can someone help?

Regards, Anjani

-- Anjani Mishra
distroless
kubernetes
thread-dump

2 Answers

2/23/2022

Are you using Spring Boot to build those microservices? If yes, then by using Spring Boot Admin you can get thread dumps, heap dumps and monitor your services from a single window.

Please check here to get more details about it.

-- suv3ndu
Source: StackOverflow

3/28/2022

Check Spring Boot actuator endpoints https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints

There is a dedicated endpoint for thread dumps. Note that by default it returns custom JSON format, but you could request default text format.

curl 'http://localhost:8080/actuator/threaddump' -i -X GET \
-H 'Accept: text/plain'

See for more details https://docs.spring.io/spring-boot/docs/current/actuator-api/htmlsingle/#threaddump.retrieving-text

-- Bartosz Bilicki
Source: StackOverflow