diff --git a/src/main/docs/guide/management/providedEndpoints/healthEndpoint.adoc b/src/main/docs/guide/management/providedEndpoints/healthEndpoint.adoc index d8ff91a4d5d..38ef4b88d5f 100644 --- a/src/main/docs/guide/management/providedEndpoints/healthEndpoint.adoc +++ b/src/main/docs/guide/management/providedEndpoints/healthEndpoint.adoc @@ -144,3 +144,55 @@ The JDBC health indicator determines the health of your application based on the If your application uses service discovery, a health indicator is included to monitor the health of the discovery client. The data returned can include a list of the services available. TIP: See the guide for https://guides.micronaut.io/latest/micronaut-health-endpoint.html[Exposing a Health Endpoint for your Micronaut Application] to learn more. + +== Deadlocked Threads + +The deadlocked threads health indicator uses the link:{jdkapi}/java.management/java/lang/management/ThreadMXBean.html[ThreadMXBean] to check for deadlocked threads and is part of the /health and /health/liveness endpoints. + +Its only configuration option is to enable or disable the indicator by the `endpoints.health.deadlocked-thread.enabled` key. It is enabled by default. + +The health status is set to api:health.HealthStatus#DOWN[DOWN] if any deadlocked threads are found and their link:{jdkapi}/java.management/java/lang/management/ThreadInfo.html[ThreadInfo] including a formatted stacktrace are given in the details. See below for an example. + +[source,json] +---- +{ + "name": "example-app", + "status": "DOWN", + "details": { + "deadlockedThreads": { + "name": "example-app", + "status": "DOWN", + "details": [ + { + "threadId": "60", + "threadName": "Thread-0", + "threadState": "BLOCKED", + "daemon": "false", + "priority": "5", + "suspended": "false", + "inNative": "false", + "lockName": "java.lang.Object@7d10b1ca", + "lockOwnerName": "Thread-1", + "lockOwnerId": "61", + "lockedSynchronizers": [], + "stackTrace": "app//com.example.Deadlock.lambda$new$0(Deadlock.java:27)\n- blocked on java.lang.Object@7d10b1ca\n- locked java.lang.Object@4505ea74\napp//com.example.Deadlock$$Lambda/0x000001906948b360.run(Unknown Source)\njava.base@21/java.lang.Thread.runWith(Thread.java:1596)\njava.base@21/java.lang.Thread.run(Thread.java:1583)\n" + }, + { + "threadId": "61", + "threadName": "Thread-1", + "threadState": "BLOCKED", + "daemon": "false", + "priority": "5", + "suspended": "false", + "inNative": "false", + "lockName": "java.lang.Object@4505ea74", + "lockOwnerName": "Thread-0", + "lockOwnerId": "60", + "lockedSynchronizers": [], + "stackTrace": "app//com.example.Deadlock.lambda$new$1(Deadlock.java:43)\n- blocked on java.lang.Object@4505ea74\n- locked java.lang.Object@7d10b1ca\napp//com.example.Deadlock$$Lambda/0x000001906948b580.run(Unknown Source)\njava.base@21/java.lang.Thread.runWith(Thread.java:1596)\njava.base@21/java.lang.Thread.run(Thread.java:1583)\n" + } + ] + } + } +} +----