Add paths to management interface on KC25

71 views
Skip to first unread message

Johannes Reppin

unread,
Jul 12, 2024, 6:36:47 AM7/12/24
to Keycloak User
Hi,
I've been updating (mainly dependencies and breaking changes)
the Keycloak Health Check Repo [1] on our gitlab and github [2].
While this now works with Keycloak 25, the module exposes paths on the regular 
server inferface. 
Could someone point me towards the code in the main keycloak repository on how to
add paths to the _management_ server (default port 9000)?
I don't expose that to the world and it would make my proxy config much simpler.
Best,
Johannes

[1]
[2]

Thomas Darimont

unread,
Jul 12, 2024, 6:59:37 AM7/12/24
to Keycloak User
Hello Johanness,

the following works for me:

```java
package com.thomasdarimont.training.keycloak.health;

import jakarta.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Liveness;

@Liveness
@ApplicationScoped
public class CustomHealthCheck implements HealthCheck {

    @Override
    public HealthCheckResponse call() {
        return HealthCheckResponse.up("Simple health check");
    }
}
```

pom.xml add those dependencies:
```
        <dependency>
            <groupId>org.eclipse.microprofile.health</groupId>
            <artifactId>microprofile-health-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
            <version>4.1.0</version>
            <scope>provided</scope>
        </dependency>
```


{"status": "UP","checks": [{"name": "Simple health check","status": "UP"},{"name": "Keycloak database connections async health check","status": "UP"}]}

Kind regards,
Thomas

Johannes Reppin

unread,
Jul 12, 2024, 8:11:47 AM7/12/24
to Keycloak User
Hi Thomas, 
thanks for the swift reply!
I'll try to add those changes to the health-checks repo and give you some feedback wether it worked.
The infinispan checks are super useful and I don't want to miss them.
Best,
Johannes 

Reply all
Reply to author
Forward
0 new messages